45#include <QRegularExpression>
49 if ( esriFieldType == QLatin1String(
"esriFieldTypeInteger" ) )
50 return QVariant::LongLong;
51 if ( esriFieldType == QLatin1String(
"esriFieldTypeSmallInteger" ) )
53 if ( esriFieldType == QLatin1String(
"esriFieldTypeDouble" ) )
54 return QVariant::Double;
55 if ( esriFieldType == QLatin1String(
"esriFieldTypeSingle" ) )
56 return QVariant::Double;
57 if ( esriFieldType == QLatin1String(
"esriFieldTypeString" ) )
58 return QVariant::String;
59 if ( esriFieldType == QLatin1String(
"esriFieldTypeDate" ) )
60 return QVariant::DateTime;
61 if ( esriFieldType == QLatin1String(
"esriFieldTypeGeometry" ) )
62 return QVariant::Invalid;
63 if ( esriFieldType == QLatin1String(
"esriFieldTypeOID" ) )
64 return QVariant::LongLong;
65 if ( esriFieldType == QLatin1String(
"esriFieldTypeBlob" ) )
66 return QVariant::ByteArray;
67 if ( esriFieldType == QLatin1String(
"esriFieldTypeGlobalID" ) )
68 return QVariant::String;
69 if ( esriFieldType == QLatin1String(
"esriFieldTypeRaster" ) )
70 return QVariant::ByteArray;
71 if ( esriFieldType == QLatin1String(
"esriFieldTypeGUID" ) )
72 return QVariant::String;
73 if ( esriFieldType == QLatin1String(
"esriFieldTypeXML" ) )
74 return QVariant::String;
75 return QVariant::Invalid;
81 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
83 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
85 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
87 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
89 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
91 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
111std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertPoint(
const QVariantList &coordList,
QgsWkbTypes::Type pointType )
113 int nCoords = coordList.size();
116 bool xok =
false, yok =
false;
117 const double x = coordList[0].toDouble( &xok );
118 const double y = coordList[1].toDouble( &yok );
122 const double z = hasZ && nCoords >= 3 ? coordList[2].toDouble() : std::numeric_limits< double >::quiet_NaN();
125 const double m =
QgsWkbTypes::hasM( pointType ) && ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN();
126 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
129std::unique_ptr< QgsCircularString > QgsArcGisRestUtils::convertCircularString(
const QVariantMap &curveData,
QgsWkbTypes::Type pointType,
const QgsPoint &startPoint )
131 const QVariantList coordsList = curveData[QStringLiteral(
"c" )].toList();
132 if ( coordsList.isEmpty() )
134 const int coordsListSize = coordsList.size();
136 QVector<QgsPoint> points;
137 points.reserve( coordsListSize + 1 );
138 points.append( startPoint );
140 for (
int i = 0; i < coordsListSize - 1; )
144 std::unique_ptr< QgsPoint > endPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
148 std::unique_ptr< QgsPoint > interiorPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
149 if ( !interiorPoint )
152 points << *interiorPoint;
155 std::unique_ptr< QgsCircularString > curve = std::make_unique< QgsCircularString> ();
156 curve->setPoints( points );
160std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::convertCompoundCurve(
const QVariantList &curvesList,
QgsWkbTypes::Type pointType )
163 std::unique_ptr< QgsCompoundCurve > compoundCurve = std::make_unique< QgsCompoundCurve >();
165 QVector< double > lineX;
166 QVector< double > lineY;
167 QVector< double > lineZ;
168 QVector< double > lineM;
169 int maxCurveListSize = curvesList.size();
170 lineX.resize( maxCurveListSize );
171 lineY.resize( maxCurveListSize );
175 lineZ.resize( maxCurveListSize );
178 lineM.resize( maxCurveListSize );
180 double *outLineX = lineX.data();
181 double *outLineY = lineY.data();
182 double *outLineZ = lineZ.data();
183 double *outLineM = lineM.data();
184 int actualLineSize = 0;
189 int curveListIndex = 0;
190 for (
const QVariant &curveData : curvesList )
192 if ( curveData.type() == QVariant::List )
194 const QVariantList coordList = curveData.toList();
195 const int nCoords = coordList.size();
199 const double x = coordList[0].toDouble( &xok );
200 const double y = coordList[1].toDouble( &yok );
209 *outLineZ++ = nCoords >= 3 ? coordList[2].toDouble() : std::numeric_limits< double >::quiet_NaN();
215 *outLineM++ = ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN();
218 else if ( curveData.type() == QVariant::Map )
222 if ( actualLineSize > 0 )
224 lastLineStringPoint =
QgsPoint( lineX.at( actualLineSize - 1 ),
225 lineY.at( actualLineSize - 1 ),
226 hasZ ? lineZ.at( actualLineSize - 1 ) : std::numeric_limits< double >::quiet_NaN(),
227 hasM ? lineM.at( actualLineSize - 1 ) : std::numeric_limits< double >::quiet_NaN() );
229 std::unique_ptr< QgsCircularString > circularString( convertCircularString( curveData.toMap(), pointType, lastLineStringPoint ) );
230 if ( !circularString )
235 if ( actualLineSize > 0 )
237 lineX.resize( actualLineSize );
238 lineY.resize( actualLineSize );
240 lineZ.resize( actualLineSize );
242 lineM.resize( actualLineSize );
244 compoundCurve->addCurve(
new QgsLineString( lineX, lineY, lineZ, lineM ) );
245 lineX.resize( maxCurveListSize - curveListIndex );
246 lineY.resize( maxCurveListSize - curveListIndex );
248 lineZ.resize( maxCurveListSize - curveListIndex );
250 lineM.resize( maxCurveListSize - curveListIndex );
251 outLineX = lineX.data();
252 outLineY = lineY.data();
253 outLineZ = lineZ.data();
254 outLineM = lineM.data();
258 if ( compoundCurve->curveAt( compoundCurve->nCurves() - 1 )->nCoordinates() < 2 )
259 compoundCurve->removeCurve( compoundCurve->nCurves() - 1 );
261 const QgsPoint endPointCircularString = circularString->endPoint();
262 compoundCurve->addCurve( circularString.release() );
266 *outLineX++ = endPointCircularString.
x();
267 *outLineY++ = endPointCircularString.
y();
269 *outLineZ++ = endPointCircularString.
z();
271 *outLineM++ = endPointCircularString.
m();
276 if ( actualLineSize == 1 && compoundCurve->nCurves() > 0 )
278 const QgsCurve *finalCurve = compoundCurve->curveAt( compoundCurve->nCurves() - 1 );
282 && ( !hasZ ||
qgsDoubleNear( finalCurveEndPoint.
z(), lineZ.at( 0 ) ) )
283 && ( !hasM ||
qgsDoubleNear( finalCurveEndPoint.
m(), lineM.at( 0 ) ) ) )
289 if ( actualLineSize > 0 )
291 lineX.resize( actualLineSize );
292 lineY.resize( actualLineSize );
294 lineZ.resize( actualLineSize );
296 lineM.resize( actualLineSize );
297 compoundCurve->addCurve(
new QgsLineString( lineX, lineY, lineZ, lineM ) );
300 return compoundCurve;
303std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertGeometryPoint(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
306 bool xok =
false, yok =
false;
307 double x = geometryData[QStringLiteral(
"x" )].toDouble( &xok );
308 double y = geometryData[QStringLiteral(
"y" )].toDouble( &yok );
311 double z = geometryData[QStringLiteral(
"z" )].toDouble();
312 double m = geometryData[QStringLiteral(
"m" )].toDouble();
313 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
316std::unique_ptr< QgsMultiPoint > QgsArcGisRestUtils::convertMultiPoint(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
319 const QVariantList coordsList = geometryData[QStringLiteral(
"points" )].toList();
321 std::unique_ptr< QgsMultiPoint > multiPoint = std::make_unique< QgsMultiPoint >();
322 multiPoint->reserve( coordsList.size() );
323 for (
const QVariant &coordData : coordsList )
325 const QVariantList coordList = coordData.toList();
326 std::unique_ptr< QgsPoint > p = convertPoint( coordList, pointType );
331 multiPoint->addGeometry( p.release() );
336 std::unique_ptr< QgsPoint > p = convertGeometryPoint( geometryData, pointType );
338 multiPoint->addGeometry( p.release() );
340 if ( multiPoint->numGeometries() == 0 )
348std::unique_ptr< QgsMultiCurve > QgsArcGisRestUtils::convertGeometryPolyline(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
351 QVariantList pathsList;
352 if ( geometryData[QStringLiteral(
"paths" )].isValid() )
353 pathsList = geometryData[QStringLiteral(
"paths" )].toList();
354 else if ( geometryData[QStringLiteral(
"curvePaths" )].isValid() )
355 pathsList = geometryData[QStringLiteral(
"curvePaths" )].toList();
356 if ( pathsList.isEmpty() )
358 std::unique_ptr< QgsMultiCurve > multiCurve = std::make_unique< QgsMultiCurve >();
359 multiCurve->reserve( pathsList.size() );
360 for (
const QVariant &pathData : std::as_const( pathsList ) )
362 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( pathData.toList(), pointType );
367 multiCurve->addGeometry( curve.release() );
372std::unique_ptr< QgsMultiSurface > QgsArcGisRestUtils::convertGeometryPolygon(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
375 QVariantList ringsList;
376 if ( geometryData[QStringLiteral(
"rings" )].isValid() )
377 ringsList = geometryData[QStringLiteral(
"rings" )].toList();
378 else if ( geometryData[QStringLiteral(
"ringPaths" )].isValid() )
379 ringsList = geometryData[QStringLiteral(
"ringPaths" )].toList();
380 if ( ringsList.isEmpty() )
383 QList< QgsCompoundCurve * > curves;
384 for (
int i = 0, n = ringsList.size(); i < n; ++i )
386 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( ringsList[i].toList(), pointType );
391 curves.append( curve.release() );
393 if ( curves.count() == 0 )
396 std::unique_ptr< QgsMultiSurface > result = std::make_unique< QgsMultiSurface >();
397 if ( curves.count() == 1 )
400 std::unique_ptr< QgsCurvePolygon > newPolygon = std::make_unique< QgsCurvePolygon >();
401 newPolygon->setExteriorRing( curves.takeAt( 0 ) );
402 result->addGeometry( newPolygon.release() );
406 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 ); } );
407 result->reserve( curves.size() );
408 while ( !curves.isEmpty() )
414 engine->prepareGeometry();
416 QMutableListIterator< QgsCompoundCurve * > it( curves );
417 while ( it.hasNext() )
424 if ( engine->contains( &point ) )
429 engine->prepareGeometry();
433 result->addGeometry( newPolygon );
435 if ( result->numGeometries() == 0 )
441std::unique_ptr< QgsPolygon > QgsArcGisRestUtils::convertEnvelope(
const QVariantMap &geometryData )
444 bool xminOk =
false, yminOk =
false, xmaxOk =
false, ymaxOk =
false;
445 double xmin = geometryData[QStringLiteral(
"xmin" )].toDouble( &xminOk );
446 double ymin = geometryData[QStringLiteral(
"ymin" )].toDouble( &yminOk );
447 double xmax = geometryData[QStringLiteral(
"xmax" )].toDouble( &xmaxOk );
448 double ymax = geometryData[QStringLiteral(
"ymax" )].toDouble( &ymaxOk );
449 if ( !xminOk || !yminOk || !xmaxOk || !ymaxOk )
451 std::unique_ptr< QgsLineString > ext = std::make_unique< QgsLineString> ();
452 ext->addVertex(
QgsPoint( xmin, ymin ) );
453 ext->addVertex(
QgsPoint( xmax, ymin ) );
454 ext->addVertex(
QgsPoint( xmax, ymax ) );
455 ext->addVertex(
QgsPoint( xmin, ymax ) );
456 ext->addVertex(
QgsPoint( xmin, ymin ) );
457 std::unique_ptr< QgsPolygon > poly = std::make_unique< QgsPolygon >();
458 poly->setExteriorRing( ext.release() );
471 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
473 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
474 return convertGeometryPoint( geometryData, pointType ).release();
475 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
476 return convertMultiPoint( geometryData, pointType ).release();
477 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
478 return convertGeometryPolyline( geometryData, pointType ).release();
479 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
480 return convertGeometryPolygon( geometryData, pointType ).release();
481 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
482 return convertEnvelope( geometryData ).release();
505 QString spatialReference = spatialReferenceMap[QStringLiteral(
"latestWkid" )].toString();
506 if ( spatialReference.isEmpty() )
507 spatialReference = spatialReferenceMap[QStringLiteral(
"wkid" )].toString();
510 if ( !spatialReference.isEmpty() )
519 else if ( !spatialReferenceMap[QStringLiteral(
"wkt" )].toString().isEmpty() )
522 crs.
createFromWkt( spatialReferenceMap[QStringLiteral(
"wkt" )].toString() );
537 const QString type = symbolData.value( QStringLiteral(
"type" ) ).toString();
538 if ( type == QLatin1String(
"esriSMS" ) )
541 return parseEsriMarkerSymbolJson( symbolData ).release();
543 else if ( type == QLatin1String(
"esriSLS" ) )
546 return parseEsriLineSymbolJson( symbolData ).release();
548 else if ( type == QLatin1String(
"esriSFS" ) )
551 return parseEsriFillSymbolJson( symbolData ).release();
553 else if ( type == QLatin1String(
"esriPFS" ) )
555 return parseEsriPictureFillSymbolJson( symbolData ).release();
557 else if ( type == QLatin1String(
"esriPMS" ) )
560 return parseEsriPictureMarkerSymbolJson( symbolData ).release();
562 else if ( type == QLatin1String(
"esriTS" ) )
570std::unique_ptr<QgsLineSymbol> QgsArcGisRestUtils::parseEsriLineSymbolJson(
const QVariantMap &symbolData )
572 QColor lineColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
573 if ( !lineColor.isValid() )
577 double widthInPoints = symbolData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
582 Qt::PenStyle penStyle =
convertLineStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
583 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, widthInPoints, penStyle );
585 layers.append( lineLayer.release() );
587 std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >( layers );
591std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriFillSymbolJson(
const QVariantMap &symbolData )
593 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
594 Qt::BrushStyle brushStyle =
convertFillStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
596 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
597 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
598 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
600 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
603 std::unique_ptr< QgsSimpleFillSymbolLayer > fillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( fillColor, brushStyle, lineColor, penStyle, penWidthInPoints );
605 layers.append( fillLayer.release() );
607 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
611std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriPictureFillSymbolJson(
const QVariantMap &symbolData )
615 double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
619 const double xScale = symbolData.value( QStringLiteral(
"xscale" ) ).toDouble( &ok );
621 widthInPixels *= xScale;
623 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
628 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
629 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
631 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
632 symbolPath.prepend( QLatin1String(
"base64:" ) );
635 std::unique_ptr< QgsRasterFillSymbolLayer > fillLayer = std::make_unique< QgsRasterFillSymbolLayer >( symbolPath );
636 fillLayer->setWidth( widthInPixels );
637 fillLayer->setAngle( angleCW );
639 fillLayer->setOffset( QPointF( xOffset, yOffset ) );
641 layers.append( fillLayer.release() );
643 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
644 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
645 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
646 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
648 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, penWidthInPoints, penStyle );
650 layers.append( lineLayer.release() );
652 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
656Qgis::MarkerShape QgsArcGisRestUtils::parseEsriMarkerShape(
const QString &style )
658 if ( style == QLatin1String(
"esriSMSCircle" ) )
660 else if ( style == QLatin1String(
"esriSMSCross" ) )
662 else if ( style == QLatin1String(
"esriSMSDiamond" ) )
664 else if ( style == QLatin1String(
"esriSMSSquare" ) )
666 else if ( style == QLatin1String(
"esriSMSX" ) )
668 else if ( style == QLatin1String(
"esriSMSTriangle" ) )
674std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriMarkerSymbolJson(
const QVariantMap &symbolData )
676 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
678 const double sizeInPoints = symbolData.value( QStringLiteral(
"size" ) ).toDouble( &ok );
681 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
686 Qgis::MarkerShape shape = parseEsriMarkerShape( symbolData.value( QStringLiteral(
"style" ) ).toString() );
688 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
689 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
691 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
692 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
693 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
694 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
697 std::unique_ptr< QgsSimpleMarkerSymbolLayer > markerLayer = std::make_unique< QgsSimpleMarkerSymbolLayer >( shape, sizeInPoints, angleCW,
Qgis::ScaleMethod::ScaleArea, fillColor, lineColor );
700 markerLayer->setStrokeStyle( penStyle );
701 markerLayer->setStrokeWidth( penWidthInPoints );
702 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
704 layers.append( markerLayer.release() );
706 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
710std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriPictureMarkerSymbolJson(
const QVariantMap &symbolData )
713 const double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
716 const double heightInPixels = symbolData.value( QStringLiteral(
"height" ) ).toInt( &ok );
720 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
725 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
726 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
730 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
731 symbolPath.prepend( QLatin1String(
"base64:" ) );
734 std::unique_ptr< QgsRasterMarkerSymbolLayer > markerLayer = std::make_unique< QgsRasterMarkerSymbolLayer >( symbolPath, widthInPixels, angleCW,
Qgis::ScaleMethod::ScaleArea );
738 if ( !
qgsDoubleNear(
static_cast< double >( heightInPixels ) / widthInPixels, markerLayer->defaultAspectRatio() ) )
739 markerLayer->setFixedAspectRatio(
static_cast< double >( heightInPixels ) / widthInPixels );
741 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
743 layers.append( markerLayer.release() );
745 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
751 if ( labelingData.empty() )
758 for (
const QVariant &lbl : labelingData )
760 const QVariantMap labeling = lbl.toMap();
765 const QString placement = labeling.value( QStringLiteral(
"labelPlacement" ) ).toString();
766 if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveCenter" ) )
769 settings->
quadOffset = Qgis::LabelQuadrantPosition::Above;
771 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowCenter" ) )
774 settings->
quadOffset = Qgis::LabelQuadrantPosition::Below;
776 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterCenter" ) )
779 settings->
quadOffset = Qgis::LabelQuadrantPosition::Over;
781 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveLeft" ) )
784 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveLeft;
786 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowLeft" ) )
789 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowLeft;
791 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterLeft" ) )
794 settings->
quadOffset = Qgis::LabelQuadrantPosition::Left;
796 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveRight" ) )
799 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveRight;
801 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowRight" ) )
804 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowRight;
806 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterRight" ) )
809 settings->
quadOffset = Qgis::LabelQuadrantPosition::Right;
811 else if ( placement == QLatin1String(
"esriServerLinePlacementAboveAfter" ) ||
812 placement == QLatin1String(
"esriServerLinePlacementAboveStart" ) ||
813 placement == QLatin1String(
"esriServerLinePlacementAboveAlong" ) )
818 else if ( placement == QLatin1String(
"esriServerLinePlacementBelowAfter" ) ||
819 placement == QLatin1String(
"esriServerLinePlacementBelowStart" ) ||
820 placement == QLatin1String(
"esriServerLinePlacementBelowAlong" ) )
825 else if ( placement == QLatin1String(
"esriServerLinePlacementCenterAfter" ) ||
826 placement == QLatin1String(
"esriServerLinePlacementCenterStart" ) ||
827 placement == QLatin1String(
"esriServerLinePlacementCenterAlong" ) )
832 else if ( placement == QLatin1String(
"esriServerPolygonPlacementAlwaysHorizontal" ) )
837 const double minScale = labeling.value( QStringLiteral(
"minScale" ) ).toDouble();
838 const double maxScale = labeling.value( QStringLiteral(
"maxScale" ) ).toDouble();
840 QVariantMap symbol = labeling.value( QStringLiteral(
"symbol" ) ).toMap();
842 const double haloSize = symbol.value( QStringLiteral(
"haloSize" ) ).toDouble();
853 const QString fontFamily = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"family" ) ).toString();
854 const QString fontStyle = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"style" ) ).toString();
855 const QString fontWeight = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"weight" ) ).toString();
856 const int fontSize = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"size" ) ).toInt();
857 QFont font( fontFamily, fontSize );
858 font.setStyleName( fontStyle );
859 font.setWeight( fontWeight == QLatin1String(
"bold" ) ? QFont::Bold : QFont::Normal );
867 QString where = labeling.value( QStringLiteral(
"where" ) ).toString();
886 const QString type = rendererData.value( QStringLiteral(
"type" ) ).toString();
887 if ( type == QLatin1String(
"simple" ) )
889 const QVariantMap symbolProps = rendererData.value( QStringLiteral(
"symbol" ) ).toMap();
890 std::unique_ptr< QgsSymbol > symbol(
convertSymbol( symbolProps ) );
896 else if ( type == QLatin1String(
"uniqueValue" ) )
898 const QString field1 = rendererData.value( QStringLiteral(
"field1" ) ).toString();
899 const QString field2 = rendererData.value( QStringLiteral(
"field2" ) ).toString();
900 const QString field3 = rendererData.value( QStringLiteral(
"field3" ) ).toString();
902 if ( !field2.isEmpty() || !field3.isEmpty() )
904 const QString delimiter = rendererData.value( QStringLiteral(
"fieldDelimiter" ) ).toString();
905 if ( !field3.isEmpty() )
907 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\",'%4',\"%5\")" ).arg( field1, delimiter, field2, delimiter, field3 );
911 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\")" ).arg( field1, delimiter, field2 );
919 const QVariantList categories = rendererData.value( QStringLiteral(
"uniqueValueInfos" ) ).toList();
921 for (
const QVariant &category : categories )
923 const QVariantMap categoryData = category.toMap();
924 const QString value = categoryData.value( QStringLiteral(
"value" ) ).toString();
925 const QString label = categoryData.value( QStringLiteral(
"label" ) ).toString();
933 std::unique_ptr< QgsSymbol > defaultSymbol(
convertSymbol( rendererData.value( QStringLiteral(
"defaultSymbol" ) ).toMap() ) );
936 categoryList.append(
QgsRendererCategory( QVariant(), defaultSymbol.release(), rendererData.value( QStringLiteral(
"defaultLabel" ) ).toString() ) );
939 if ( categoryList.empty() )
944 else if ( type == QLatin1String(
"classBreaks" ) )
949 else if ( type == QLatin1String(
"heatmap" ) )
954 else if ( type == QLatin1String(
"vectorField" ) )
964 QString expression = string;
967 const thread_local QRegularExpression rx1 = QRegularExpression( QStringLiteral(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)CONCAT(\\s|$)" ) );
968 expression = expression.replace( rx1, QStringLiteral(
"\\4||\\5" ) );
970 const thread_local QRegularExpression rx2 = QRegularExpression( QStringLiteral(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)NEWLINE(\\s|$)" ) );
971 expression = expression.replace( rx2, QStringLiteral(
"\\4'\\n'\\5" ) );
974 const thread_local QRegularExpression rx3 = QRegularExpression( QStringLiteral(
"\"(.*?(?<!\\\\))\"" ) );
975 expression = expression.replace( rx3, QStringLiteral(
"'\\1'" ) );
976 const thread_local QRegularExpression rx4 = QRegularExpression( QStringLiteral(
"\\\\\"" ) );
977 expression = expression.replace( rx4, QStringLiteral(
"\"" ) );
980 const thread_local QRegularExpression rx5 = QRegularExpression( QStringLiteral(
"\\[([^]]*)\\]" ) );
981 expression = expression.replace( rx5, QStringLiteral(
"\"\\1\"" ) );
988 const QVariantList colorParts = colorData.toList();
989 if ( colorParts.count() < 4 )
992 int red = colorParts.at( 0 ).toInt();
993 int green = colorParts.at( 1 ).toInt();
994 int blue = colorParts.at( 2 ).toInt();
995 int alpha = colorParts.at( 3 ).toInt();
996 return QColor( red, green, blue, alpha );
1001 if ( style == QLatin1String(
"esriSLSSolid" ) )
1002 return Qt::SolidLine;
1003 else if ( style == QLatin1String(
"esriSLSDash" ) )
1004 return Qt::DashLine;
1005 else if ( style == QLatin1String(
"esriSLSDashDot" ) )
1006 return Qt::DashDotLine;
1007 else if ( style == QLatin1String(
"esriSLSDashDotDot" ) )
1008 return Qt::DashDotDotLine;
1009 else if ( style == QLatin1String(
"esriSLSDot" ) )
1011 else if ( style == QLatin1String(
"esriSLSNull" ) )
1014 return Qt::SolidLine;
1019 if ( style == QLatin1String(
"esriSFSBackwardDiagonal" ) )
1020 return Qt::BDiagPattern;
1021 else if ( style == QLatin1String(
"esriSFSCross" ) )
1022 return Qt::CrossPattern;
1023 else if ( style == QLatin1String(
"esriSFSDiagonalCross" ) )
1024 return Qt::DiagCrossPattern;
1025 else if ( style == QLatin1String(
"esriSFSForwardDiagonal" ) )
1026 return Qt::FDiagPattern;
1027 else if ( style == QLatin1String(
"esriSFSHorizontal" ) )
1028 return Qt::HorPattern;
1029 else if ( style == QLatin1String(
"esriSFSNull" ) )
1031 else if ( style == QLatin1String(
"esriSFSSolid" ) )
1032 return Qt::SolidPattern;
1033 else if ( style == QLatin1String(
"esriSFSVertical" ) )
1034 return Qt::VerPattern;
1036 return Qt::SolidPattern;
1044 QDateTime dt = QDateTime::fromMSecsSinceEpoch( value.toLongLong( &ok ) );
1047 QgsDebugMsg( QStringLiteral(
"Invalid value %1 for datetime" ).arg( value.toString() ) );
1058 return QVariantMap();
1065 return QVariantMap();
1068 res = pointToJson( qgsgeometry_cast< const QgsPoint * >( geom ) );
1072 res = lineStringToJson( qgsgeometry_cast< const QgsLineString * >( geom ) );
1077 res = curveToJson( qgsgeometry_cast< const QgsCurve * >( geom ) );
1081 res = polygonToJson( qgsgeometry_cast< const QgsPolygon * >( geom ) );
1085 res = multiPointToJson( qgsgeometry_cast< const QgsMultiPoint * >( geom ) );
1089 res = multiLineStringToJson( qgsgeometry_cast< const QgsMultiLineString * >( geom ) );
1093 res = multiCurveToJson( qgsgeometry_cast< const QgsMultiCurve * >( geom ) );
1097 res = multiPolygonToJson( qgsgeometry_cast< const QgsMultiPolygon * >( geom ) );
1101 res = curvePolygonToJson( qgsgeometry_cast< const QgsCurvePolygon * >( geom ) );
1105 res = multiSurfaceToJson( qgsgeometry_cast< const QgsMultiSurface * >( geom ) );
1109 return QVariantMap();
1112 return QVariantMap();
1115 return QVariantMap();
1122 res.insert( QStringLiteral(
"spatialReference" ),
crsToJson(
crs ) );
1128QVariantMap QgsArcGisRestUtils::pointToJson(
const QgsPoint *point )
1132 data[QStringLiteral(
"x" )] = QStringLiteral(
"NaN" );
1135 data[QStringLiteral(
"x" )] = point->
x();
1136 data[QStringLiteral(
"y" )] = point->
y();
1138 if ( point->
is3D() )
1139 data[QStringLiteral(
"z" )] = !std::isnan( point->
z() ) ? QVariant( point->
z() ) : QVariant( QStringLiteral(
"NaN" ) );
1142 data[QStringLiteral(
"m" )] = !std::isnan( point->
m() ) ? QVariant( point->
m() ) : QVariant( QStringLiteral(
"NaN" ) );
1147QVariantMap QgsArcGisRestUtils::multiPointToJson(
const QgsMultiPoint *multiPoint )
1150 const bool hasZ = multiPoint->
is3D();
1151 const bool hasM = multiPoint->
isMeasure();
1152 data[QStringLiteral(
"hasM" )] = hasM;
1153 data[QStringLiteral(
"hasZ" )] = hasZ;
1155 QVariantList pointsList;
1157 pointsList.reserve( size );
1159 QVariantList pointList;
1160 for (
int i = 0; i < size; ++i )
1165 pointList.append( point->
x() );
1166 pointList.append( point->
y() );
1168 pointList.append( point->
z() );
1169 if ( hasM && !std::isnan( point->
m() ) )
1170 pointList.append( point->
m() );
1172 pointsList.push_back( pointList );
1175 data[QStringLiteral(
"points" )] = pointsList;
1179QVariantList QgsArcGisRestUtils::lineStringToJsonPath(
const QgsLineString *line )
1181 const bool hasZ = line->
is3D();
1184 QVariantList pointsList;
1186 pointsList.reserve( size );
1188 QVariantList pointList;
1189 const double *xData = line->
xData();
1190 const double *yData = line->
yData();
1191 const double *zData = hasZ ? line->
zData() :
nullptr;
1192 const double *mData = hasM ? line->
mData() :
nullptr;
1194 for (
int i = 0; i < size; ++i )
1197 pointList.append( *xData++ );
1198 pointList.append( *yData++ );
1201 pointList.append( *zData++ );
1203 if ( hasM && !std::isnan( *mData ) )
1204 pointList.append( *mData );
1208 pointsList.push_back( pointList );
1213QVariantList QgsArcGisRestUtils::curveToJsonCurve(
const QgsCurve *curve,
bool includeStart )
1215 const bool hasZ = curve->
is3D();
1218 auto pointToList = [hasZ, hasM](
const QgsPoint & point ) -> QVariantList
1220 QVariantList pointList;
1222 pointList.append( point.
x() );
1223 pointList.append( point.
y() );
1226 pointList.append( point.
z() );
1228 if ( hasM && !std::isnan( point.
m() ) )
1229 pointList.append( point.
m() );
1239 QVariantList part = lineStringToJsonPath( qgsgeometry_cast< const QgsLineString *>( curve ) );
1240 if ( !part.isEmpty() && !includeStart )
1248 const QgsCircularString *circularString = qgsgeometry_cast<const QgsCircularString * >( curve );
1249 if ( includeStart && !circularString->
isEmpty() )
1251 res.push_back( pointToList( circularString->
startPoint() ) );
1254 const int size = circularString->
numPoints();
1255 for (
int i = 1; i + 1 < size; i += 2 )
1258 QVariantMap curvePart;
1259 QVariantList curveList;
1260 curveList.push_back( pointToList( circularString->
pointN( i + 1 ) ) );
1262 curveList.push_back( pointToList( circularString->
pointN( i ) ) );
1264 curvePart.insert( QStringLiteral(
"c" ), curveList );
1265 res.push_back( curvePart );
1272 const QgsCompoundCurve *compoundCurve = qgsgeometry_cast<const QgsCompoundCurve * >( curve );
1274 const int size = compoundCurve->
nCurves();
1275 for (
int i = 0; i < size; ++i )
1278 res.append( curveToJsonCurve( subCurve, i == 0 ) );
1289QVariantMap QgsArcGisRestUtils::lineStringToJson(
const QgsLineString *line )
1292 const bool hasZ = line->
is3D();
1294 data[QStringLiteral(
"hasM" )] = hasM;
1295 data[QStringLiteral(
"hasZ" )] = hasZ;
1297 const QVariantList pointsList = lineStringToJsonPath( line );
1299 QVariantList pointsData = QVariantList();
1300 pointsData.push_back( pointsList );
1301 data[QStringLiteral(
"paths" )] = pointsData;
1306QVariantMap QgsArcGisRestUtils::curveToJson(
const QgsCurve *curve )
1309 const bool hasZ = curve->
is3D();
1311 data[QStringLiteral(
"hasM" )] = hasM;
1312 data[QStringLiteral(
"hasZ" )] = hasZ;
1314 const QVariantList curveList = curveToJsonCurve( curve,
true );
1316 QVariantList curveData = QVariantList();
1317 curveData.push_back( curveList );
1318 data[QStringLiteral(
"curvePaths" )] = curveData;
1323QVariantMap QgsArcGisRestUtils::multiLineStringToJson(
const QgsMultiLineString *multiLine )
1326 const bool hasZ = multiLine->
is3D();
1327 const bool hasM = multiLine->
isMeasure();
1328 data[QStringLiteral(
"hasM" )] = hasM;
1329 data[QStringLiteral(
"hasZ" )] = hasZ;
1333 paths.reserve( size );
1334 for (
int i = 0; i < size; ++i )
1337 paths.push_back( lineStringToJsonPath( line ) );
1340 data[QStringLiteral(
"paths" )] = paths;
1344QVariantMap QgsArcGisRestUtils::multiCurveToJson(
const QgsMultiCurve *multiCurve )
1347 const bool hasZ = multiCurve->
is3D();
1348 const bool hasM = multiCurve->
isMeasure();
1349 data[QStringLiteral(
"hasM" )] = hasM;
1350 data[QStringLiteral(
"hasZ" )] = hasZ;
1354 paths.reserve( size );
1355 for (
int i = 0; i < size; ++i )
1358 paths.push_back( curveToJsonCurve( curve,
true ) );
1361 data[QStringLiteral(
"curvePaths" )] = paths;
1365QVariantList QgsArcGisRestUtils::polygonToJsonRings(
const QgsPolygon *polygon )
1369 rings.reserve( numInteriorRings + 1 );
1377 rings.push_back( lineStringToJsonPath( exterior ) );
1382 std::unique_ptr< QgsLineString > reversed( exterior->
reversed() );
1383 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1389 for (
int i = 0; i < numInteriorRings; ++i )
1396 rings.push_back( lineStringToJsonPath( ring ) );
1401 std::unique_ptr< QgsLineString > reversed( ring->
reversed() );
1402 rings.push_back( lineStringToJsonPath( reversed.get() ) );
1410QVariantList QgsArcGisRestUtils::curvePolygonToJsonRings(
const QgsCurvePolygon *polygon )
1414 rings.reserve( numInteriorRings + 1 );
1416 if (
const QgsCurve *exterior = qgsgeometry_cast< const QgsCurve * >( polygon->
exteriorRing() ) )
1422 rings.push_back( curveToJsonCurve( exterior,
true ) );
1427 std::unique_ptr< QgsCurve > reversed( exterior->
reversed() );
1428 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1434 for (
int i = 0; i < numInteriorRings; ++i )
1441 rings.push_back( curveToJsonCurve( ring,
true ) );
1446 std::unique_ptr< QgsCurve > reversed( ring->
reversed() );
1447 rings.push_back( curveToJsonCurve( reversed.get(),
true ) );
1455QVariantMap QgsArcGisRestUtils::polygonToJson(
const QgsPolygon *polygon )
1458 const bool hasZ = polygon->
is3D();
1460 data[QStringLiteral(
"hasM" )] = hasM;
1461 data[QStringLiteral(
"hasZ" )] = hasZ;
1462 data[QStringLiteral(
"rings" )] = polygonToJsonRings( polygon );
1466QVariantMap QgsArcGisRestUtils::curvePolygonToJson(
const QgsCurvePolygon *polygon )
1469 const bool hasZ = polygon->
is3D();
1471 data[QStringLiteral(
"hasM" )] = hasM;
1472 data[QStringLiteral(
"hasZ" )] = hasZ;
1473 data[QStringLiteral(
"curveRings" )] = curvePolygonToJsonRings( polygon );
1477QVariantMap QgsArcGisRestUtils::multiPolygonToJson(
const QgsMultiPolygon *multiPolygon )
1480 const bool hasZ = multiPolygon->
is3D();
1481 const bool hasM = multiPolygon->
isMeasure();
1482 data[QStringLiteral(
"hasM" )] = hasM;
1483 data[QStringLiteral(
"hasZ" )] = hasZ;
1487 for (
int i = 0; i < size; ++i )
1490 rings.append( polygonToJsonRings( polygon ) );
1493 data[QStringLiteral(
"rings" )] = rings;
1497QVariantMap QgsArcGisRestUtils::multiSurfaceToJson(
const QgsMultiSurface *multiSurface )
1500 const bool hasZ = multiSurface->
is3D();
1501 const bool hasM = multiSurface->
isMeasure();
1502 data[QStringLiteral(
"hasM" )] = hasM;
1503 data[QStringLiteral(
"hasZ" )] = hasZ;
1507 for (
int i = 0; i < size; ++i )
1513 rings.append( curvePolygonToJsonRings( polygon ) );
1516 data[QStringLiteral(
"curveRings" )] = rings;
1527 if ( !authid.isEmpty() )
1529 const thread_local QRegularExpression rxAuthid( QStringLiteral(
"(\\w+):(\\d+)" ) );
1530 const QRegularExpressionMatch match = rxAuthid.match( authid );
1531 if ( match.hasMatch()
1533 ( match.captured( 1 ).compare( QLatin1String(
"EPSG" ), Qt::CaseInsensitive ) == 0 )
1534 || ( match.captured( 1 ).compare( QLatin1String(
"ESRI" ), Qt::CaseInsensitive ) == 0 )
1538 const QString wkid = match.captured( 2 );
1539 res.insert( QStringLiteral(
"wkid" ), wkid );
1558 QVariantMap attributes;
1565 if ( !attributes.isEmpty() )
1567 res.insert( QStringLiteral(
"attributes" ), attributes );
1577 switch ( expectedType )
1579 case QVariant::DateTime:
1580 case QVariant::Date:
1582 switch ( variant.type() )
1584 case QVariant::DateTime:
1585 return variant.toDateTime().toMSecsSinceEpoch();
1587 case QVariant::Date:
1589 if ( context.
timeZone().isValid() )
1590 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ), context.
timeZone() ).toMSecsSinceEpoch();
1592 return QDateTime( variant.toDate(), QTime( 0, 0, 0 ) ).toMSecsSinceEpoch();
1607 res.insert( QStringLiteral(
"name" ),
field.
name() );
1612 case QVariant::LongLong:
1613 fieldType = QStringLiteral(
"esriFieldTypeInteger" );
1617 fieldType = QStringLiteral(
"esriFieldTypeSmallInteger" );
1620 case QVariant::Double:
1621 fieldType = QStringLiteral(
"esriFieldTypeDouble" );
1624 case QVariant::String:
1625 fieldType = QStringLiteral(
"esriFieldTypeString" );
1628 case QVariant::DateTime:
1629 case QVariant::Date:
1630 fieldType = QStringLiteral(
"esriFieldTypeDate" );
1633 case QVariant::ByteArray:
1634 fieldType = QStringLiteral(
"esriFieldTypeBlob" );
1639 fieldType = QStringLiteral(
"esriFieldTypeString" );
1642 res.insert( QStringLiteral(
"type" ), fieldType );
1645 res.insert( QStringLiteral(
"alias" ),
field.
alias() );
1649 res.insert( QStringLiteral(
"nullable" ), !notNullable );
1652 res.insert( QStringLiteral(
"editable" ),
true );
1659 if ( type.compare( QLatin1String(
"FeatureServer" ), Qt::CaseInsensitive ) == 0 )
1660 return Qgis::ArcGisRestServiceType::FeatureServer;
1661 else if ( type.compare( QLatin1String(
"MapServer" ), Qt::CaseInsensitive ) == 0 )
1662 return Qgis::ArcGisRestServiceType::MapServer;
1663 else if ( type.compare( QLatin1String(
"ImageServer" ), Qt::CaseInsensitive ) == 0 )
1664 return Qgis::ArcGisRestServiceType::ImageServer;
1665 else if ( type.compare( QLatin1String(
"GlobeServer" ), Qt::CaseInsensitive ) == 0 )
1667 else if ( type.compare( QLatin1String(
"GPServer" ), Qt::CaseInsensitive ) == 0 )
1669 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)
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.
QgsWkbTypes::Type 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 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 QgsWkbTypes::Type convertGeometryType(const QString &type)
Converts an ESRI REST geometry type to a WKB 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 setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
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 setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
@ RenderPoints
Points (e.g., for font sizes)
static bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
static Type zmType(Type type, bool hasZ, bool hasM) SIP_HOLDGIL
Returns the modified input geometry type according to hasZ / hasM.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
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