Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename some QgsCoordinateReferenceSystem methods
- geographicFlag() -> isGeographic()
- axisInverted() -> hasAxisInverted()
  • Loading branch information
nyalldawson committed Jul 25, 2016
1 parent 2b8b979 commit ee62bde
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 66 deletions.
2 changes: 2 additions & 0 deletions doc/api_break.dox
Expand Up @@ -106,6 +106,8 @@ qgsPermissiveToInt()</li>
<li>setCustomSrsValidation() has been renamed to setCustomCrsValidation()</li>
<li>saveAsUserCRS() has been renamed to saveAsUserCrs()</li>
<li>geographicCRSAuthId() has been renamed to geographicCrsAuthId()</li>
<li>geographicFlag() was renamed to isGeographic()</li>
<li>axisInverted() was renamed to hasAxisInverted()</li>
</ul>

\subsection qgis_api_break_3_0_QgsCoordinateTransform QgsCoordinateTransform
Expand Down
5 changes: 2 additions & 3 deletions python/core/qgscoordinatereferencesystem.sip
Expand Up @@ -436,13 +436,12 @@ class QgsCoordinateReferenceSystem
/** Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
* @returns true if CRS is geographic, or false if it is a projected CRS
*/
//TODO QGIS 3.0 - rename to isGeographic
bool geographicFlag() const;
bool isGeographic() const;

/** Returns whether axis is inverted (eg. for WMS 1.3) for the CRS.
* @returns true if CRS axis is inverted
*/
bool axisInverted() const;
bool hasAxisInverted() const;

/** Returns the units for the projection used by the CRS.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationnortharrow.cpp
Expand Up @@ -228,7 +228,7 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
{
QgsCoordinateReferenceSystem outputCRS = mapCanvas->mapSettings().destinationCrs();

if ( outputCRS.isValid() && !outputCRS.geographicFlag() )
if ( outputCRS.isValid() && !outputCRS.isGeographic() )
{
// Use a geographic CRS to get lat/long to work out direction
QgsCoordinateReferenceSystem ourCRS = QgsCrsCache::instance()->crsByOgcWmsCrs( GEO_EPSG_CRS_AUTHID );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmeasuretool.cpp
Expand Up @@ -81,7 +81,7 @@ void QgsMeasureTool::activate()

// If we suspect that they have data that is projected, yet the
// map CRS is set to a geographic one, warn them.
if ( mCanvas->mapSettings().destinationCrs().geographicFlag() &&
if ( mCanvas->mapSettings().destinationCrs().isGeographic() &&
( mCanvas->extent().height() > 360 ||
mCanvas->extent().width() > 720 ) )
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposermapgrid.cpp
Expand Up @@ -1442,13 +1442,13 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
{
//check if we are using degrees (ie, geographic crs)
bool geographic = false;
if ( mCRS.isValid() && mCRS.geographicFlag() )
if ( mCRS.isValid() && mCRS.isGeographic() )
{
geographic = true;
}
else if ( mComposerMap && mComposerMap->composition() )
{
geographic = mComposerMap->composition()->mapSettings().destinationCrs().geographicFlag();
geographic = mComposerMap->composition()->mapSettings().destinationCrs().isGeographic();
}

if ( geographic && coord == QgsComposerMapGrid::Longitude &&
Expand Down Expand Up @@ -1744,7 +1744,7 @@ int QgsComposerMapGrid::xGridLinesCrsTransform( const QgsRectangle& bbox, const

bool crosses180 = false;
bool crossed180 = false;
if ( mCRS.geographicFlag() && ( minX > maxX ) )
if ( mCRS.isGeographic() && ( minX > maxX ) )
{
//handle 180 degree longitude crossover
crosses180 = true;
Expand Down Expand Up @@ -1823,7 +1823,7 @@ int QgsComposerMapGrid::yGridLinesCrsTransform( const QgsRectangle& bbox, const

bool crosses180 = false;
bool crossed180 = false;
if ( mCRS.geographicFlag() && ( bbox.xMinimum() > bbox.xMaximum() ) )
if ( mCRS.isGeographic() && ( bbox.xMinimum() > bbox.xMaximum() ) )
{
//handle 180 degree longitude crossover
crosses180 = true;
Expand Down Expand Up @@ -2379,7 +2379,7 @@ int QgsComposerMapGrid::crsGridParams( QgsRectangle& crsRect, QgsCoordinateTrans
QgsRectangle mapBoundingRect( mbr.left(), mbr.bottom(), mbr.right(), mbr.top() );


if ( mCRS.geographicFlag() )
if ( mCRS.isGeographic() )
{
//handle crossing the 180 degree longitude line
QgsPoint lowerLeft( mapBoundingRect.xMinimum(), mapBoundingRect.yMinimum() );
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -365,7 +365,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( const QString& db, const QString&
return d->mIsValid;
}

bool QgsCoordinateReferenceSystem::axisInverted() const
bool QgsCoordinateReferenceSystem::hasAxisInverted() const
{
if ( d->mAxisInverted == -1 )
{
Expand Down Expand Up @@ -847,7 +847,7 @@ QString QgsCoordinateReferenceSystem::toProj4() const
return d->mProj4.trimmed();
}

bool QgsCoordinateReferenceSystem::geographicFlag() const
bool QgsCoordinateReferenceSystem::isGeographic() const
{
return d->mIsGeographic;
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ bool QgsCoordinateReferenceSystem::writeXml( QDomNode & theNode, QDomDocument &

QDomElement myGeographicFlagElement = theDoc.createElement( "geographicflag" );
QString myGeoFlagText = "false";
if ( geographicFlag() )
if ( isGeographic() )
{
myGeoFlagText = "true";
}
Expand Down Expand Up @@ -2127,7 +2127,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )

QString QgsCoordinateReferenceSystem::geographicCrsAuthId() const
{
if ( geographicFlag() )
if ( isGeographic() )
{
return d->mAuthId;
}
Expand Down
5 changes: 2 additions & 3 deletions src/core/qgscoordinatereferencesystem.h
Expand Up @@ -483,13 +483,12 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
/** Returns whether the CRS is a geographic CRS (using lat/lon coordinates)
* @returns true if CRS is geographic, or false if it is a projected CRS
*/
//TODO QGIS 3.0 - rename to isGeographic
bool geographicFlag() const;
bool isGeographic() const;

