Skip to content

Commit

Permalink
api cleanups for distance area
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9504 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 20, 2008
1 parent b6761a8 commit 5aeb250
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 67 deletions.
4 changes: 2 additions & 2 deletions python/core/qgscoordinatetransform.sip
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class QgsCoordinateTransform : QObject
* Set the source (layer) QgsCoordinateReferenceSystem
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
*/
void setSourceCRS(const QgsCoordinateReferenceSystem& theCRS);
void setSourceCrs(const QgsCoordinateReferenceSystem& theCRS);

/*!
* Mutator for dest QgsCoordinateReferenceSystem
Expand All @@ -76,7 +76,7 @@ class QgsCoordinateTransform : QObject
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
*/
QgsCoordinateReferenceSystem& sourceCRS();
QgsCoordinateReferenceSystem& sourceCrs();

/*!
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
Expand Down
10 changes: 5 additions & 5 deletions python/core/qgsdistancearea.sip
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class QgsDistanceArea
void setProjectionsEnabled(bool flag);

//! returns projections enabled flag
bool projectionsEnabled();
bool hasCrsTransformEnabled();

//! sets source spatial reference system (by QGIS CRS)
void setSourceCRS(long srsid);
void setSourceCrs(long srsid);

//! sets source spatial reference system (by EpsgCrsId)
void setSourceEpsgCrsId(long epsgId);

//! returns source spatial reference system
long sourceCRS();
long sourceCrs();
//! What sort of coordinate system is being used?
bool geographic();

Expand All @@ -41,7 +41,7 @@ class QgsDistanceArea
//! returns ellipsoid's semi minor axis
double ellipsoidSemiMinor();
//! returns ellipsoid's inverse flattening
double ellipsoidInvFlattening();
double ellipsoidInverseFlattening();

//! general measurement (line distance or polygon area)
double measure(QgsGeometry* geometry);
Expand All @@ -56,7 +56,7 @@ class QgsDistanceArea
double measurePolygon(const QList<QgsPoint>& points);

//! compute bearing - in radians
double getBearing(const QgsPoint& p1, const QgsPoint& p2);
double bearing(const QgsPoint& p1, const QgsPoint& p2);

static QString textUnit(double value, int decimals, QGis::UnitType u, bool isArea);

Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsmaprenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class QgsMapRenderer : QObject
void setProjectionsEnabled(bool enabled);

//! returns true if projections are enabled for this layer set
bool projectionsEnabled();
bool hasCrsTransformEnabled();

//! sets destination spatial reference system
void setDestinationSrs(const QgsCoordinateReferenceSystem& srs);
Expand Down Expand Up @@ -99,7 +99,7 @@ class QgsMapRenderer : QObject

void setProgress(int current, int total);

void projectionsEnabled(bool flag);
void hasCrsTransformEnabled(bool flag);

void destinationSrsChanged();

Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmapcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class QgsMapCanvas : QGraphicsView
bool renderFlag();

/** A simple helper method to find out if on the fly projections are enabled or not */
bool projectionsEnabled();
bool hasCrsTransformEnabled();

/** The map units may have changed, so cope with that */
void mapUnitsChanged();
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmapoverviewcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QgsMapOverviewCanvas : QWidget

public slots:

void projectionsEnabled(bool flag);
void hasCrsTransformEnabled(bool flag);

void destinationSrsChanged();

Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegendlayerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void QgsLegendLayerFile::saveAsShapefileGeneral( bool saveOnlySelection )

destCRS = vlayer->srs();
// Find out if we have projections enabled or not
if ( QgisApp::instance()->mapCanvas()->mapRenderer()->projectionsEnabled() )
if ( QgisApp::instance()->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() )
{
destCRS = QgisApp::instance()->mapCanvas()->mapRenderer()->destinationSrs();
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ void QgisApp::setupConnections()
//signal when mouse moved over window (coords display in status bar)
connect( mMapCanvas, SIGNAL( xyCoordinates( QgsPoint & ) ), this, SLOT( showMouseCoordinate( QgsPoint & ) ) );
connect( mMapCanvas->mapRenderer(), SIGNAL( drawingProgress( int, int ) ), this, SLOT( showProgress( int, int ) ) );
connect( mMapCanvas->mapRenderer(), SIGNAL( projectionsEnabled( bool ) ), this, SLOT( projectionsEnabled( bool ) ) );
connect( mMapCanvas->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( hasCrsTransformEnabled( bool ) ) );
connect( mMapCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( destinationSrsChanged() ) );
connect( mMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( showExtents() ) );
connect( mMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( showScale( double ) ) );
Expand Down Expand Up @@ -4811,7 +4811,7 @@ void QgisApp::destinationSrsChanged()

}

