Skip to content
Permalink
Browse files

Some renaming

  • Loading branch information
pblottiere committed Mar 10, 2021
1 parent 914338c commit d9dfa5d2c98a9691074c202bac240c7fc2f75944
@@ -505,14 +505,14 @@ Returns new instance of :py:class:`QgsMapLayerRenderer` that will be used for re
Returns the extent of the layer.
%End

QgsRectangle geographicExtent( bool actual = false ) const;
QgsRectangle wgs84Extent( bool forceRecalculate = false ) const;
%Docstring
Returns the geographic extent (EPSG:4326) of the layer according to
Returns the WGS84 extent (EPSG:4326) of the layer according to
ReadFlag.FlagTrustLayerMetadata. If that flag is activated, then the
geographic extent read in the qgs project is returned. Otherwise, the
actual geographic extent is returned.
WGS84 extent read in the qgs project is returned. Otherwise, the actual
WGS84 extent is returned.

:param actual: True to return the current geographic extent whatever the read flags
:param forceRecalculate: True to return the current WGS84 extent whatever the read flags

.. versionadded:: 3.18
%End
@@ -1707,9 +1707,9 @@ Copies attributes like name, short name, ... into another layer.
.. versionadded:: 3.0
%End

virtual void setExtent( const QgsRectangle &extent );
virtual void setExtent( const QgsRectangle &rect );
%Docstring
Sets the ``extent`` in layer CRS.
Sets the extent
%End

void setValid( bool valid );
@@ -395,9 +395,9 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, QgsReadWriteCon
// geographic extent is read only if necessary
if ( mReadFlags & QgsMapLayer::ReadFlag::FlagTrustLayerMetadata )
{
const QDomNode geoExtentNode = layerElement.namedItem( QStringLiteral( "geographicExtent" ) );
if ( !geoExtentNode.isNull() )
mGeographicExtent = QgsXmlUtils::readRectangle( geoExtentNode.toElement() );
const QDomNode wgs84ExtentNode = layerElement.namedItem( QStringLiteral( "wgs84extent" ) );
if ( !wgs84ExtentNode.isNull() )
mWgs84Extent = QgsXmlUtils::readRectangle( wgs84ExtentNode.toElement() );
}

return ! layerError;
@@ -419,7 +419,7 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume
if ( !extent().isNull() )
{
layerElement.appendChild( QgsXmlUtils::writeRectangle( mExtent, document ) );
layerElement.appendChild( QgsXmlUtils::writeRectangle( geographicExtent( true ), document, QStringLiteral( "geographicExtent" ) ) );
layerElement.appendChild( QgsXmlUtils::writeRectangle( wgs84Extent( true ), document, QStringLiteral( "wgs84extent" ) ) );
}

layerElement.setAttribute( QStringLiteral( "autoRefreshTime" ), QString::number( mRefreshTimer->interval() ) );
@@ -2011,25 +2011,25 @@ void QgsMapLayer::onNotified( const QString &message )
}
}

QgsRectangle QgsMapLayer::geographicExtent( bool actual ) const
QgsRectangle QgsMapLayer::wgs84Extent( bool forceRecalculate ) const
{
QgsRectangle geoExtent;
QgsRectangle wgs84Extent;

if ( mReadFlags & QgsMapLayer::ReadFlag::FlagTrustLayerMetadata && ! actual )
if ( mReadFlags & QgsMapLayer::ReadFlag::FlagTrustLayerMetadata && ! forceRecalculate )
{
geoExtent = mGeographicExtent;
wgs84Extent = mWgs84Extent;
}
else
{
const QgsCoordinateTransform transformer { crs(), QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() ), transformContext() };
try
{
geoExtent = transformer.transformBoundingBox( mExtent );
wgs84Extent = transformer.transformBoundingBox( mExtent );
}
catch ( const QgsCsException &cse )
{
geoExtent = QgsRectangle();
wgs84Extent = QgsRectangle();
}
}
return geoExtent;
return wgs84Extent;
}
@@ -515,14 +515,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
virtual QgsRectangle extent() const;

/**
* Returns the geographic extent (EPSG:4326) of the layer according to
* Returns the WGS84 extent (EPSG:4326) of the layer according to
* ReadFlag::FlagTrustLayerMetadata. If that flag is activated, then the
* geographic extent read in the qgs project is returned. Otherwise, the
* actual geographic extent is returned.
* \param actual True to return the current geographic extent whatever the read flags
* WGS84 extent read in the qgs project is returned. Otherwise, the actual
* WGS84 extent is returned.
* \param forceRecalculate True to return the current WGS84 extent whatever the read flags
* \since QGIS 3.18
*/
QgsRectangle geographicExtent( bool actual = false ) const;
QgsRectangle wgs84Extent( bool forceRecalculate = false ) const;

/**
* Returns the status of the layer. An invalid layer is one which has a bad datasource
@@ -1522,10 +1522,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
void clone( QgsMapLayer *layer ) const;

/**
* Sets the \a extent in layer CRS.
*/
virtual void setExtent( const QgsRectangle &extent );
//! Sets the extent
virtual void setExtent( const QgsRectangle &rect );

//! Sets whether layer is valid or not
void setValid( bool valid );
@@ -1618,7 +1616,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
mutable QgsRectangle mExtent;

//! Extent of the layer in EPSG:4326
QgsRectangle mGeographicExtent;
QgsRectangle mWgs84Extent;

//! Indicates if the layer is valid and can be drawn
bool mValid = false;
@@ -1065,15 +1065,15 @@ namespace QgsWms

//Ex_GeographicBoundingBox
QgsRectangle extent = l->extent(); // layer extent by default
QgsRectangle geoExtent = l->geographicExtent();
QgsRectangle wgs84Extent = l->wgs84Extent();
if ( l->type() == QgsMapLayerType::VectorLayer )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
if ( vl && vl->featureCount() == 0 )
{
// if there's no feature, use the wms extent defined in the
// project...
geoExtent = QgsRectangle();
wgs84Extent = QgsRectangle();
extent = QgsServerProjectUtils::wmsExtent( *project );
if ( extent.isNull() )
{
@@ -1097,7 +1097,7 @@ namespace QgsWms
}
}

appendLayerBoundingBoxes( doc, layerElem, extent, l->crs(), crsList, outputCrsList, project, geoExtent );
appendLayerBoundingBoxes( doc, layerElem, extent, l->crs(), crsList, outputCrsList, project, wgs84Extent );
}

// add details about supported styles of the layer

0 comments on commit d9dfa5d

Please sign in to comment.