mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-18 00:06:00 -04:00
Add QgsArcGisRestUtils::convertRectangle
See https://github.com/qgis/QGIS/pull/54944#pullrequestreview-1680737873
This commit is contained in:
parent
1262257ffb
commit
c99a33d224
@ -166,6 +166,15 @@ Converts a ``crs`` to an ArcGIS REST JSON representation.
|
|||||||
Returns an empty map if the ``crs`` is not valid.
|
Returns an empty map if the ``crs`` is not valid.
|
||||||
|
|
||||||
.. versionadded:: 3.28
|
.. versionadded:: 3.28
|
||||||
|
%End
|
||||||
|
|
||||||
|
static QgsRectangle convertRectangle( const QVariant &value );
|
||||||
|
%Docstring
|
||||||
|
Converts a rectangle ``value`` to a :py:class:`QgsRectangle`.
|
||||||
|
|
||||||
|
Returns a null rectangle if the value cannot be converted.
|
||||||
|
|
||||||
|
.. versionadded:: 3.34
|
||||||
%End
|
%End
|
||||||
|
|
||||||
enum class FeatureToJsonFlag
|
enum class FeatureToJsonFlag
|
||||||
|
@ -87,29 +87,7 @@ QgsRectangle QgsArcGisRestQueryUtils::getExtent( const QString &layerurl, const
|
|||||||
return QgsRectangle();
|
return QgsRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsRectangle rect;
|
return QgsArcGisRestUtils::convertRectangle( res.value( QStringLiteral( "extent" ) ) );
|
||||||
do
|
|
||||||
{
|
|
||||||
const QVariantMap coords = res.value( QStringLiteral( "extent" ) ).toMap();
|
|
||||||
if ( coords.isEmpty() ) break;
|
|
||||||
bool ok;
|
|
||||||
const double xmin = coords.value( QStringLiteral( "xmin" ) ).toDouble( &ok );
|
|
||||||
if ( ! ok ) break;
|
|
||||||
const double ymin = coords.value( QStringLiteral( "ymin" ) ).toDouble( &ok );
|
|
||||||
if ( ! ok ) break;
|
|
||||||
const double xmax = coords.value( QStringLiteral( "xmax" ) ).toDouble( &ok );
|
|
||||||
if ( ! ok ) break;
|
|
||||||
const double ymax = coords.value( QStringLiteral( "ymax" ) ).toDouble( &ok );
|
|
||||||
if ( ! ok ) break;
|
|
||||||
|
|
||||||
rect.setXMinimum( xmin );
|
|
||||||
rect.setYMinimum( ymin );
|
|
||||||
rect.setXMaximum( xmax );
|
|
||||||
rect.setYMaximum( ymax );
|
|
||||||
}
|
|
||||||
while ( 0 );
|
|
||||||
|
|
||||||
return rect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap QgsArcGisRestQueryUtils::getObjects( const QString &layerurl, const QString &authcfg, const QList<quint32> &objectIds, const QString &crs,
|
QVariantMap QgsArcGisRestQueryUtils::getObjects( const QString &layerurl, const QString &authcfg, const QList<quint32> &objectIds, const QString &crs,
|
||||||
|
@ -1053,6 +1053,33 @@ QDateTime QgsArcGisRestUtils::convertDateTime( const QVariant &value )
|
|||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsRectangle QgsArcGisRestUtils::convertRectangle( const QVariant &value )
|
||||||
|
{
|
||||||
|
if ( QgsVariantUtils::isNull( value ) )
|
||||||
|
return QgsRectangle();
|
||||||
|
|
||||||
|
const QVariantMap coords = value.toMap();
|
||||||
|
if ( coords.isEmpty() ) return QgsRectangle();
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
const double xmin = coords.value( QStringLiteral( "xmin" ) ).toDouble( &ok );
|
||||||
|
if ( ! ok ) return QgsRectangle();
|
||||||
|
|
||||||
|
const double ymin = coords.value( QStringLiteral( "ymin" ) ).toDouble( &ok );
|
||||||
|
if ( ! ok ) return QgsRectangle();
|
||||||
|
|
||||||
|
const double xmax = coords.value( QStringLiteral( "xmax" ) ).toDouble( &ok );
|
||||||
|
if ( ! ok ) return QgsRectangle();
|
||||||
|
|
||||||
|
const double ymax = coords.value( QStringLiteral( "ymax" ) ).toDouble( &ok );
|
||||||
|
if ( ! ok ) return QgsRectangle();
|
||||||
|
|
||||||
|
return QgsRectangle( xmin, ymin, xmax, ymax );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap QgsArcGisRestUtils::geometryToJson( const QgsGeometry &geometry, const QgsArcGisRestContext &, const QgsCoordinateReferenceSystem &crs )
|
QVariantMap QgsArcGisRestUtils::geometryToJson( const QgsGeometry &geometry, const QgsArcGisRestContext &, const QgsCoordinateReferenceSystem &crs )
|
||||||
{
|
{
|
||||||
QVariantMap res;
|
QVariantMap res;
|
||||||
|
@ -211,6 +211,15 @@ class CORE_EXPORT QgsArcGisRestUtils
|
|||||||
*/
|
*/
|
||||||
static QVariantMap crsToJson( const QgsCoordinateReferenceSystem &crs );
|
static QVariantMap crsToJson( const QgsCoordinateReferenceSystem &crs );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a rectangle \a value to a QgsRectangle.
|
||||||
|
*
|
||||||
|
* Returns a null rectangle if the value cannot be converted.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.34
|
||||||
|
*/
|
||||||
|
static QgsRectangle convertRectangle( const QVariant &value );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags which control the behavior of converting features to JSON.
|
* Flags which control the behavior of converting features to JSON.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user