Skip to content

Commit

Permalink
Renamed accessor/mutator and deprecated old names
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Aug 23, 2012
1 parent dd4de85 commit e455264
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 24 deletions.
4 changes: 3 additions & 1 deletion python/core/qgsdistancearea.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgsgraphbuilderintr.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
{
mDa.setSourceCrs( mCrs.srsid() );
mDa.setEllipsoid( ellipsoidID );
mDa.setProjectionsEnabled( ctfEnabled );
mDa.setEllipsoidalEnabled( ctfEnabled );
}

//! Destructor
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmeasureangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}


Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmeasuredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
21 changes: 10 additions & 11 deletions src/core/qgsdistancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
QgsDistanceArea::QgsDistanceArea()
{
// init with default settings
mProjectionsEnabled = false;
mEllipsoidalEnabled = false;
mCoordTransform = new QgsCoordinateTransform;
setSourceCrs( GEOCRS_ID ); // WGS 84
setEllipsoid( "WGS84" );
Expand All @@ -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 )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down
8 changes: 5 additions & 3 deletions src/core/qgsdistancearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/heatmap/heatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/heatmap/heatmapgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down

0 comments on commit e455264

Please sign in to comment.