Skip to content
Permalink
Browse files
api cleanups for distance area
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 5aeb2500062aa08923faeb2ac94362d733429b28
@@ -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
@@ -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
@@ -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();

@@ -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);
@@ -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);

@@ -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);
@@ -99,7 +99,7 @@ class QgsMapRenderer : QObject

void setProgress(int current, int total);

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

void destinationSrsChanged();

@@ -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();
@@ -30,7 +30,7 @@ class QgsMapOverviewCanvas : QWidget

public slots:

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

void destinationSrsChanged();

@@ -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();
}
@@ -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 ) ) );
@@ -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 ) );
@@ -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 ) )
@@ -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
@@ -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 );
@@ -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();
@@ -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();
@@ -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();
@@ -99,7 +99,7 @@ QgsCoordinateTransform::~QgsCoordinateTransform()
}
}

void QgsCoordinateTransform::setSourceCRS( const QgsCoordinateReferenceSystem& theCRS )
void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& theCRS )
{
mSourceCRS = theCRS;
initialise();
@@ -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
@@ -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
@@ -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
{
@@ -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 );
}


@@ -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" ) )
@@ -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 );
@@ -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 );
@@ -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 );

Loading

0 comments on commit 5aeb250

Please sign in to comment.