void QgisApp::projectionsEnabled( bool theFlag )
void QgisApp::hasCrsTransformEnabled( bool theFlag )
{
// save this information to project
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectionsEnabled", ( theFlag ? 1 : 0 ) );
Expand Down Expand Up @@ -4996,14 +4996,14 @@ void QgisApp::projectProperties()
//connect (pp,SIGNAL(refresh()), mMapCanvas, SLOT(refresh()));

QgsMapRenderer* myRender = mMapCanvas->mapRenderer();
bool wasProjected = myRender->projectionsEnabled();
bool wasProjected = myRender->hasCrsTransformEnabled();
long oldCRSID = myRender->destinationSrs().srsid();

// Display the modal dialog box.
pp->exec();

long newCRSID = myRender->destinationSrs().srsid();
bool isProjected = myRender->projectionsEnabled();
bool isProjected = myRender->hasCrsTransformEnabled();

// projections have been turned on/off or dest CRS has changed while projections are on
if ( wasProjected != isProjected || ( isProjected && oldCRSID != newCRSID ) )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class QgisApp : public QMainWindow
void showExtents();
void showStatusMessage( QString theMessage );
void updateMouseCoordinatePrecision();
void projectionsEnabled( bool theFlag );
void hasCrsTransformEnabled( bool theFlag );
void destinationSrsChanged();
// void debugHook();
//! Add a vector layer to the map
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ void QgsMapToolIdentify::identifyVectorLayer( const QgsPoint& point )

// init distance/area calculator
QgsDistanceArea calc;
calc.setProjectionsEnabled( mCanvas->projectionsEnabled() ); // project?
calc.setProjectionsEnabled( mCanvas->hasCrsTransformEnabled() ); // project?
calc.setEllipsoid( ellipsoid );
calc.setSourceCRS( layer->srs().srsid() );
calc.setSourceCrs( layer->srs().srsid() );

mFeatureList.clear();
QApplication::setOverrideCursor( Qt::WaitCursor );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmeasuretool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ void QgsMeasureTool::updateProjection()

// set source CRS and projections enabled flag
// QgsMapRenderer* mapRender = mCanvas->mapRenderer();
// mCalc->setProjectionsEnabled(mapRender->projectionsEnabled());
// mCalc->setProjectionsEnabled(mapRender->hasCrsTransformEnabled());
// int srsid = mapRender->destinationSrs().srsid();
// mCalc->setSourceCRS(srsid);
// mCalc->setSourceCrs(srsid);

int myRed = settings.value( "/qgis/default_measure_color_red", 180 ).toInt();
int myGreen = settings.value( "/qgis/default_measure_color_green", 180 ).toInt();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsprojectproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
setMapUnits( myUnit );

//see if the user wants on the fly projection enabled
bool myProjectionEnabled = myRender->projectionsEnabled();
bool myProjectionEnabled = myRender->hasCrsTransformEnabled();
cbxProjectionEnabled->setChecked( myProjectionEnabled );

long myCRSID = myRender->destinationSrs().srsid();
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
theMapRenderer.setExtent( extent );
theMapRenderer.setOutputSize( size, dpi );
theMapRenderer.setLayerSet( mMapRenderer->layerSet() );
theMapRenderer.setProjectionsEnabled( mMapRenderer->projectionsEnabled() );
theMapRenderer.setProjectionsEnabled( mMapRenderer->hasCrsTransformEnabled() );
theMapRenderer.setDestinationSrs( mMapRenderer->destinationSrs() );

QgsRenderContext* theRendererContext = theMapRenderer.rendererContext();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatetransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ QgsCoordinateTransform::~QgsCoordinateTransform()
}
}

