46#include <QRegularExpression>
51 if ( esriFieldType == QLatin1String(
"esriFieldTypeInteger" ) )
52 return QVariant::LongLong;
53 if ( esriFieldType == QLatin1String(
"esriFieldTypeSmallInteger" ) )
55 if ( esriFieldType == QLatin1String(
"esriFieldTypeDouble" ) )
56 return QVariant::Double;
57 if ( esriFieldType == QLatin1String(
"esriFieldTypeSingle" ) )
58 return QVariant::Double;
59 if ( esriFieldType == QLatin1String(
"esriFieldTypeString" ) )
60 return QVariant::String;
61 if ( esriFieldType == QLatin1String(
"esriFieldTypeDate" ) )
62 return QVariant::DateTime;
63 if ( esriFieldType == QLatin1String(
"esriFieldTypeGeometry" ) )
64 return QVariant::Invalid;
65 if ( esriFieldType == QLatin1String(
"esriFieldTypeOID" ) )
66 return QVariant::LongLong;
67 if ( esriFieldType == QLatin1String(
"esriFieldTypeBlob" ) )
68 return QVariant::ByteArray;
69 if ( esriFieldType == QLatin1String(
"esriFieldTypeGlobalID" ) )
70 return QVariant::String;
71 if ( esriFieldType == QLatin1String(
"esriFieldTypeRaster" ) )
72 return QVariant::ByteArray;
73 if ( esriFieldType == QLatin1String(
"esriFieldTypeGUID" ) )
74 return QVariant::String;
75 if ( esriFieldType == QLatin1String(
"esriFieldTypeXML" ) )
76 return QVariant::String;
77 return QVariant::Invalid;
83 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
85 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
87 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
89 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
91 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
93 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
113std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertPoint(
const QVariantList &coordList,
Qgis::WkbType pointType )
115 int nCoords = coordList.size();
118 bool xok =
false, yok =
false;
119 const double x = coordList[0].toDouble( &xok );
120 const double y = coordList[1].toDouble( &yok );
124 const double z = hasZ && nCoords >= 3 ? coordList[2].toDouble() : std::numeric_limits< double >::quiet_NaN();
127 const double m =
QgsWkbTypes::hasM( pointType ) && ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN();
128 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
131std::unique_ptr< QgsCircularString > QgsArcGisRestUtils::convertCircularString(
const QVariantMap &curveData,
Qgis::WkbType pointType,
const QgsPoint &startPoint )
133 const QVariantList coordsList = curveData[QStringLiteral(
"c" )].toList();
134 if ( coordsList.isEmpty() )
136 const int coordsListSize = coordsList.size();
138 QVector<QgsPoint> points;
139 points.reserve( coordsListSize + 1 );
140 points.append( startPoint );
142 for (
int i = 0; i < coordsListSize - 1; )
146 std::unique_ptr< QgsPoint > endPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
150 std::unique_ptr< QgsPoint > interiorPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
151 if ( !interiorPoint )
154 points << *interiorPoint;
157 std::unique_ptr< QgsCircularString > curve = std::make_unique< QgsCircularString> ();
158 curve->setPoints( points );
162std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::convertCompoundCurve(
const QVariantList &curvesList,
Qgis::WkbType pointType )
165 std::unique_ptr< QgsCompoundCurve > compoundCurve = std::make_unique< QgsCompoundCurve >();
167 QVector< double > lineX;
168 QVector< double > lineY;
169 QVector< double > lineZ;
170 QVector< double > lineM;
171 int maxCurveListSize = curvesList.size();
172 lineX.resize( maxCurveListSize );
173 lineY.resize( maxCurveListSize );
177 lineZ.resize( maxCurveListSize );
180 lineM.resize( maxCurveListSize );
182 double *outLineX = lineX.data();
183 double *outLineY = lineY.data();
184 double *outLineZ = lineZ.data();
185 double *outLineM = lineM.data();
186 int actualLineSize = 0;
191 int curveListIndex = 0;
192 for (
const QVariant &curveData : curvesList )
194 if ( curveData.type() == QVariant::List )
196 const QVariantList coordList = curveData.toList();
197 const int nCoords = coordList.size();
201 const double x = coordList[0].toDouble( &xok );
202 const double y = coordList[1].toDouble( &yok );
211 *outLineZ++ = nCoords >= 3 ? coordList[2].toDouble() : std::numeric_limits< double >::quiet_NaN();
217 *outLineM++ = ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN();
220 else if ( curveData.type() == QVariant::Map )
224 if ( actualLineSize > 0 )
226 lastLineStringPoint =
QgsPoint( lineX.at( actualLineSize - 1 ),
227 lineY.at( actualLineSize - 1 ),
228 hasZ ? lineZ.at( actualLineSize - 1 ) : std::numeric_limits< double >::quiet_NaN(),
229 hasM ? lineM.at( actualLineSize - 1 ) : std::numeric_limits< double >::quiet_NaN() );
231 std::unique_ptr< QgsCircularString > circularString( convertCircularString( curveData.toMap(), pointType, lastLineStringPoint ) );
232 if ( !circularString )
237 if ( actualLineSize > 0 )
239 lineX.resize( actualLineSize );
240 lineY.resize( actualLineSize );
242 lineZ.resize( actualLineSize );
244 lineM.resize( actualLineSize );
246 compoundCurve->addCurve(
new QgsLineString( lineX, lineY, lineZ, lineM ) );
247 lineX.resize( maxCurveListSize - curveListIndex );
248 lineY.resize( maxCurveListSize - curveListIndex );
250 lineZ.resize( maxCurveListSize - curveListIndex );
252 lineM.resize( maxCurveListSize - curveListIndex );
253 outLineX = lineX.data();
254 outLineY = lineY.data();
255 outLineZ = lineZ.data();
256 outLineM = lineM.data();
260 if ( compoundCurve->curveAt( compoundCurve->nCurves() - 1 )->nCoordinates() < 2 )
261 compoundCurve->removeCurve( compoundCurve->nCurves() - 1 );
263 const QgsPoint endPointCircularString = circularString->endPoint();
264 compoundCurve->addCurve( circularString.release() );
268 *outLineX++ = endPointCircularString.
x();
269 *outLineY++ = endPointCircularString.
y();
271 *outLineZ++ = endPointCircularString.
z();
273 *outLineM++ = endPointCircularString.
m();
278 if ( actualLineSize == 1 && compoundCurve->nCurves() > 0 )
280 const QgsCurve *finalCurve = compoundCurve->curveAt( compoundCurve->nCurves() - 1 );
284 && ( !hasZ ||
qgsDoubleNear( finalCurveEndPoint.
z(), lineZ.at( 0 ) ) )
285 && ( !hasM ||
qgsDoubleNear( finalCurveEndPoint.
m(), lineM.at( 0 ) ) ) )
291 if ( actualLineSize > 0 )
293 lineX.resize( actualLineSize );
294 lineY.resize( actualLineSize );
296 lineZ.resize( actualLineSize );
298 lineM.resize( actualLineSize );
299 compoundCurve->addCurve(
new QgsLineString( lineX, lineY, lineZ, lineM ) );
302 return compoundCurve;
305std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertGeometryPoint(
const QVariantMap &geometryData,
Qgis::WkbType pointType )
308 bool xok =
false, yok =
false;
309 double x = geometryData[QStringLiteral(
"x" )].toDouble( &xok );
310 double y = geometryData[QStringLiteral(
"y" )].toDouble( &yok );
313 double z = geometryData[QStringLiteral(
"z" )].toDouble();
314 double m = geometryData[QStringLiteral(
"m" )].toDouble();
315 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
318std::unique_ptr< QgsMultiPoint > QgsArcGisRestUtils::convertMultiPoint(
const QVariantMap &geometryData,
Qgis::WkbType pointType )
321 const QVariantList coordsList = geometryData[QStringLiteral(
"points" )].toList();
323 std::unique_ptr< QgsMultiPoint > multiPoint = std::make_unique< QgsMultiPoint >();
324 multiPoint->reserve( coordsList.size() );
325 for (
const QVariant &coordData : coordsList )
327 const QVariantList coordList = coordData.toList();
328 std::unique_ptr< QgsPoint > p = convertPoint( coordList, pointType );
333 multiPoint->addGeometry( p.release() );
338 std::unique_ptr< QgsPoint > p = convertGeometryPoint( geometryData, pointType );
340 multiPoint->addGeometry( p.release() );
342 if ( multiPoint->numGeometries() == 0 )
350std::unique_ptr< QgsMultiCurve > QgsArcGisRestUtils::convertGeometryPolyline(
const QVariantMap &geometryData,
Qgis::WkbType pointType )
353 QVariantList pathsList;
354 if ( geometryData[QStringLiteral(
"paths" )].isValid() )
355 pathsList = geometryData[QStringLiteral(
"paths" )].toList();
356 else if ( geometryData[QStringLiteral(
"curvePaths" )].isValid() )
357 pathsList = geometryData[QStringLiteral(
"curvePaths" )].toList();
358 if ( pathsList.isEmpty() )
360 std::unique_ptr< QgsMultiCurve > multiCurve = std::make_unique< QgsMultiCurve >();
361 multiCurve->reserve( pathsList.size() );
362 for (
const QVariant &pathData : std::as_const( pathsList ) )
364 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( pathData.toList(), pointType );
369 multiCurve->addGeometry( curve.release() );
374std::unique_ptr< QgsMultiSurface > QgsArcGisRestUtils::convertGeometryPolygon(
const QVariantMap &geometryData,
Qgis::WkbType pointType )
377 QVariantList ringsList;
378 if ( geometryData[QStringLiteral(
"rings" )].isValid() )
379 ringsList = geometryData[QStringLiteral(
"rings" )].toList();
380 else if ( geometryData[QStringLiteral(
"ringPaths" )].isValid() )
381 ringsList = geometryData[QStringLiteral(
"ringPaths" )].toList();
382 if ( ringsList.isEmpty() )
385 QList< QgsCompoundCurve * > curves;
386 for (
int i = 0, n = ringsList.size(); i < n; ++i )
388 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( ringsList[i].toList(), pointType );
393 curves.append( curve.release() );
395 if ( curves.count() == 0 )
398 std::unique_ptr< QgsMultiSurface > result = std::make_unique< QgsMultiSurface >();
399 if ( curves.count() == 1 )
402 std::unique_ptr< QgsCurvePolygon > newPolygon = std::make_unique< QgsCurvePolygon >();
403 newPolygon->setExteriorRing( curves.takeAt( 0 ) );
404 result->addGeometry( newPolygon.release() );
408 std::sort( curves.begin(), curves.end(), [](
const QgsCompoundCurve * a,
const QgsCompoundCurve * b )->bool{ double a_area = 0.0; double b_area = 0.0; a->sumUpArea( a_area ); b->sumUpArea( b_area ); return std::abs( a_area ) > std::abs( b_area ); } );
409 result->reserve( curves.size() );
410 while ( !curves.isEmpty() )
416 engine->prepareGeometry();
418 QMutableListIterator< QgsCompoundCurve * > it( curves );
419 while ( it.hasNext() )
426 if ( engine->contains( &point ) )
431 engine->prepareGeometry();
435 result->addGeometry( newPolygon );
437 if ( result->numGeometries() == 0 )
443std::unique_ptr< QgsPolygon > QgsArcGisRestUtils::convertEnvelope(
const QVariantMap &geometryData )
446 bool xminOk =
false, yminOk =
false, xmaxOk =
false, ymaxOk =
false;
447 double xmin = geometryData[QStringLiteral(
"xmin" )].toDouble( &xminOk );
448 double ymin = geometryData[QStringLiteral(
"ymin" )].toDouble( &yminOk );
449 double xmax = geometryData[QStringLiteral(
"xmax" )].toDouble( &xmaxOk );
450 double ymax = geometryData[QStringLiteral(
"ymax" )].toDouble( &ymaxOk );
451 if ( !xminOk || !yminOk || !xmaxOk || !ymaxOk )
453 std::unique_ptr< QgsLineString > ext = std::make_unique< QgsLineString> ();
454 ext->addVertex(
QgsPoint( xmin, ymin ) );
455 ext->addVertex(
QgsPoint( xmax, ymin ) );
456 ext->addVertex(
QgsPoint( xmax, ymax ) );
457 ext->addVertex(
QgsPoint( xmin, ymax ) );
458 ext->addVertex(
QgsPoint( xmin, ymin ) );
459 std::unique_ptr< QgsPolygon > poly = std::make_unique< QgsPolygon >();
460 poly->setExteriorRing( ext.release() );
473 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
475 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
476 return convertGeometryPoint( geometryData, pointType ).release();
477 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
478 return convertMultiPoint( geometryData, pointType ).release();
479 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
480 return convertGeometryPolyline( geometryData, pointType ).release();
481 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
482 return convertGeometryPolygon( geometryData, pointType ).release();
483 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
484 return convertEnvelope( geometryData ).release();
507 QString spatialReference = spatialReferenceMap[QStringLiteral(
"latestWkid" )].toString();
508 if ( spatialReference.isEmpty() )
509 spatialReference = spatialReferenceMap[QStringLiteral(
"wkid" )].toString();
512 if ( !spatialReference.isEmpty() )
521 else if ( !spatialReferenceMap[QStringLiteral(
"wkt" )].toString().isEmpty() )
524 crs.
createFromWkt( spatialReferenceMap[QStringLiteral(
"wkt" )].toString() );
539 const QString type = symbolData.value( QStringLiteral(
"type" ) ).toString();
540 if ( type == QLatin1String(
"esriSMS" ) )
543 return parseEsriMarkerSymbolJson( symbolData ).release();
545 else if ( type == QLatin1String(
"esriSLS" ) )
548 return parseEsriLineSymbolJson( symbolData ).release();
550 else if ( type == QLatin1String(
"esriSFS" ) )
553 return parseEsriFillSymbolJson( symbolData ).release();
555 else if ( type == QLatin1String(
"esriPFS" ) )
557 return parseEsriPictureFillSymbolJson( symbolData ).release();
559 else if ( type == QLatin1String(
"esriPMS" ) )
562 return parseEsriPictureMarkerSymbolJson( symbolData ).release();
564 else if ( type == QLatin1String(
"esriTS" ) )
572std::unique_ptr<QgsLineSymbol> QgsArcGisRestUtils::parseEsriLineSymbolJson(
const QVariantMap &symbolData )
574 QColor lineColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
575 if ( !lineColor.isValid() )
579 double widthInPoints = symbolData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
584 Qt::PenStyle penStyle =
convertLineStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
585 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, widthInPoints, penStyle );
587 layers.append( lineLayer.release() );
589 std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >( layers );
593std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriFillSymbolJson(
const QVariantMap &symbolData )
595 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
596 Qt::BrushStyle brushStyle =
convertFillStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
598 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
599 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
600 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
602 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
605 std::unique_ptr< QgsSimpleFillSymbolLayer > fillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( fillColor, brushStyle, lineColor, penStyle, penWidthInPoints );
607 layers.append( fillLayer.release() );
609 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
613std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriPictureFillSymbolJson(
const QVariantMap &symbolData )
617 double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
621 const double xScale = symbolData.value( QStringLiteral(
"xscale" ) ).toDouble( &ok );
623 widthInPixels *= xScale;
625 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
630 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
631 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
633 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
634 symbolPath.prepend( QLatin1String(
"base64:" ) );
637 std::unique_ptr< QgsRasterFillSymbolLayer > fillLayer = std::make_unique< QgsRasterFillSymbolLayer >( symbolPath );
638 fillLayer->setWidth( widthInPixels );
639 fillLayer->setAngle( angleCW );
641 fillLayer->setOffset( QPointF( xOffset, yOffset ) );
643 layers.append( fillLayer.release() );
645 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
646 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
647 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
648 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
650 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, penWidthInPoints, penStyle );
652 layers.append( lineLayer.release() );
654 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
658Qgis::MarkerShape QgsArcGisRestUtils::parseEsriMarkerShape(
const QString &style )
660 if ( style == QLatin1String(
"esriSMSCircle" ) )
662 else if ( style == QLatin1String(
"esriSMSCross" ) )
664 else if ( style == QLatin1String(
"esriSMSDiamond" ) )
666 else if ( style == QLatin1String(
"esriSMSSquare" ) )
668 else if ( style == QLatin1String(
"esriSMSX" ) )
670 else if ( style == QLatin1String(
"esriSMSTriangle" ) )
676std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriMarkerSymbolJson(
const QVariantMap &symbolData )
678 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
680 const double sizeInPoints = symbolData.value( QStringLiteral(
"size" ) ).toDouble( &ok );
683 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
688 Qgis::MarkerShape shape = parseEsriMarkerShape( symbolData.value( QStringLiteral(
"style" ) ).toString() );
690 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
691 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
693 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
694 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
695 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
696 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
699 std::unique_ptr< QgsSimpleMarkerSymbolLayer > markerLayer = std::make_unique< QgsSimpleMarkerSymbolLayer >( shape, sizeInPoints, angleCW,
Qgis::ScaleMethod::ScaleArea, fillColor, lineColor );
702 markerLayer->setStrokeStyle( penStyle );
703 markerLayer->setStrokeWidth( penWidthInPoints );
704 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
706 layers.append( markerLayer.release() );
708 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
712std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriPictureMarkerSymbolJson(
const QVariantMap &symbolData )
715 const double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
718 const double heightInPixels = symbolData.value( QStringLiteral(
"height" ) ).toInt( &ok );
722 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
727 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
728 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
732 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
733 symbolPath.prepend( QLatin1String(
"base64:" ) );
736 std::unique_ptr< QgsRasterMarkerSymbolLayer > markerLayer = std::make_unique< QgsRasterMarkerSymbolLayer >( symbolPath, widthInPixels, angleCW,
Qgis::ScaleMethod::ScaleArea );
740 if ( !
qgsDoubleNear(
static_cast< double >( heightInPixels ) / widthInPixels, markerLayer->defaultAspectRatio() ) )
741 markerLayer->setFixedAspectRatio(
static_cast< double >( heightInPixels ) / widthInPixels );
743 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
745 layers.append( markerLayer.release() );
747 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
753 if ( labelingData.empty() )
760 for (
const QVariant &lbl : labelingData )
762 const QVariantMap labeling = lbl.toMap();
767 const QString placement = labeling.value( QStringLiteral(
"labelPlacement" ) ).toString();
768 if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveCenter" ) )
773 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowCenter" ) )
778 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterCenter" ) )
783 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveLeft" ) )
788 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowLeft" ) )
793 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterLeft" ) )
798 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveRight" ) )
803 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowRight" ) )
808 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterRight" ) )
813 else if ( placement == QLatin1String(
"esriServerLinePlacementAboveAfter" ) ||
814 placement == QLatin1String(
"esriServerLinePlacementAboveStart" ) ||
815 placement == QLatin1String(
"esriServerLinePlacementAboveAlong" ) )
820 else if ( placement == QLatin1String(
"esriServerLinePlacementBelowAfter" ) ||
821 placement == QLatin1String(
"esriServerLinePlacementBelowStart" ) ||
822 placement == QLatin1String(
"esriServerLinePlacementBelowAlong" ) )
827 else if ( placement == QLatin1String(
"esriServerLinePlacementCenterAfter" ) ||
828 placement == QLatin1String(
"esriServerLinePlacementCenterStart" ) ||
829 placement == QLatin1String(
"esriServerLinePlacementCenterAlong" ) )
834 else if ( placement == QLatin1String(
"esriServerPolygonPlacementAlwaysHorizontal" ) )
839 const double minScale = labeling.value( QStringLiteral(
"minScale" ) ).toDouble();
840 const double maxScale = labeling.value( QStringLiteral(
"maxScale" ) ).toDouble();
842 QVariantMap symbol = labeling.value( QStringLiteral(
"symbol" ) ).toMap();
844 const double haloSize = symbol.value( QStringLiteral(
"haloSize" ) ).toDouble();
855 const QString fontFamily = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"family" ) ).toString();
856 const QString fontStyle = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"style" ) ).toString();
857 const QString fontWeight = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"weight" ) ).toString();
858 const int fontSize = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"size" ) ).toInt();
859 QFont font( fontFamily, fontSize );
860 font.setStyleName( fontStyle );
861 font.setWeight( fontWeight == QLatin1String(
"bold" ) ? QFont::Bold : QFont::Normal );
869 QString where = labeling.value( QStringLiteral(
"where" ) ).toString();
888 const QString type = rendererData.value( QStringLiteral(
"type" ) ).toString();
889 if ( type == QLatin1String(
"simple" ) )
891 const QVariantMap symbolProps = rendererData.value( QStringLiteral(
"symbol" ) ).toMap();
892 std::unique_ptr< QgsSymbol > symbol(
convertSymbol( symbolProps ) );
898 else if ( type == QLatin1String(
"uniqueValue" ) )
900 const QString field1 = rendererData.value( QStringLiteral(
"field1" ) ).toString();
901 const QString field2 = rendererData.value( QStringLiteral(
"field2" ) ).toString();
902 const QString field3 = rendererData.value( QStringLiteral(
"field3" ) ).toString();
904 if ( !field2.isEmpty() || !field3.isEmpty() )
906 const QString delimiter = rendererData.value( QStringLiteral(
"fieldDelimiter" ) ).toString();
907 if ( !field3.isEmpty() )
909 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\",'%4',\"%5\")" ).arg( field1, delimiter, field2, delimiter, field3 );
913 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\")" ).arg( field1, delimiter, field2 );
921 const QVariantList categories = rendererData.value( QStringLiteral(
"uniqueValueInfos" ) ).toList();
923 for (
const QVariant &category : categories )
925 const QVariantMap categoryData = category.toMap();
926 const QString value = categoryData.value( QStringLiteral(
"value" ) ).toString();
927 const QString label = categoryData.value( QStringLiteral(
"label" ) ).toString();
935 std::unique_ptr< QgsSymbol > defaultSymbol(
convertSymbol( rendererData.value( QStringLiteral(
"defaultSymbol" ) ).toMap() ) );
938 categoryList.append(
QgsRendererCategory( QVariant(), defaultSymbol.release(), rendererData.value( QStringLiteral(
"defaultLabel" ) ).toString() ) );
941 if ( categoryList.empty() )
946 else if ( type == QLatin1String(
"classBreaks" ) )
951 else if ( type == QLatin1String(
"heatmap" ) )
956 else if ( type == QLatin1String(
"vectorField" ) )
966 QString expression = string;
969 const thread_local QRegularExpression rx1 = QRegularExpression( QStringLiteral(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)CONCAT(\\s|$)" ) );
970 expression = expression.replace( rx1, QStringLiteral(
"\\4||\\5" ) );
972 const thread_local QRegularExpression rx2 = QRegularExpression( QStringLiteral(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)NEWLINE(\\s|$)" ) );
973 expression = expression.replace( rx2, QStringLiteral(
"\\4'\\n'\\5" ) );
976 const thread_local QRegularExpression rx3 = QRegularExpression( QStringLiteral(
"\"(.*?(?<!\\\\))\"" ) );
977 expression = expression.replace( rx3, QStringLiteral(
"'\\1'" ) );
978 const thread_local QRegularExpression rx4 = QRegularExpression( QStringLiteral(
"\\\\\"" ) );
979 expression = expression.replace( rx4, QStringLiteral(
"\"" ) );
982 const thread_local QRegularExpression rx5 = QRegularExpression( QStringLiteral(
"\\[([^]]*)\\]" ) );
983 expression = expression.replace( rx5, QStringLiteral(
"\"\\1\"" ) );
990 const QVariantList colorParts = colorData.toList();
991 if ( colorParts.count() < 4 )
994 int red = colorParts.at( 0 ).toInt();
995 int green = colorParts.at( 1 ).toInt();
996 int blue = colorParts.at( 2 ).toInt();
997 int alpha = colorParts.at( 3 ).toInt();
998 return QColor( red, green, blue, alpha );
1003 if ( style == QLatin1String(
"esriSLSSolid" ) )
1004 return Qt::SolidLine;
1005 else if ( style == QLatin1String(
"esriSLSDash" ) )
1006 return Qt::DashLine;
1007 else if ( style == QLatin1String(
"esriSLSDashDot" ) )
1008 return Qt::DashDotLine;
1009 else if ( style == QLatin1String(
"esriSLSDashDotDot" ) )
1010 return Qt::DashDotDotLine;
1011 else if ( style == QLatin1String(
"esriSLSDot" ) )
1013 else if ( style == QLatin1String(
"esriSLSNull" ) )
1016 return Qt::SolidLine;
1021 if ( style == QLatin1String(
"esriSFSBackwardDiagonal" ) )
1022 return Qt::BDiagPattern;
1023 else if ( style == QLatin1String(
"esriSFSCross" ) )
1024 return Qt::CrossPattern;
1025 else if ( style == QLatin1String(
"esriSFSDiagonalCross" ) )
1026 return Qt::DiagCrossPattern;
1027 else if ( style == QLatin1String(
"esriSFSForwardDiagonal" ) )
1028 return Qt::FDiagPattern;
1029 else if ( style == QLatin1String(
"esriSFSHorizontal" ) )
1030 return Qt::HorPattern;
1031 else if ( style == QLatin1String(
"esriSFSNull" ) )
1033 else if ( style == QLatin1String(
"esriSFSSolid" ) )
1034 return Qt::SolidPattern;
1035 else if ( style == QLatin1String(
"esriSFSVertical" ) )
1036 return Qt::VerPattern;
1038 return Qt::SolidPattern;
1046 QDateTime dt = QDateTime::fromMSecsSinceEpoch( value.toLongLong( &ok ) );
1049 QgsDebugError( QStringLiteral(
"Invalid value %1 for datetime" ).arg( value.toString() ) );
1061 const QVariantMap coords = value.toMap();
1066 const double xmin = coords.value( QStringLiteral(
"xmin" ) ).toDouble( &ok );
1069 const double ymin = coords.value( QStringLiteral(
"ymin" ) ).toDouble( &ok );
1072 const double xmax = coords.value( QStringLiteral(
"xmax" ) ).toDouble( &ok );
1075 const double ymax = coords.value( QStringLiteral(
"ymax" ) ).toDouble( &ok );
1087 return QVariantMap();
1094 return QVariantMap();
1097 res = pointToJson( qgsgeometry_cast< const QgsPoint * >( geom ) );
1101 res = lineStringToJson( qgsgeometry_cast< const QgsLineString * >( geom ) );
1106 res = curveToJson( qgsgeometry_cast< const QgsCurve * >( geom ) );
1110 res = polygonToJson( qgsgeometry_cast< const QgsPolygon * >( geom ) );
1114 res = multiPointToJson( qgsgeometry_cast< const QgsMultiPoint * >( geom ) );
1118 res = multiLineStringToJson( qgsgeometry_cast< const QgsMultiLineString * >( geom ) );
1122 res = multiCurveToJson( qgsgeometry_cast< const QgsMultiCurve * >( geom ) );
1126 res = multiPolygonToJson( qgsgeometry_cast< const QgsMultiPolygon * >( geom ) );
1130 res = curvePolygonToJson( qgsgeometry_cast< const QgsCurvePolygon * >( geom ) );
1134 res = multiSurfaceToJson( qgsgeometry_cast< const QgsMultiSurface * >( geom ) );
1138 return QVariantMap();
1141 return QVariantMap();
1144 return QVariantMap();
1151 res.insert( QStringLiteral(
"spatialReference" ),
crsToJson(
crs ) );
1157QVariantMap QgsArcGisRestUtils::pointToJson(
const QgsPoint *point )
1161 data[QStringLiteral(
"x" )] = QStringLiteral(
"NaN" );
1164 data[QStringLiteral(
"x" )] = point->
x();
1165 data[QStringLiteral(
"y" )] = point->
y();
1167 if ( point->
is3D() )
1168 data[QStringLiteral(
"z" )] = !std::isnan( point->
z() ) ? QVariant( point->
z() ) : QVariant( QStringLiteral(
"NaN" ) );
1171 data[QStringLiteral(
"m" )] = !std::isnan( point->
m() ) ? QVariant( point->
m() ) : QVariant( QStringLiteral(
"NaN" ) );
1176QVariantMap QgsArcGisRestUtils::multiPointToJson(
const QgsMultiPoint *multiPoint )
1179 const bool hasZ = multiPoint->
is3D();
1180 const bool hasM = multiPoint->
isMeasure();
1181 data[QStringLiteral(
"hasM" )] = hasM;
1182 data[QStringLiteral(
"hasZ" )] = hasZ;
1184 QVariantList pointsList;
1186 pointsList.reserve( size );
1188 QVariantList pointList;
1189 for (
int i = 0; i < size; ++i )
1194 pointList.append( point->
x() );
1195 pointList.append( point->
y() );
1197 pointList.append( point->
z() );
1198 if ( hasM && !std::isnan( point->
m() ) )
1199 pointList.append( point->
m() );
1201 pointsList.push_back( pointList );
1204 data[QStringLiteral(
"points" )] = pointsList;
1208QVariantList QgsArcGisRestUtils::lineStringToJsonPath(
const QgsLineString *line )
1210 const bool hasZ = line->
is3D();
1213 QVariantList pointsList;
1215 pointsList.reserve( size );
1217 QVariantList pointList;
1218 const double *xData = line->
xData();
1219 const double *yData = line->
yData();
1220 const double *zData = hasZ ? line->
zData() :
nullptr;
1221 const double *mData = hasM ? line->
mData() :
nullptr;
1223 for (
int i = 0; i < size; ++i )
1226 pointList.append( *xData++ );
1227 pointList.append( *yData++ );
1230 pointList.append( *zData++ );
1232 if ( hasM && !std::isnan( *mData ) )
1233 pointList.append( *mData );
1237 pointsList.push_back( pointList );
1242QVariantList QgsArcGisRestUtils::curveToJsonCurve(
const QgsCurve *curve,
bool includeStart )
1244 const bool hasZ = curve->
is3D();
1247 auto pointToList = [hasZ, hasM](
const QgsPoint & point ) -> QVariantList
1249 QVariantList pointList;
1251 pointList.append( point.
x() );
1252 pointList.append( point.
y() );
1255 pointList.append( point.
z() );
1257 if ( hasM && !std::isnan( point.
m() ) )
1258 pointList.append( point.
m() );
1268 QVariantList part = lineStringToJsonPath( qgsgeometry_cast< const QgsLineString *>( curve ) );
1269 if ( !part.isEmpty() && !includeStart )
1277 const QgsCircularString *circularString = qgsgeometry_cast<const QgsCircularString * >( curve );
1278 if ( includeStart && !circularString->
isEmpty() )
1280 res.push_back( pointToList( circularString->
startPoint() ) );
1283 const int size = circularString->
numPoints();
1284 for (
int i = 1; i + 1 < size; i += 2 )
1287 QVariantMap curvePart;
1288 QVariantList curveList;
1289 curveList.push_back( pointToList( circularString->
pointN( i + 1 ) ) );
1291 curveList.push_back( pointToList( circularString->
pointN( i ) ) );
1293 curvePart.insert( QStringLiteral(
"c" ), curveList );
1294 res.push_back( curvePart );
1301 const QgsCompoundCurve *compoundCurve = qgsgeometry_cast<const QgsCompoundCurve * >( curve );
1303 const int size = compoundCurve->
nCurves();
1304 for (
int i = 0; i < size; ++i )
1307 res.append( curveToJsonCurve( subCurve, i == 0 ) );
1318QVariantMap QgsArcGisRestUtils::lineStringToJson(
const QgsLineString *line )
1321 const bool hasZ = line->
is3D();
1323 data[QStringLiteral(
"hasM" )] = hasM;
1324 data[QStringLiteral(
"hasZ" )] = hasZ;
1326 const QVariantList pointsList = lineStringToJsonPath( line );
1328 QVariantList pointsData = QVariantList();
1329 pointsData.push_back( pointsList );
1330 data[QStringLiteral(
"paths" )] = pointsData;
1335QVariantMap QgsArcGisRestUtils::curveToJson(
const QgsCurve *curve )
1338 const bool hasZ = curve->
is3D();
1340 data[QStringLiteral(
"hasM" )] = hasM;
1341 data[QStringLiteral(
"hasZ" )] = hasZ;
1343 const QVariantList curveList = curveToJsonCurve( curve,
true );
1345 QVariantList curveData = QVariantList();
1346 curveData.push_back( curveList );
1347 data[QStringLiteral(
"curvePaths" )] = curveData;
1352QVariantMap QgsArcGisRestUtils::multiLineStringToJson(
const QgsMultiLineString *multiLine )
1355 const bool hasZ = multiLine->
is3D();
1356 const bool hasM = multiLine->
isMeasure();
1357 data[QStringLiteral(
"hasM" )] = hasM;
1358 data[QStringLiteral(
"hasZ" )] = hasZ;
1362 paths.reserve( size );
1363 for (
int i = 0; i < size; ++i )
1366 paths.push_back( lineStringToJsonPath( line ) );
1369 data[QStringLiteral(
"paths" )] = paths;
1373QVariantMap QgsArcGisRestUtils::multiCurveToJson(
const QgsMultiCurve *multiCurve )
1376 const bool hasZ = multiCurve->
is3D();
1377 const bool hasM = multiCurve->
isMeasure();
1378 data[QStringLiteral(
"hasM" )] = hasM;
1379 data[QStringLiteral(
"hasZ" )] = hasZ;
1383 paths.reserve( size );
1384 for (
int i = 0; i < size; ++i )
1387 paths.push_back( curveToJsonCurve( curve,
true ) );
1390 data[QStringLiteral(
"curvePaths" )] = paths;
1394QVariantList QgsArcGisRestUtils::polygonToJsonRings(
const QgsPolygon *polygon )
1398 rings.reserve( numInteriorRings + 1 );
1406 rings.push_back( lineStringToJsonPath( exterior ) );
1411 std::unique_ptr< QgsLineString > reversed( exterior->
reversed() );
1412 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1420 for (
int i = 0; i < numInteriorRings; ++i )
1427 rings.push_back( lineStringToJsonPath( ring ) );
1432 std::unique_ptr< QgsLineString > reversed( ring->
reversed() );
1433 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1443QVariantList QgsArcGisRestUtils::curvePolygonToJsonRings(
const QgsCurvePolygon *polygon )
1447 rings.reserve( numInteriorRings + 1 );
1449 if (
const QgsCurve *exterior = qgsgeometry_cast< const QgsCurve * >( polygon->
exteriorRing() ) )
1455 rings.push_back( curveToJsonCurve( exterior,
true ) );
1460 std::unique_ptr< QgsCurve > reversed( exterior->
reversed() );
1461 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1469 for (
int i = 0; i < numInteriorRings; ++i )
1476 rings.push_back( curveToJsonCurve( ring,
true ) );
1481 std::unique_ptr< QgsCurve > reversed( ring->
reversed() );
1482 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1492QVariantMap QgsArcGisRestUtils::polygonToJson(
const QgsPolygon *polygon )
1495 const bool hasZ = polygon->
is3D();
1497 data[QStringLiteral(
"hasM" )] = hasM;
1498 data[QStringLiteral(
"hasZ" )] = hasZ;
1499 data[QStringLiteral(
"rings" )] = polygonToJsonRings( polygon );
1503QVariantMap QgsArcGisRestUtils::curvePolygonToJson(
const QgsCurvePolygon *polygon )
1506 const bool hasZ = polygon->
is3D();
1508 data[QStringLiteral(
"hasM" )] = hasM;
1509 data[QStringLiteral(
"hasZ" )] = hasZ;
1510 data[QStringLiteral(
"curveRings" )] = curvePolygonToJsonRings( polygon );
1514QVariantMap QgsArcGisRestUtils::multiPolygonToJson(
const QgsMultiPolygon *multiPolygon )
1517 const bool hasZ = multiPolygon->
is3D();
1518 const bool hasM = multiPolygon->
isMeasure();
1519 data[QStringLiteral(
"hasM" )] = hasM;
1520 data[QStringLiteral(
"hasZ" )] = hasZ;
1524 for (
int i = 0; i < size; ++i )
1527 rings.append( polygonToJsonRings( polygon ) );
1530 data[QStringLiteral(
"rings" )] = rings;
1534QVariantMap QgsArcGisRestUtils::multiSurfaceToJson(
const QgsMultiSurface *multiSurface )
1537 const bool hasZ = multiSurface->
is3D();
1538 const bool hasM = multiSurface->
isMeasure();
1539 data[QStringLiteral(
"hasM" )] = hasM;
1540 data[QStringLiteral(
"hasZ" )] = hasZ;
1544 for (
int i = 0; i < size; ++i )
1550 rings.append( curvePolygonToJsonRings( polygon ) );
1553 data[QStringLiteral(
"curveRings" )] = rings;
1564 if ( !authid.isEmpty() )
1566 const thread_local QRegularExpression rxAuthid( QStringLiteral(
"(\\w+):(\\d+)" ) );
1567 const QRegularExpressionMatch match = rxAuthid.match( authid );
1568 if ( match.hasMatch()
1570 ( match.captured( 1 ).compare( QLatin1String(
"EPSG" ), Qt::CaseInsensitive ) == 0 )
1571 || ( match.captured( 1 ).compare( QLatin1String(
"ESRI" ), Qt::CaseInsensitive ) == 0 )
1575 const QString wkid = match.captured( 2 );
1576 res.insert( QStringLiteral(
"wkid" ), wkid );
1595 QVariantMap attributes;
1597 for (
const QgsField &field : fields )
1602 if ( !attributes.isEmpty() )
1604 res.insert( QStringLiteral(
"attributes" ), attributes );
1614 switch ( expectedType )
1616 case QVariant::String:
1617 return QString( QUrl::toPercentEncoding( variant.toString() ) );
1619 case QVariant::DateTime:
1620 case QVariant::Date:
1622 switch ( variant.type() )
1624 case QVariant::DateTime:
1625 return variant.toDateTime().toMSecsSinceEpoch();
1627 case QVariant::Date:
1629 if ( context.
timeZone().isValid() )
1630 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ), context.
timeZone() ).toMSecsSinceEpoch();
1632 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ) ).toMSecsSinceEpoch();
1647 res.insert( QStringLiteral(
"name" ), field.
name() );
1650 switch ( field.
type() )
1652 case QVariant::LongLong:
1653 fieldType = QStringLiteral(
"esriFieldTypeInteger" );
1657 fieldType = QStringLiteral(
"esriFieldTypeSmallInteger" );
1660 case QVariant::Double:
1661 fieldType = QStringLiteral(
"esriFieldTypeDouble" );
1664 case QVariant::String:
1665 fieldType = QStringLiteral(
"esriFieldTypeString" );
1668 case QVariant::DateTime:
1669 case QVariant::Date:
1670 fieldType = QStringLiteral(
"esriFieldTypeDate" );
1673 case QVariant::ByteArray:
1674 fieldType = QStringLiteral(
"esriFieldTypeBlob" );
1679 fieldType = QStringLiteral(
"esriFieldTypeString" );
1682 res.insert( QStringLiteral(
"type" ), fieldType );
1684 if ( !field.
alias().isEmpty() )
1685 res.insert( QStringLiteral(
"alias" ), field.
alias() );
1689 res.insert( QStringLiteral(
"nullable" ), !notNullable );
1692 res.insert( QStringLiteral(
"editable" ),
true );
1699 if ( type.compare( QLatin1String(
"FeatureServer" ), Qt::CaseInsensitive ) == 0 )
1701 else if ( type.compare( QLatin1String(
"MapServer" ), Qt::CaseInsensitive ) == 0 )
1703 else if ( type.compare( QLatin1String(
"ImageServer" ), Qt::CaseInsensitive ) == 0 )
1705 else if ( type.compare( QLatin1String(
"GlobeServer" ), Qt::CaseInsensitive ) == 0 )
1707 else if ( type.compare( QLatin1String(
"GPServer" ), Qt::CaseInsensitive ) == 0 )
1709 else if ( type.compare( QLatin1String(
"GeocodeServer" ), Qt::CaseInsensitive ) == 0 )
@ BelowLine
Labels can be placed below a line feature. Unless MapOrientation is also specified this mode respects...
@ MapOrientation
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
@ OnLine
Labels can be placed directly over a line feature.
@ AboveLine
Labels can be placed above a line feature. Unless MapOrientation is also specified this mode respects...
@ NoOrientation
Unknown orientation or sentinel value.
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ ScaleArea
Calculate scale by the area.
ArcGisRestServiceType
Available ArcGIS REST service types.
@ GeocodeServer
GeocodeServer.
@ Unknown
Other unknown/unsupported type.
@ GlobeServer
GlobeServer.
@ ImageServer
ImageServer.
@ FeatureServer
FeatureServer.
MarkerShape
Marker shapes.
@ Cross2
Rotated cross (lines only), 'x' shape.
@ Cross
Cross (lines only)
@ Points
Points (e.g., for font sizes)
WkbType
The WKB type describes the number of dimensions a geometry has.
@ CompoundCurve
CompoundCurve.
@ MultiPolygon
MultiPolygon.
@ MultiLineString
MultiLineString.
@ CircularString
CircularString.
@ GeometryCollection
GeometryCollection.
@ CurvePolygon
CurvePolygon.
@ MultiSurface
MultiSurface.
@ Wkt2_2019Simplified
WKT2_2019 with the simplification rule of WKT2_SIMPLIFIED.
Abstract base class for all geometries.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Contains the context of a ArcGIS REST service operation.
QTimeZone timeZone() const
Returns the time zone for datetime values.
QString objectIdFieldName() const
Returns the name of the objectId field.
static QVariantMap fieldDefinitionToJson(const QgsField &field)
Converts a field's definition to an ArcGIS REST JSON representation.
static QgsCoordinateReferenceSystem convertSpatialReference(const QVariantMap &spatialReferenceMap)
Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.
static QDateTime convertDateTime(const QVariant &value)
Converts a date time value to a QDateTime.
static Qgis::WkbType convertGeometryType(const QString &type)
Converts an ESRI REST geometry type to a WKB type.
static QString convertLabelingExpression(const QString &string)
Converts an ESRI labeling expression to a QGIS expression string.
static QgsSymbol * convertSymbol(const QVariantMap &definition)
Converts a symbol JSON definition to a QgsSymbol.
static QVariantMap geometryToJson(const QgsGeometry &geometry, const QgsArcGisRestContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Converts a geometry to an ArcGIS REST JSON representation.
static Qgis::ArcGisRestServiceType serviceTypeFromString(const QString &type)
Converts a string value to a REST service type.
static QgsAbstractGeometry * convertGeometry(const QVariantMap &geometry, const QString &esriGeometryType, bool hasM, bool hasZ, QgsCoordinateReferenceSystem *crs=nullptr)
Converts an ESRI REST geometry JSON definition to a QgsAbstractGeometry.
static QVariant variantToAttributeValue(const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context)
Converts a variant to a REST attribute value.
static QVariantMap featureToJson(const QgsFeature &feature, const QgsArcGisRestContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), QgsArcGisRestUtils::FeatureToJsonFlags flags=QgsArcGisRestUtils::FeatureToJsonFlags(static_cast< int >(QgsArcGisRestUtils::FeatureToJsonFlag::IncludeGeometry)|static_cast< int >(QgsArcGisRestUtils::FeatureToJsonFlag::IncludeNonObjectIdAttributes)))
Flags which control the behavior of converting features to JSON.
static Qt::PenStyle convertLineStyle(const QString &style)
Converts an ESRI line style to a Qt pen style.
@ IncludeGeometry
Whether to include the geometry definition.
@ IncludeNonObjectIdAttributes
Whether to include any non-objectId attributes.
static QgsFeatureRenderer * convertRenderer(const QVariantMap &rendererData)
Converts renderer JSON data to an equivalent QgsFeatureRenderer.
static Qt::BrushStyle convertFillStyle(const QString &style)
Converts an ESRI fill style to a Qt brush style.
static QVariant::Type convertFieldType(const QString &type)
Converts an ESRI REST field type to a QVariant type.
static QVariantMap crsToJson(const QgsCoordinateReferenceSystem &crs)
Converts a crs to an ArcGIS REST JSON representation.
static QgsAbstractVectorLayerLabeling * convertLabeling(const QVariantList &data)
Converts labeling JSON data to an equivalent QGIS vector labeling.
static QColor convertColor(const QVariant &data)
Converts ESRI JSON color data to a QColor object.
static QgsRectangle convertRectangle(const QVariant &value)
Converts a rectangle value to a QgsRectangle.
Circular string geometry type.
QgsPoint startPoint() const override
Returns the starting point of the curve.
bool isEmpty() const override
Returns true if the geometry is empty.
int numPoints() const override
Returns the number of points in the curve.
QgsPoint pointN(int i) const
Returns the point at index i within the circular string.
Compound curve geometry type.
QgsCompoundCurve * reversed() const override
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
int nCurves() const
Returns the number of curves in the geometry.
const QgsCurve * curveAt(int i) const
Returns the curve at the specified index.
QgsPoint startPoint() const override
Returns the starting point of the curve.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool createFromWkt(const QString &wkt)
Sets this CRS using a WKT definition.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
QString toWkt(Qgis::CrsWktVariant variant=Qgis::CrsWktVariant::Wkt1Gdal, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Curve polygon geometry type.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
Abstract base class for curved geometry type.
Qgis::AngularDirection orientation() const
Returns the curve's orientation, e.g.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
virtual QgsPoint endPoint() const =0
Returns the end point of the curve.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool isValid() const
Checks if this expression is valid.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
@ ConstraintNotNull
Field may not be null.
Encapsulate a field in an attribute table or data source.
QgsFieldConstraints constraints
Container of fields for a vector layer.
int numGeometries() const
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
void setPlacementFlags(Qgis::LabelLinePlacementFlags flags)
Returns the line placement flags, which dictate how line labels can be placed above or below the line...
Line string geometry type, with support for z-dimension and m-values.
const double * yData() const
Returns a const pointer to the y vertex data.
const double * xData() const
Returns a const pointer to the x vertex data.
const double * zData() const
Returns a const pointer to the z vertex data, or nullptr if the linestring does not have z values.
int numPoints() const override
Returns the number of points in the curve.
QgsLineString * reversed() const override
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
const double * mData() const
Returns a const pointer to the m vertex data, or nullptr if the linestring does not have m values.
Multi curve geometry collection.
QgsCurve * curveN(int index)
Returns the curve with the specified index.
Multi line string geometry collection.
QgsLineString * lineStringN(int index)
Returns the line string with the specified index.
Multi point geometry collection.
QgsPoint * pointN(int index)
Returns the point with the specified index.
Multi polygon geometry collection.
QgsPolygon * polygonN(int index)
Returns the polygon with the specified index.
Multi surface geometry collection.
Contains settings for how a map layer will be labeled.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
Qgis::LabelPlacement placement
Label placement mode.
Qgis::LabelQuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm'
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
QString fieldName
Name of field (or an expression) to use for label text.
Point geometry type, with support for z-dimension and m-values.
void clear() override
Clears the geometry, ie reset it to a null geometry.
bool isEmpty() const override
Returns true if the geometry is empty.
A rectangle specified with double values.
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
A child rule for QgsRuleBasedLabeling.
void setActive(bool state)
Sets if this rule is active.
void appendChild(QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
Rule based labeling for a vector layer.
Abstract base class for all rendered symbols.
Container for settings relating to a text buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
void setSize(double size)
Sets the size of the buffer.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setSize(double size)
Sets the size for rendered text.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the size of rendered text.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static Qgis::WkbType zmType(Qgis::WkbType type, bool hasZ, bool hasM)
Returns the modified input geometry type according to hasZ / hasM.
static bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QList< QgsRendererCategory > QgsCategoryList
#define QgsDebugError(str)
QList< QgsSymbolLayer * > QgsSymbolLayerList
const QgsCoordinateReferenceSystem & crs