Skip to content
Permalink
Browse files

Renamed accessor/mutator and deprecated old names

  • Loading branch information
homann committed Aug 23, 2012
1 parent dd4de85 commit e455264ac625140c3a1a54abaadf924c41a068d4
@@ -15,9 +15,11 @@ class QgsDistanceArea

//! sets whether coordinates must be projected to ellipsoid before measuring
void setProjectionsEnabled(bool flag);
void setEllipsoidalEnabled(bool flag) /Deprecated/;

//! returns projections enabled flag
bool hasCrsTransformEnabled();
bool ellipsoidalEnabled();
bool hasCrsTransformEnabled() /Deprecated/;

//! sets source spatial reference system (by QGIS CRS)
void setSourceCrs(long srsid);
@@ -46,7 +46,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
{
mDa.setSourceCrs( mCrs.srsid() );
mDa.setEllipsoid( ellipsoidID );
mDa.setProjectionsEnabled( ctfEnabled );
mDa.setEllipsoidalEnabled( ctfEnabled );
}

//! Destructor
@@ -245,7 +245,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
QgsDistanceArea calc;
if ( !featureList.count() == 0 )
{
calc.setProjectionsEnabled( mCanvas->hasCrsTransformEnabled() ); // project?
calc.setEllipsoidalEnabled( mCanvas->hasCrsTransformEnabled() ); // project?
calc.setEllipsoid( ellipsoid );
calc.setSourceCrs( layer->crs().srsid() );
}
@@ -183,7 +183,7 @@ void QgsMapToolMeasureAngle::configureDistanceArea()
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
mDa.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
mDa.setEllipsoidalEnabled( mResultDisplay->projectionEnabled() );
}