void QgsCoordinateTransform::setSourceCRS( const QgsCoordinateReferenceSystem& theCRS )
void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& theCRS )
{
mSourceCRS = theCRS;
initialise();
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgscoordinatetransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject
* Set the source (layer) QgsCoordinateReferenceSystem
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
*/
void setSourceCRS( const QgsCoordinateReferenceSystem& theCRS );
void setSourceCrs( const QgsCoordinateReferenceSystem& theCRS );

/*!
* Mutator for dest QgsCoordinateReferenceSystem
Expand All @@ -111,7 +111,7 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
*/
QgsCoordinateReferenceSystem& sourceCRS() { return mSourceCRS; }
QgsCoordinateReferenceSystem& sourceCrs() { return mSourceCRS; }

/*!
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
Expand Down Expand Up @@ -289,9 +289,9 @@ inline std::ostream& operator << ( std::ostream& os, const QgsCoordinateTransfor
}
mySummary += "\n\tSource Spatial Ref Sys : ";
if (r.sourceCRS())
if (r.sourceCrs())
{
mySummary << r.sourceCRS();
mySummary << r.sourceCrs();
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsdistancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ void QgsDistanceArea::setProjectionsEnabled( bool flag )
mProjectionsEnabled = flag;
}

void QgsDistanceArea::setSourceCRS( long srsid )
void QgsDistanceArea::setSourceCrs( long srsid )
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromSrsId( srsid );
mCoordTransform->setSourceCRS( srcCRS );
mCoordTransform->setSourceCrs( srcCRS );
}

void QgsDistanceArea::setSourceEpsgCrsId( long epsgId )
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromEpsg( epsgId );
mCoordTransform->setSourceCRS( srcCRS );
mCoordTransform->setSourceCrs( srcCRS );
}


Expand Down Expand Up @@ -404,7 +404,7 @@ double QgsDistanceArea::measurePolygon( const QList<QgsPoint>& points )
}


double QgsDistanceArea::getBearing( const QgsPoint& p1, const QgsPoint& p2 )
double QgsDistanceArea::bearing( const QgsPoint& p1, const QgsPoint& p2 )
{
QgsPoint pp1 = p1, pp2 = p2;
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsdistancearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ class CORE_EXPORT QgsDistanceArea
void setProjectionsEnabled( bool flag );

//! returns projections enabled flag
bool projectionsEnabled() { return mProjectionsEnabled; }
bool hasCrsTransformEnabled() { return mProjectionsEnabled; }

//! sets source spatial reference system (by QGIS CRS)
void setSourceCRS( long srsid );
void setSourceCrs( long srsid );

//! sets source spatial reference system (by EpsgCrsId)
void setSourceEpsgCrsId( long epsgId );

//! returns source spatial reference system
long sourceCRS() { return mSourceRefSys; }
long sourceCrs() { return mSourceRefSys; }
//! What sort of coordinate system is being used?
bool geographic() { return mCoordTransform->sourceCRS().geographicFlag(); }
bool geographic() { return mCoordTransform->sourceCrs().geographicFlag(); }

//! sets ellipsoid by its acronym
bool setEllipsoid( const QString& ellipsoid );
Expand All @@ -69,7 +69,7 @@ class CORE_EXPORT QgsDistanceArea
//! returns ellipsoid's semi minor axis
double ellipsoidSemiMinor() { return mSemiMinor; }
//! returns ellipsoid's inverse flattening
double ellipsoidInvFlattening() { return mInvFlattening; }
double ellipsoidInverseFlattening() { return mInvFlattening; }

//! general measurement (line distance or polygon area)
double measure( QgsGeometry* geometry );
Expand All @@ -83,7 +83,7 @@ class CORE_EXPORT QgsDistanceArea
double measurePolygon( const QList<QgsPoint>& points );

//! compute bearing - in radians
double getBearing( const QgsPoint& p1, const QgsPoint& p2 );
double bearing( const QgsPoint& p1, const QgsPoint& p2 );

static QString textUnit( double value, int decimals, QGis::UnitType u, bool isArea );

Expand Down
Loading

0 comments on commit 5aeb250

Please sign in to comment.