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 );
586 lineLayer->setWidthUnit( Qgis::RenderUnit::Points );
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 );
606 fillLayer->setStrokeWidthUnit( Qgis::RenderUnit::Points );
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 );
640 fillLayer->setWidthUnit( Qgis::RenderUnit::Points );
641 fillLayer->setOffset( QPointF( xOffset, yOffset ) );
642 fillLayer->setOffsetUnit( Qgis::RenderUnit::Points );
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 );
651 lineLayer->setWidthUnit( Qgis::RenderUnit::Points );
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 );
700 markerLayer->setSizeUnit( Qgis::RenderUnit::Points );
701 markerLayer->setStrokeWidthUnit( Qgis::RenderUnit::Points );
702 markerLayer->setStrokeStyle( penStyle );
703 markerLayer->setStrokeWidth( penWidthInPoints );
704 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
705 markerLayer->setOffsetUnit( Qgis::RenderUnit::Points );
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 );
737 markerLayer->setSizeUnit( Qgis::RenderUnit::Points );
740 if ( !
qgsDoubleNear(
static_cast< double >( heightInPixels ) / widthInPixels, markerLayer->defaultAspectRatio() ) )
741 markerLayer->setFixedAspectRatio(
static_cast< double >( heightInPixels ) / widthInPixels );
743 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
744 markerLayer->setOffsetUnit( Qgis::RenderUnit::Points );
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" ) )
771 settings->
quadOffset = Qgis::LabelQuadrantPosition::Above;
773 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowCenter" ) )
776 settings->
quadOffset = Qgis::LabelQuadrantPosition::Below;
778 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterCenter" ) )
781 settings->
quadOffset = Qgis::LabelQuadrantPosition::Over;
783 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveLeft" ) )
786 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveLeft;
788 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowLeft" ) )
791 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowLeft;
793 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterLeft" ) )
796 settings->
quadOffset = Qgis::LabelQuadrantPosition::Left;
798 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveRight" ) )
801 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveRight;
803 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowRight" ) )
806 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowRight;
808 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterRight" ) )
811 settings->
quadOffset = Qgis::LabelQuadrantPosition::Right;
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 QgsDebugMsg( QStringLiteral(
"Invalid value %1 for datetime" ).arg( value.toString() ) );
1060 return QVariantMap();
1067 return QVariantMap();
1070 res = pointToJson( qgsgeometry_cast< const QgsPoint * >( geom ) );
1074 res = lineStringToJson( qgsgeometry_cast< const QgsLineString * >( geom ) );
1079 res = curveToJson( qgsgeometry_cast< const QgsCurve * >( geom ) );
1083 res = polygonToJson( qgsgeometry_cast< const QgsPolygon * >( geom ) );
1087 res = multiPointToJson( qgsgeometry_cast< const QgsMultiPoint * >( geom ) );
1091 res = multiLineStringToJson( qgsgeometry_cast< const QgsMultiLineString * >( geom ) );
1095 res = multiCurveToJson( qgsgeometry_cast< const QgsMultiCurve * >( geom ) );
1099 res = multiPolygonToJson( qgsgeometry_cast< const QgsMultiPolygon * >( geom ) );
1103 res = curvePolygonToJson( qgsgeometry_cast< const QgsCurvePolygon * >( geom ) );
1107 res = multiSurfaceToJson( qgsgeometry_cast< const QgsMultiSurface * >( geom ) );
1111 return QVariantMap();
1114 return QVariantMap();
1117 return QVariantMap();
1124 res.insert( QStringLiteral(
"spatialReference" ),
crsToJson(
crs ) );
1130QVariantMap QgsArcGisRestUtils::pointToJson(
const QgsPoint *point )
1134 data[QStringLiteral(
"x" )] = QStringLiteral(
"NaN" );
1137 data[QStringLiteral(
"x" )] = point->
x();
1138 data[QStringLiteral(
"y" )] = point->
y();
1140 if ( point->
is3D() )
1141 data[QStringLiteral(
"z" )] = !std::isnan( point->
z() ) ? QVariant( point->
z() ) : QVariant( QStringLiteral(
"NaN" ) );
1144 data[QStringLiteral(
"m" )] = !std::isnan( point->
m() ) ? QVariant( point->
m() ) : QVariant( QStringLiteral(
"NaN" ) );
1149QVariantMap QgsArcGisRestUtils::multiPointToJson(
const QgsMultiPoint *multiPoint )
1152 const bool hasZ = multiPoint->
is3D();
1153 const bool hasM = multiPoint->
isMeasure();
1154 data[QStringLiteral(
"hasM" )] = hasM;
1155 data[QStringLiteral(
"hasZ" )] = hasZ;
1157 QVariantList pointsList;
1159 pointsList.reserve( size );
1161 QVariantList pointList;
1162 for (
int i = 0; i < size; ++i )
1167 pointList.append( point->
x() );
1168 pointList.append( point->
y() );
1170 pointList.append( point->
z() );
1171 if ( hasM && !std::isnan( point->
m() ) )
1172 pointList.append( point->
m() );
1174 pointsList.push_back( pointList );
1177 data[QStringLiteral(
"points" )] = pointsList;
1181QVariantList QgsArcGisRestUtils::lineStringToJsonPath(
const QgsLineString *line )
1183 const bool hasZ = line->
is3D();
1186 QVariantList pointsList;
1188 pointsList.reserve( size );
1190 QVariantList pointList;
1191 const double *xData = line->
xData();
1192 const double *yData = line->
yData();
1193 const double *zData = hasZ ? line->
zData() :
nullptr;
1194 const double *mData = hasM ? line->
mData() :
nullptr;
1196 for (
int i = 0; i < size; ++i )
1199 pointList.append( *xData++ );
1200 pointList.append( *yData++ );
1203 pointList.append( *zData++ );
1205 if ( hasM && !std::isnan( *mData ) )
1206 pointList.append( *mData );
1210 pointsList.push_back( pointList );
1215QVariantList QgsArcGisRestUtils::curveToJsonCurve(
const QgsCurve *curve,
bool includeStart )
1217 const bool hasZ = curve->
is3D();
1220 auto pointToList = [hasZ, hasM](
const QgsPoint & point ) -> QVariantList
1222 QVariantList pointList;
1224 pointList.append( point.
x() );
1225 pointList.append( point.
y() );
1228 pointList.append( point.
z() );
1230 if ( hasM && !std::isnan( point.
m() ) )
1231 pointList.append( point.
m() );
1241 QVariantList part = lineStringToJsonPath( qgsgeometry_cast< const QgsLineString *>( curve ) );
1242 if ( !part.isEmpty() && !includeStart )
1250 const QgsCircularString *circularString = qgsgeometry_cast<const QgsCircularString * >( curve );
1251 if ( includeStart && !circularString->
isEmpty() )
1253 res.push_back( pointToList( circularString->
startPoint() ) );
1256 const int size = circularString->
numPoints();
1257 for (
int i = 1; i + 1 < size; i += 2 )
1260 QVariantMap curvePart;
1261 QVariantList curveList;
1262 curveList.push_back( pointToList( circularString->
pointN( i + 1 ) ) );
1264 curveList.push_back( pointToList( circularString->
pointN( i ) ) );
1266 curvePart.insert( QStringLiteral(
"c" ), curveList );
1267 res.push_back( curvePart );
1274 const QgsCompoundCurve *compoundCurve = qgsgeometry_cast<const QgsCompoundCurve * >( curve );
1276 const int size = compoundCurve->
nCurves();
1277 for (
int i = 0; i < size; ++i )
1280 res.append( curveToJsonCurve( subCurve, i == 0 ) );
1291QVariantMap QgsArcGisRestUtils::lineStringToJson(
const QgsLineString *line )
1294 const bool hasZ = line->
is3D();
1296 data[QStringLiteral(
"hasM" )] = hasM;
1297 data[QStringLiteral(
"hasZ" )] = hasZ;
1299 const QVariantList pointsList = lineStringToJsonPath( line );
1301 QVariantList pointsData = QVariantList();
1302 pointsData.push_back( pointsList );
1303 data[QStringLiteral(
"paths" )] = pointsData;
1308QVariantMap QgsArcGisRestUtils::curveToJson(
const QgsCurve *curve )
1311 const bool hasZ = curve->
is3D();
1313 data[QStringLiteral(
"hasM" )] = hasM;
1314 data[QStringLiteral(
"hasZ" )] = hasZ;
1316 const QVariantList curveList = curveToJsonCurve( curve,
true );
1318 QVariantList curveData = QVariantList();
1319 curveData.push_back( curveList );
1320 data[QStringLiteral(
"curvePaths" )] = curveData;
1325QVariantMap QgsArcGisRestUtils::multiLineStringToJson(
const QgsMultiLineString *multiLine )
1328 const bool hasZ = multiLine->
is3D();
1329 const bool hasM = multiLine->
isMeasure();
1330 data[QStringLiteral(
"hasM" )] = hasM;
1331 data[QStringLiteral(
"hasZ" )] = hasZ;
1335 paths.reserve( size );
1336 for (
int i = 0; i < size; ++i )
1339 paths.push_back( lineStringToJsonPath( line ) );
1342 data[QStringLiteral(
"paths" )] = paths;
1346QVariantMap QgsArcGisRestUtils::multiCurveToJson(
const QgsMultiCurve *multiCurve )
1349 const bool hasZ = multiCurve->
is3D();
1350 const bool hasM = multiCurve->
isMeasure();
1351 data[QStringLiteral(
"hasM" )] = hasM;
1352 data[QStringLiteral(
"hasZ" )] = hasZ;
1356 paths.reserve( size );
1357 for (
int i = 0; i < size; ++i )
1360 paths.push_back( curveToJsonCurve( curve,
true ) );
1363 data[QStringLiteral(
"curvePaths" )] = paths;
1367QVariantList QgsArcGisRestUtils::polygonToJsonRings(
const QgsPolygon *polygon )
1371 rings.reserve( numInteriorRings + 1 );
1379 rings.push_back( lineStringToJsonPath( exterior ) );
1384 std::unique_ptr< QgsLineString > reversed( exterior->
reversed() );
1385 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1391 for (
int i = 0; i < numInteriorRings; ++i )
1398 rings.push_back( lineStringToJsonPath( ring ) );
1403 std::unique_ptr< QgsLineString > reversed( ring->
reversed() );
1404 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1412QVariantList QgsArcGisRestUtils::curvePolygonToJsonRings(
const QgsCurvePolygon *polygon )
1416 rings.reserve( numInteriorRings + 1 );
1418 if (
const QgsCurve *exterior = qgsgeometry_cast< const QgsCurve * >( polygon->
exteriorRing() ) )
1424 rings.push_back( curveToJsonCurve( exterior,
true ) );
1429 std::unique_ptr< QgsCurve > reversed( exterior->
reversed() );
1430 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1436 for (
int i = 0; i < numInteriorRings; ++i )
1443 rings.push_back( curveToJsonCurve( ring,
true ) );
1448 std::unique_ptr< QgsCurve > reversed( ring->
reversed() );
1449 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1457QVariantMap QgsArcGisRestUtils::polygonToJson(
const QgsPolygon *polygon )
1460 const bool hasZ = polygon->
is3D();
1462 data[QStringLiteral(
"hasM" )] = hasM;
1463 data[QStringLiteral(
"hasZ" )] = hasZ;
1464 data[QStringLiteral(
"rings" )] = polygonToJsonRings( polygon );
1468QVariantMap QgsArcGisRestUtils::curvePolygonToJson(
const QgsCurvePolygon *polygon )
1471 const bool hasZ = polygon->
is3D();
1473 data[QStringLiteral(
"hasM" )] = hasM;
1474 data[QStringLiteral(
"hasZ" )] = hasZ;
1475 data[QStringLiteral(
"curveRings" )] = curvePolygonToJsonRings( polygon );
1479QVariantMap QgsArcGisRestUtils::multiPolygonToJson(
const QgsMultiPolygon *multiPolygon )
1482 const bool hasZ = multiPolygon->
is3D();
1483 const bool hasM = multiPolygon->
isMeasure();
1484 data[QStringLiteral(
"hasM" )] = hasM;
1485 data[QStringLiteral(
"hasZ" )] = hasZ;
1489 for (
int i = 0; i < size; ++i )
1492 rings.append( polygonToJsonRings( polygon ) );
1495 data[QStringLiteral(
"rings" )] = rings;
1499QVariantMap QgsArcGisRestUtils::multiSurfaceToJson(
const QgsMultiSurface *multiSurface )
1502 const bool hasZ = multiSurface->
is3D();
1503 const bool hasM = multiSurface->
isMeasure();
1504 data[QStringLiteral(
"hasM" )] = hasM;
1505 data[QStringLiteral(
"hasZ" )] = hasZ;
1509 for (
int i = 0; i < size; ++i )
1515 rings.append( curvePolygonToJsonRings( polygon ) );
1518 data[QStringLiteral(
"curveRings" )] = rings;
1529 if ( !authid.isEmpty() )
1531 const thread_local QRegularExpression rxAuthid( QStringLiteral(
"(\\w+):(\\d+)" ) );
1532 const QRegularExpressionMatch match = rxAuthid.match( authid );
1533 if ( match.hasMatch()
1535 ( match.captured( 1 ).compare( QLatin1String(
"EPSG" ), Qt::CaseInsensitive ) == 0 )
1536 || ( match.captured( 1 ).compare( QLatin1String(
"ESRI" ), Qt::CaseInsensitive ) == 0 )
1540 const QString wkid = match.captured( 2 );
1541 res.insert( QStringLiteral(
"wkid" ), wkid );
1560 QVariantMap attributes;
1567 if ( !attributes.isEmpty() )
1569 res.insert( QStringLiteral(
"attributes" ), attributes );
1579 switch ( expectedType )
1581 case QVariant::String:
1582 return QString( QUrl::toPercentEncoding( variant.toString() ) );
1584 case QVariant::DateTime:
1585 case QVariant::Date:
1587 switch ( variant.type() )
1589 case QVariant::DateTime:
1590 return variant.toDateTime().toMSecsSinceEpoch();
1592 case QVariant::Date:
1594 if ( context.
timeZone().isValid() )
1595 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ), context.
timeZone() ).toMSecsSinceEpoch();
1597 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ) ).toMSecsSinceEpoch();
1612 res.insert( QStringLiteral(
"name" ),
field.
name() );
1617 case QVariant::LongLong:
1618 fieldType = QStringLiteral(
"esriFieldTypeInteger" );
1622 fieldType = QStringLiteral(
"esriFieldTypeSmallInteger" );
1625 case QVariant::Double:
1626 fieldType = QStringLiteral(
"esriFieldTypeDouble" );
1629 case QVariant::String:
1630 fieldType = QStringLiteral(
"esriFieldTypeString" );
1633 case QVariant::DateTime:
1634 case QVariant::Date:
1635 fieldType = QStringLiteral(
"esriFieldTypeDate" );
1638 case QVariant::ByteArray:
1639 fieldType = QStringLiteral(
"esriFieldTypeBlob" );
1644 fieldType = QStringLiteral(
"esriFieldTypeString" );
1647 res.insert( QStringLiteral(
"type" ), fieldType );
1650 res.insert( QStringLiteral(
"alias" ),
field.
alias() );
1654 res.insert( QStringLiteral(
"nullable" ), !notNullable );
1657 res.insert( QStringLiteral(
"editable" ),
true );
1664 if ( type.compare( QLatin1String(
"FeatureServer" ), Qt::CaseInsensitive ) == 0 )
1665 return Qgis::ArcGisRestServiceType::FeatureServer;
1666 else if ( type.compare( QLatin1String(
"MapServer" ), Qt::CaseInsensitive ) == 0 )
1667 return Qgis::ArcGisRestServiceType::MapServer;
1668 else if ( type.compare( QLatin1String(
"ImageServer" ), Qt::CaseInsensitive ) == 0 )
1669 return Qgis::ArcGisRestServiceType::ImageServer;
1670 else if ( type.compare( QLatin1String(
"GlobeServer" ), Qt::CaseInsensitive ) == 0 )
1672 else if ( type.compare( QLatin1String(
"GPServer" ), Qt::CaseInsensitive ) == 0 )
1674 else if ( type.compare( QLatin1String(
"GeocodeServer" ), Qt::CaseInsensitive ) == 0 )
@ 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.
MarkerShape
Marker shapes.
@ Cross2
Rotated cross (lines only), 'x' shape.
@ Cross
Cross (lines only)
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.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const SIP_HOLDGIL
Returns a reference to the simplest lossless representation of this geometry, e.g.
Qgis::WkbType wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
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.
Circular string geometry type.
QgsPoint pointN(int i) const SIP_HOLDGIL
Returns the point at index i within the circular string.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
QgsPoint startPoint() const override SIP_HOLDGIL
Returns the starting point of the curve.
Compound curve geometry type.
QgsCompoundCurve * reversed() const override
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
const QgsCurve * curveAt(int i) const SIP_HOLDGIL
Returns the curve at the specified index.
QgsPoint startPoint() const override SIP_HOLDGIL
Returns the starting point of the curve.
int nCurves() const SIP_HOLDGIL
Returns the number of curves in the geometry.
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.
@ WKT2_2019_SIMPLIFIED
WKT2_2019 with the simplification rule of WKT2_SIMPLIFIED.
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Curve polygon geometry type.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
const QgsCurve * exteriorRing() const SIP_HOLDGIL
Returns the curve polygon's exterior ring.
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)
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with the curve polygon.
Abstract base class for curved geometry type.
Qgis::AngularDirection orientation() const
Returns the curve's orientation, e.g.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
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.
Q_GADGET Constraints constraints
Encapsulate a field in an attribute table or data source.
QgsFieldConstraints constraints
Container of fields for a vector layer.
int numGeometries() const SIP_HOLDGIL
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 SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
void setPlacementFlags(QgsLabeling::LinePlacementFlags 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 SIP_HOLDGIL
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 SIP_HOLDGIL
Returns true if the geometry is empty.
A rectangle specified with double values.
bool intersects(const QgsRectangle &rect) const SIP_HOLDGIL
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.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
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)
Returns true if the specified variant should be considered a NULL value.
static bool hasZ(Qgis::WkbType type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
static Qgis::WkbType flatType(Qgis::WkbType type) SIP_HOLDGIL
Returns the flat type for a WKB type.
static Qgis::WkbType zmType(Qgis::WkbType type, bool hasZ, bool hasM) SIP_HOLDGIL
Returns the modified input geometry type according to hasZ / hasM.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QList< QgsRendererCategory > QgsCategoryList
QList< QgsSymbolLayer * > QgsSymbolLayerList
const QgsCoordinateReferenceSystem & crs