@@ -365,5 +365,5 @@ void QgsMeasureDialog::configureDistanceArea()
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
mDa.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mcbProjectionEnabled->isChecked() );
mDa.setEllipsoidalEnabled( mcbProjectionEnabled->isChecked() );
}
@@ -188,7 +188,7 @@ double QgsComposerScaleBar::mapDiagonal() const
else
{
QgsDistanceArea da;
da.setProjectionsEnabled( true );
da.setEllipsoidalEnabled( true );
da.setSourceCrs( mComposerMap->mapRenderer()->destinationCrs().srsid() );
QSettings s;
da.setEllipsoid( s.value( "/qgis/measure/ellipsoid", "WGS84" ).toString() );
@@ -41,7 +41,7 @@
QgsDistanceArea::QgsDistanceArea()
{
// init with default settings
mProjectionsEnabled = false;
mEllipsoidalEnabled = false;
mCoordTransform = new QgsCoordinateTransform;
setSourceCrs( GEOCRS_ID ); // WGS 84
setEllipsoid( "WGS84" );
@@ -53,10 +53,9 @@ QgsDistanceArea::~QgsDistanceArea()
delete mCoordTransform;
}


void QgsDistanceArea::setProjectionsEnabled( bool flag )
void QgsDistanceArea::setEllipsoidalEnabled( bool flag )
{
mProjectionsEnabled = flag;
mEllipsoidalEnabled = flag;
}

void QgsDistanceArea::setSourceCrs( long srsid )
@@ -338,14 +337,14 @@ double QgsDistanceArea::measureLine( const QList<QgsPoint>& points )

try
{
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
p1 = mCoordTransform->transform( points[0] );
else
p1 = points[0];

for ( QList<QgsPoint>::const_iterator i = points.begin(); i != points.end(); ++i )
{
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
{
p2 = mCoordTransform->transform( *i );
total += computeDistanceBearing( p1, p2 );
@@ -379,7 +378,7 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
QgsPoint pp1 = p1, pp2 = p2;

QgsDebugMsg( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ) );
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
{
QgsDebugMsg( QString( "Ellipsoidal calculations is enabled, using ellipsoid %1" ).arg( mEllipsoid ) );
QgsDebugMsg( QString( "From proj4 : %1" ).arg( mCoordTransform->sourceCrs().toProj4() ) );
@@ -448,7 +447,7 @@ unsigned char* QgsDistanceArea::measurePolygon( unsigned char* feature, double*

pnt = QgsPoint( x, y );

if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
{
pnt = mCoordTransform->transform( pnt );
}
@@ -500,7 +499,7 @@ double QgsDistanceArea::measurePolygon( const QList<QgsPoint>& points )

try
{
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
{
QList<QgsPoint> pts;
for ( QList<QgsPoint>::const_iterator i = points.begin(); i != points.end(); ++i )
@@ -528,7 +527,7 @@ double QgsDistanceArea::bearing( const QgsPoint& p1, const QgsPoint& p2 )
QgsPoint pp1 = p1, pp2 = p2;
double bearing;

if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
if ( mEllipsoidalEnabled && ( mEllipsoid != "NONE" ) )
{
pp1 = mCoordTransform->transform( p1 );
pp2 = mCoordTransform->transform( p2 );
@@ -690,7 +689,7 @@ double QgsDistanceArea::computePolygonArea( const QList<QgsPoint>& points )
double area;

QgsDebugMsgLevel( "Ellipsoid: " + mEllipsoid, 3 );
if (( ! mProjectionsEnabled ) || ( mEllipsoid == "NONE" ) )
if (( ! mEllipsoidalEnabled ) || ( mEllipsoid == "NONE" ) )
{
return computePolygonFlatArea( points );
}
@@ -41,10 +41,12 @@ class CORE_EXPORT QgsDistanceArea
~QgsDistanceArea();

//! sets whether coordinates must be projected to ellipsoid before measuring
void setProjectionsEnabled( bool flag );
void setEllipsoidalEnabled( bool flag );
Q_DECL_DEPRECATED void QgsDistanceArea::setProjectionsEnabled( bool flag ) { setEllipsoidalEnabled( flag ); };

//! returns projections enabled flag
bool hasCrsTransformEnabled() { return mProjectionsEnabled; }
bool ellipsoidalEnabled() { return mEllipsoidalEnabled; }
Q_DECL_DEPRECATED bool hasCrsTransformEnabled() { return mEllipsoidalEnabled; }

//! sets source spatial reference system (by QGIS CRS)
void setSourceCrs( long srsid );
@@ -134,7 +136,7 @@ class CORE_EXPORT QgsDistanceArea
QgsCoordinateTransform* mCoordTransform;

//! indicates whether we will transform coordinates
bool mProjectionsEnabled;
bool mEllipsoidalEnabled;

//! id of the source spatial reference system
long mSourceRefSys;
@@ -913,7 +913,7 @@ bool QgsExpression::needsGeometry()
void QgsExpression::initGeomCalculator()
{
mCalc = new QgsDistanceArea;
mCalc->setProjectionsEnabled( false );
mCalc->setEllipsoidalEnabled( false );
QSettings settings;
QString ellipsoid = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
mCalc->setEllipsoid( ellipsoid );
@@ -664,7 +664,7 @@ void QgsMapRenderer::setProjectionsEnabled( bool enabled )
{
mProjectionsEnabled = enabled;
QgsDebugMsg( "Adjusting DistArea projection on/off" );
mDistArea->setProjectionsEnabled( enabled );
mDistArea->setEllipsoidalEnabled( enabled );
updateFullExtent();
mLastExtent.setMinimal();
emit hasCrsTransformEnabled( enabled );
@@ -307,7 +307,7 @@ float Heatmap::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs )
da.setEllipsoid( layerCrs.ellipsoidAcronym() );
if ( da.geographic() )
{
da.setProjectionsEnabled( true );
da.setEllipsoidalEnabled( true );
}
return meters / da.measureLine( QgsPoint( 0.0, 0.0 ), QgsPoint( 0.0, 1.0 ) );
}
@@ -336,7 +336,7 @@ float HeatmapGui::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCr
da.setEllipsoid( layerCrs.ellipsoidAcronym() );
if ( da.geographic() )
{
da.setProjectionsEnabled( true );
da.setEllipsoidalEnabled( true );
}
double unitDistance = da.measureLine( QgsPoint( 0.0, 0.0 ), QgsPoint( 0.0, 1.0 ) );
QgsDebugMsg( QString( "Converted %1 meters to %2 mapunits" ).arg( meters ).arg( meters / unitDistance ) );

0 comments on commit e455264

Please sign in to comment.
You can’t perform that action at this time.