/** Returns whether axis is inverted (eg. for WMS 1.3) for the CRS.
* @returns true if CRS axis is inverted
*/
bool axisInverted() const;
bool hasAxisInverted() const;

/** Returns the units for the projection used by the CRS.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinateutils.cpp
Expand Up @@ -39,7 +39,7 @@ int QgsCoordinateUtils::calculateCoordinatePrecision( double mapUnitsPerPixel, c
// - both map CRS and format are geographic
// - both map CRS and format are not geographic
// - map CRS is geographic but format is not geographic (i.e. map units)
if ( mapCrs.geographicFlag() || !formatGeographic )
if ( mapCrs.isGeographic() || !formatGeographic )
{
// Work out a suitable number of decimal places for the coordinates with the aim of always
// having enough decimal places to show the difference in position between adjacent pixels.
Expand Down Expand Up @@ -70,7 +70,7 @@ QString QgsCoordinateUtils::formatCoordinateForProject( const QgsPoint& point, c
if ( format == "DM" || format == "DMS" || format == "D" )
{
// degrees
if ( destCrs.isValid() && !destCrs.geographicFlag() )
if ( destCrs.isValid() && !destCrs.isGeographic() )
{
// need to transform to geographic coordinates
QgsCoordinateTransform ct( destCrs, QgsCoordinateReferenceSystem( GEOSRID ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdistancearea.h
Expand Up @@ -96,7 +96,7 @@ class CORE_EXPORT QgsDistanceArea
long sourceCrsId() const { return mCoordTransform.sourceCrs().srsid(); }

//! What sort of coordinate system is being used?
bool geographic() const { return mCoordTransform.sourceCrs().geographicFlag(); }
bool geographic() const { return mCoordTransform.sourceCrs().isGeographic(); }

/** Sets ellipsoid by its acronym. Calculations will only use the ellipsoid if
* both the ellipsoid has been set and ellipsoidalEnabled() is true.
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgml.cpp
Expand Up @@ -1209,7 +1209,7 @@ int QgsGmlStreamingParser::readEpsgFromAttribute( int& epsgNr, const XML_Char**
if ( crs.isValid() )
{
if ((( mAxisOrientationLogic == Honour_EPSG_if_urn && bIsUrn ) ||
mAxisOrientationLogic == Honour_EPSG ) && crs.axisInverted() )
mAxisOrientationLogic == Honour_EPSG ) && crs.hasAxisInverted() )
{
mInvertAxisOrientation = !mInvertAxisOrientationRequest;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsmaprendererjob.cpp
Expand Up @@ -81,9 +81,9 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
// extent separately.
static const double splitCoord = 180.0;

if ( ml->crs().geographicFlag() )
if ( ml->crs().isGeographic() )
{
if ( ml->type() == QgsMapLayer::VectorLayer && !ct.destinationCrs().geographicFlag() )
if ( ml->type() == QgsMapLayer::VectorLayer && !ct.destinationCrs().isGeographic() )
{
// if we transform from a projected coordinate system check
// check if transforming back roughly returns the input
Expand Down Expand Up @@ -144,7 +144,7 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
}
else // can't cross 180
{
if ( ct.destinationCrs().geographicFlag() &&
if ( ct.destinationCrs().isGeographic() &&
( extent.xMinimum() <= -180 || extent.xMaximum() >= 180 ||
extent.yMinimum() <= -90 || extent.yMaximum() >= 90 ) )
// Use unlimited rectangle because otherwise we may end up transforming wrong coordinates.
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsogcutils.cpp
Expand Up @@ -62,7 +62,7 @@ QgsOgcUtilsExprToFilter::QgsOgcUtilsExprToFilter( QDomDocument& doc,
crs = QgsCrsCache::instance()->crsByOgcWmsCrs( mSrsName );
if ( crs.isValid() )
{
if ( honourAxisOrientation && crs.axisInverted() )
if ( honourAxisOrientation && crs.hasAxisInverted() )
{
mInvertAxisOrientation = !mInvertAxisOrientation;
}
Expand Down Expand Up @@ -2893,7 +2893,7 @@ bool QgsOgcUtilsSQLStatementToFilter::processSRSName( const QgsSQLStatement::Nod
crs = QgsCrsCache::instance()->crsByOgcWmsCrs( srsName );
if ( crs.isValid() )
{
if ( mHonourAxisOrientation && crs.axisInverted() )
if ( mHonourAxisOrientation && crs.hasAxisInverted() )
{
axisInversion = !axisInversion;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -2638,7 +2638,7 @@ void QgsVectorLayer::snapToGeometry( const QgsPoint& startPoint,
{
if ( geometryType() != Qgis::Point ) // cannot snap to segment for points/multipoints
{
sqrDistSegmentSnap = geom->closestSegmentWithContext( startPoint, snappedPoint, afterVertex, nullptr, crs().geographicFlag() ? 1e-12 : 1e-8 );
sqrDistSegmentSnap = geom->closestSegmentWithContext( startPoint, snappedPoint, afterVertex, nullptr, crs().isGeographic() ? 1e-12 : 1e-8 );

if ( sqrDistSegmentSnap < sqrSnappingTolerance )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -344,7 +344,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList<QgsPoint>& splitLine, bo
{
//If we have a single point, we still create a non-null box
double bufferDistance = 0.000001;
if ( L->crs().geographicFlag() )
if ( L->crs().isGeographic() )
bufferDistance = 0.00000001;
bBox.setXMinimum( bBox.xMinimum() - bufferDistance );
bBox.setXMaximum( bBox.xMaximum() + bufferDistance );
Expand Down Expand Up @@ -478,7 +478,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList<QgsPoint>& splitLine, bool
{
//If we have a single point, we still create a non-null box
double bufferDistance = 0.000001;
if ( L->crs().geographicFlag() )
if ( L->crs().isGeographic() )
bufferDistance = 0.00000001;
bBox.setXMinimum( bBox.xMinimum() - bufferDistance );
bBox.setXMaximum( bBox.xMaximum() + bufferDistance );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerrenderer.cpp
Expand Up @@ -187,7 +187,7 @@ bool QgsVectorLayerRenderer::render()
try
{
QgsPoint center = mContext.extent().center();
double rectSize = ct.sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
double rectSize = ct.sourceCrs().isGeographic() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;

QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
QgsRectangle targetRect = ct.transform( sourceRect );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -1169,7 +1169,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent* e )

void QgsAdvancedDigitizingDockWidget::enable()
{
if ( mMapCanvas->mapSettings().destinationCrs().geographicFlag() )
if ( mMapCanvas->mapSettings().destinationCrs().isGeographic() )
{
mErrorLabel->setText( tr( "CAD tools can not be used on geographic coordinates. Change the coordinates system in the project properties." ) );
mErrorLabel->show();
Expand Down
10 changes: 5 additions & 5 deletions src/providers/grass/qgsgrassgislib.cpp
Expand Up @@ -1071,7 +1071,7 @@ double QgsGrassGisLib::G_area_of_cell_at_row( int row )
QgsGeometry* geo = QgsGeometry::fromRect( rect );
double area = mDistanceArea.measure( geo );
delete geo;
if ( !mCrs.geographicFlag() )
if ( !mCrs.isGeographic() )
{
area *= qPow( G_database_units_to_meters_factor(), 2 );
}
Expand All @@ -1095,7 +1095,7 @@ double QgsGrassGisLib::G_area_of_polygon( const double *x, const double *y, int
QgsGeometry* geo = QgsGeometry::fromPolygon( polygon );
double area = mDistanceArea.measure( geo );
delete geo;
if ( !mCrs.geographicFlag() )
if ( !mCrs.isGeographic() )
{
area *= qPow( G_database_units_to_meters_factor(), 2 );
}
Expand All @@ -1115,7 +1115,7 @@ double GRASS_LIB_EXPORT G_database_units_to_meters_factor( void )
int QgsGrassGisLib::beginCalculations( void )
{
if ( !mCrs.isValid() ) return 0;
if ( !mCrs.geographicFlag() ) return 1; // planimetric
if ( !mCrs.isGeographic() ) return 1; // planimetric
return 2; // non-planimetric
}

Expand Down Expand Up @@ -1147,7 +1147,7 @@ double QgsGrassGisLib::distance( double e1, double n1, double e2, double n2 )
// QgsDistanceArea states that results are in meters, but it does not
// seem to be true,
double dist = mDistanceArea.measureLine( QgsPoint( e1, n1 ), QgsPoint( e2, n2 ) );
if ( !mCrs.geographicFlag() )
if ( !mCrs.isGeographic() )
{
dist *= G_database_units_to_meters_factor();
}
Expand Down Expand Up @@ -1199,7 +1199,7 @@ double QgsGrassGisLib::G_geodesic_distance_lon_to_lon( double lon1, double lon2
{
double dist = mDistanceArea.measureLine( QgsPoint( lon1, mLat1 ), QgsPoint( lon2, mLat2 ) );
// TODO: not sure about this
if ( !mCrs.geographicFlag() )
if ( !mCrs.isGeographic() )
{
dist *= G_database_units_to_meters_factor();
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -2437,7 +2437,7 @@ bool QgsOracleProvider::createSpatialIndex()

QSqlQuery qry( *mConnection );

if ( !crs().geographicFlag() )
if ( !crs().isGeographic() )
{
// TODO: make precision configurable
QgsRectangle r( extent() );
Expand Down Expand Up @@ -2721,7 +2721,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(

// TODO: make precision configurable
QString diminfo;
if ( srs->geographicFlag() )
if ( srs->isGeographic() )
{
diminfo = "mdsys.sdo_dim_array("
"mdsys.sdo_dim_element('Longitude', -180, 180, 0.001),"
Expand Down Expand Up @@ -2784,7 +2784,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(
" VALUES (%1,%2,%3,%4,'TRUE','TRUE','GDAL/OGR via QGIS')" )
.arg( srid )
.arg( quotedValue( srs->description() ) )
.arg( quotedValue( srs->geographicFlag() ? "GEOGRAPHIC2D" : "PROJECTED" ) )
.arg( quotedValue( srs->isGeographic() ? "GEOGRAPHIC2D" : "PROJECTED" ) )
.arg( quotedValue( wkt ) ) ) )
{
throw OracleException( tr( "CRS not found and could not be created." ), qry );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wcs/qgswcscapabilities.cpp
Expand Up @@ -956,7 +956,7 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW
{
QgsRectangle box;
QgsCoordinateReferenceSystem crs = QgsCrsCache::instance()->crsByOgcWmsCrs( authid );
if ( crs.isValid() && crs.axisInverted() )
if ( crs.isValid() && crs.hasAxisInverted() )
{
box = QgsRectangle( low[1], low[0], high[1], high[0] );
}
Expand All @@ -965,7 +965,7 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW
box = QgsRectangle( low[0], low[1], high[0], high[1] );
}
coverage->boundingBoxes.insert( authid, box );
QgsDebugMsg( "crs: " + crs.authid() + ' ' + crs.description() + QString( " axisInverted = %1" ).arg( crs.axisInverted() ) );
QgsDebugMsg( "crs: " + crs.authid() + ' ' + crs.description() + QString( " axisInverted = %1" ).arg( crs.hasAxisInverted() ) );
QgsDebugMsg( "BoundingBox: " + authid + " : " + box.toString() );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -643,7 +643,7 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const & viewExtent, int
{
//create CRS from string
QgsCoordinateReferenceSystem theSrs = QgsCrsCache::instance()->crsByOgcWmsCrs( crs );
if ( theSrs.isValid() && theSrs.axisInverted() )
if ( theSrs.isValid() && theSrs.hasAxisInverted() )
{
changeXY = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfscapabilities.cpp
Expand Up @@ -333,7 +333,7 @@ void QgsWfsCapabilities::capabilitiesReplyFinished()
featureType.bbox.xMaximum() <= 180 && featureType.bbox.yMaximum() < 90 )
{
QgsCoordinateReferenceSystem crs = QgsCrsCache::instance()->crsByOgcWmsCrs( featureType.crslist[0] );
if ( !crs.geographicFlag() )
if ( !crs.isGeographic() )
{
// If the CRS is projected then check that projecting the corner of the bbox, assumed to be in WGS84,
// into the CRS, and then back to WGS84, works (check that we are in the validity area)
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgswfsfeatureiterator.cpp
Expand Up @@ -295,7 +295,7 @@ QUrl QgsWFSFeatureDownloader::buildURL( int startIndex, int maxFeatures, bool fo
{
bool invertAxis = false;
if ( !mShared->mWFSVersion.startsWith( "1.0" ) && !mShared->mURI.ignoreAxisOrientation() &&
mShared->mSourceCRS.axisInverted() )
mShared->mSourceCRS.hasAxisInverted() )
{
invertAxis = true;
}
Expand Down Expand Up @@ -551,7 +551,7 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
!mShared->mURI.invertAxisOrientation() )
{
QgsCoordinateReferenceSystem crs = QgsCrsCache::instance()->crsByOgcWmsCrs( parser->srsName() );
if ( crs.isValid() && crs.axisInverted() &&
if ( crs.isValid() && crs.hasAxisInverted() &&
!mShared->mCapabilityExtent.contains( parser->layerExtent() ) )
{
QgsRectangle invertedRectangle( parser->layerExtent() );
Expand Down

0 comments on commit ee62bde

Please sign in to comment.