Skip to content
Permalink
Browse files

Rename some QgsCoordinateReferenceSystem methods

- geographicFlag() -> isGeographic()
- axisInverted() -> hasAxisInverted()
  • Loading branch information
nyalldawson committed Jul 23, 2016
1 parent 2b8b979 commit ee62bdeeb4f093d5bc5821a1042799ec665237ef
@@ -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
@@ -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.
*/
@@ -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 );
@@ -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 ) )
{
@@ -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 &&
@@ -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;
@@ -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;
@@ -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() );
@@ -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 )
{
@@ -847,7 +847,7 @@ QString QgsCoordinateReferenceSystem::toProj4() const
return d->mProj4.trimmed();
}

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

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

QString QgsCoordinateReferenceSystem::geographicCrsAuthId() const
{
if ( geographicFlag() )
if ( isGeographic() )
{
return d->mAuthId;
}
@@ -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.
*/
@@ -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.
@@ -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 ) );
@@ -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.
@@ -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;
}
@@ -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
@@ -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.
@@ -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;
}
@@ -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;
}
@@ -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 )
{
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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();
@@ -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 );
}
@@ -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 );
}
@@ -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
}

@@ -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();
}
@@ -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();
}
@@ -2437,7 +2437,7 @@ bool QgsOracleProvider::createSpatialIndex()

QSqlQuery qry( *mConnection );

if ( !crs().geographicFlag() )
if ( !crs().isGeographic() )
{
// TODO: make precision configurable
QgsRectangle r( extent() );
@@ -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),"
@@ -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 );
@@ -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] );
}
@@ -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() );
}
}
@@ -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;
}
@@ -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)
@@ -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;
}
@@ -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() );

0 comments on commit ee62bde

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