42 #include <QRegularExpression>
46 if ( esriFieldType == QLatin1String(
"esriFieldTypeInteger" ) )
47 return QVariant::LongLong;
48 if ( esriFieldType == QLatin1String(
"esriFieldTypeSmallInteger" ) )
50 if ( esriFieldType == QLatin1String(
"esriFieldTypeDouble" ) )
51 return QVariant::Double;
52 if ( esriFieldType == QLatin1String(
"esriFieldTypeSingle" ) )
53 return QVariant::Double;
54 if ( esriFieldType == QLatin1String(
"esriFieldTypeString" ) )
55 return QVariant::String;
56 if ( esriFieldType == QLatin1String(
"esriFieldTypeDate" ) )
57 return QVariant::DateTime;
58 if ( esriFieldType == QLatin1String(
"esriFieldTypeGeometry" ) )
59 return QVariant::Invalid;
60 if ( esriFieldType == QLatin1String(
"esriFieldTypeOID" ) )
61 return QVariant::LongLong;
62 if ( esriFieldType == QLatin1String(
"esriFieldTypeBlob" ) )
63 return QVariant::ByteArray;
64 if ( esriFieldType == QLatin1String(
"esriFieldTypeGlobalID" ) )
65 return QVariant::String;
66 if ( esriFieldType == QLatin1String(
"esriFieldTypeRaster" ) )
67 return QVariant::ByteArray;
68 if ( esriFieldType == QLatin1String(
"esriFieldTypeGUID" ) )
69 return QVariant::String;
70 if ( esriFieldType == QLatin1String(
"esriFieldTypeXML" ) )
71 return QVariant::String;
72 return QVariant::Invalid;
78 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
80 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
82 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
84 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
86 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
88 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
108 std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertPoint(
const QVariantList &coordList,
QgsWkbTypes::Type pointType )
110 int nCoords = coordList.size();
113 bool xok =
false, yok =
false;
114 const double x = coordList[0].toDouble( &xok );
115 const double y = coordList[1].toDouble( &yok );
119 const double z = hasZ && nCoords >= 3 ? coordList[2].toDouble() : std::numeric_limits< double >::quiet_NaN();
122 const double m =
QgsWkbTypes::hasM( pointType ) && ( ( hasZ && nCoords >= 4 ) || ( !hasZ && nCoords >= 3 ) ) ? coordList[ hasZ ? 3 : 2].toDouble() : std::numeric_limits< double >::quiet_NaN();
123 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
126 std::unique_ptr< QgsCircularString > QgsArcGisRestUtils::convertCircularString(
const QVariantMap &curveData,
QgsWkbTypes::Type pointType,
const QgsPoint &startPoint )
128 const QVariantList coordsList = curveData[QStringLiteral(
"c" )].toList();
129 if ( coordsList.isEmpty() )
131 const int coordsListSize = coordsList.size();
133 QVector<QgsPoint> points;
134 points.reserve( coordsListSize + 1 );
135 points.append( startPoint );
137 for (
int i = 0; i < coordsListSize - 1; )
141 std::unique_ptr< QgsPoint > endPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
145 std::unique_ptr< QgsPoint > interiorPoint( convertPoint( coordsList.at( i ).toList(), pointType ) );
146 if ( !interiorPoint )
149 points << *interiorPoint;
152 std::unique_ptr< QgsCircularString > curve = std::make_unique< QgsCircularString> ();
153 curve->setPoints( points );
157 std::unique_ptr< QgsCompoundCurve > QgsArcGisRestUtils::convertCompoundCurve(
const QVariantList &curvesList,
QgsWkbTypes::Type pointType )
160 std::unique_ptr< QgsCompoundCurve > compoundCurve = std::make_unique< QgsCompoundCurve >();
161 std::unique_ptr< QgsLineString > lineString;
162 for (
const QVariant &curveData : curvesList )
164 if ( curveData.type() == QVariant::List )
166 std::unique_ptr< QgsPoint > point( convertPoint( curveData.toList(), pointType ) );
172 lineString = std::make_unique< QgsLineString >();
174 lineString->addVertex( *point );
176 else if ( curveData.type() == QVariant::Map )
179 std::unique_ptr< QgsCircularString > circularString( convertCircularString( curveData.toMap(), pointType, lineString ? lineString->endPoint() :
QgsPoint() ) );
180 if ( !circularString )
186 compoundCurve->addCurve( lineString.release() );
189 if ( compoundCurve->curveAt( compoundCurve->nCurves() - 1 )->nCoordinates() < 2 )
190 compoundCurve->removeCurve( compoundCurve->nCurves() - 1 );
192 const QgsPoint endPointCircularString = circularString->endPoint();
193 compoundCurve->addCurve( circularString.release() );
196 lineString = std::make_unique< QgsLineString >();
197 lineString->addVertex( endPointCircularString );
201 if ( lineString && lineString->numPoints() == 1 && compoundCurve->nCurves() > 0 )
203 const QgsCurve *finalCurve = compoundCurve->curveAt( compoundCurve->nCurves() - 1 );
204 if ( finalCurve->
endPoint() == lineString->startPoint() )
209 compoundCurve->addCurve( lineString.release() );
211 return compoundCurve;
214 std::unique_ptr< QgsPoint > QgsArcGisRestUtils::convertGeometryPoint(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
217 bool xok =
false, yok =
false;
218 double x = geometryData[QStringLiteral(
"x" )].toDouble( &xok );
219 double y = geometryData[QStringLiteral(
"y" )].toDouble( &yok );
222 double z = geometryData[QStringLiteral(
"z" )].toDouble();
223 double m = geometryData[QStringLiteral(
"m" )].toDouble();
224 return std::make_unique< QgsPoint >( pointType, x, y, z, m );
227 std::unique_ptr< QgsMultiPoint > QgsArcGisRestUtils::convertMultiPoint(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
230 const QVariantList coordsList = geometryData[QStringLiteral(
"points" )].toList();
232 std::unique_ptr< QgsMultiPoint > multiPoint = std::make_unique< QgsMultiPoint >();
233 multiPoint->reserve( coordsList.size() );
234 for (
const QVariant &coordData : coordsList )
236 const QVariantList coordList = coordData.toList();
237 std::unique_ptr< QgsPoint > p = convertPoint( coordList, pointType );
242 multiPoint->addGeometry( p.release() );
247 std::unique_ptr< QgsPoint > p = convertGeometryPoint( geometryData, pointType );
249 multiPoint->addGeometry( p.release() );
251 if ( multiPoint->numGeometries() == 0 )
259 std::unique_ptr< QgsMultiCurve > QgsArcGisRestUtils::convertGeometryPolyline(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
262 QVariantList pathsList;
263 if ( geometryData[QStringLiteral(
"paths" )].isValid() )
264 pathsList = geometryData[QStringLiteral(
"paths" )].toList();
265 else if ( geometryData[QStringLiteral(
"curvePaths" )].isValid() )
266 pathsList = geometryData[QStringLiteral(
"curvePaths" )].toList();
267 if ( pathsList.isEmpty() )
269 std::unique_ptr< QgsMultiCurve > multiCurve = std::make_unique< QgsMultiCurve >();
270 multiCurve->reserve( pathsList.size() );
271 for (
const QVariant &pathData : std::as_const( pathsList ) )
273 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( pathData.toList(), pointType );
278 multiCurve->addGeometry( curve.release() );
283 std::unique_ptr< QgsMultiSurface > QgsArcGisRestUtils::convertGeometryPolygon(
const QVariantMap &geometryData,
QgsWkbTypes::Type pointType )
286 QVariantList ringsList;
287 if ( geometryData[QStringLiteral(
"rings" )].isValid() )
288 ringsList = geometryData[QStringLiteral(
"rings" )].toList();
289 else if ( geometryData[QStringLiteral(
"ringPaths" )].isValid() )
290 ringsList = geometryData[QStringLiteral(
"ringPaths" )].toList();
291 if ( ringsList.isEmpty() )
294 QList< QgsCompoundCurve * > curves;
295 for (
int i = 0, n = ringsList.size(); i < n; ++i )
297 std::unique_ptr< QgsCompoundCurve > curve = convertCompoundCurve( ringsList[i].toList(), pointType );
302 curves.append( curve.release() );
304 if ( curves.count() == 0 )
307 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 ); } );
308 std::unique_ptr< QgsMultiSurface > result = std::make_unique< QgsMultiSurface >();
309 result->reserve( curves.size() );
310 while ( !curves.isEmpty() )
316 engine->prepareGeometry();
318 QMutableListIterator< QgsCompoundCurve * > it( curves );
319 while ( it.hasNext() )
326 if ( engine->contains( &point ) )
331 engine->prepareGeometry();
335 result->addGeometry( newPolygon );
337 if ( result->numGeometries() == 0 )
343 std::unique_ptr< QgsPolygon > QgsArcGisRestUtils::convertEnvelope(
const QVariantMap &geometryData )
346 bool xminOk =
false, yminOk =
false, xmaxOk =
false, ymaxOk =
false;
347 double xmin = geometryData[QStringLiteral(
"xmin" )].toDouble( &xminOk );
348 double ymin = geometryData[QStringLiteral(
"ymin" )].toDouble( &yminOk );
349 double xmax = geometryData[QStringLiteral(
"xmax" )].toDouble( &xmaxOk );
350 double ymax = geometryData[QStringLiteral(
"ymax" )].toDouble( &ymaxOk );
351 if ( !xminOk || !yminOk || !xmaxOk || !ymaxOk )
353 std::unique_ptr< QgsLineString > ext = std::make_unique< QgsLineString> ();
354 ext->addVertex(
QgsPoint( xmin, ymin ) );
355 ext->addVertex(
QgsPoint( xmax, ymin ) );
356 ext->addVertex(
QgsPoint( xmax, ymax ) );
357 ext->addVertex(
QgsPoint( xmin, ymax ) );
358 ext->addVertex(
QgsPoint( xmin, ymin ) );
359 std::unique_ptr< QgsPolygon > poly = std::make_unique< QgsPolygon >();
360 poly->setExteriorRing( ext.release() );
373 if ( esriGeometryType == QLatin1String(
"esriGeometryNull" ) )
375 else if ( esriGeometryType == QLatin1String(
"esriGeometryPoint" ) )
376 return convertGeometryPoint( geometryData, pointType ).release();
377 else if ( esriGeometryType == QLatin1String(
"esriGeometryMultipoint" ) )
378 return convertMultiPoint( geometryData, pointType ).release();
379 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolyline" ) )
380 return convertGeometryPolyline( geometryData, pointType ).release();
381 else if ( esriGeometryType == QLatin1String(
"esriGeometryPolygon" ) )
382 return convertGeometryPolygon( geometryData, pointType ).release();
383 else if ( esriGeometryType == QLatin1String(
"esriGeometryEnvelope" ) )
384 return convertEnvelope( geometryData ).release();
407 QString spatialReference = spatialReferenceMap[QStringLiteral(
"latestWkid" )].toString();
408 if ( spatialReference.isEmpty() )
409 spatialReference = spatialReferenceMap[QStringLiteral(
"wkid" )].toString();
412 if ( !spatialReference.isEmpty() )
421 else if ( !spatialReferenceMap[QStringLiteral(
"wkt" )].toString().isEmpty() )
424 crs.
createFromWkt( spatialReferenceMap[QStringLiteral(
"wkt" )].toString() );
439 const QString type = symbolData.value( QStringLiteral(
"type" ) ).toString();
440 if ( type == QLatin1String(
"esriSMS" ) )
443 return parseEsriMarkerSymbolJson( symbolData ).release();
445 else if ( type == QLatin1String(
"esriSLS" ) )
448 return parseEsriLineSymbolJson( symbolData ).release();
450 else if ( type == QLatin1String(
"esriSFS" ) )
453 return parseEsriFillSymbolJson( symbolData ).release();
455 else if ( type == QLatin1String(
"esriPFS" ) )
457 return parseEsriPictureFillSymbolJson( symbolData ).release();
459 else if ( type == QLatin1String(
"esriPMS" ) )
462 return parseEsriPictureMarkerSymbolJson( symbolData ).release();
464 else if ( type == QLatin1String(
"esriTS" ) )
472 std::unique_ptr<QgsLineSymbol> QgsArcGisRestUtils::parseEsriLineSymbolJson(
const QVariantMap &symbolData )
474 QColor lineColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
475 if ( !lineColor.isValid() )
479 double widthInPoints = symbolData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
484 Qt::PenStyle penStyle =
convertLineStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
485 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, widthInPoints, penStyle );
487 layers.append( lineLayer.release() );
489 std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >( layers );
493 std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriFillSymbolJson(
const QVariantMap &symbolData )
495 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
496 Qt::BrushStyle brushStyle =
convertFillStyle( symbolData.value( QStringLiteral(
"style" ) ).toString() );
498 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
499 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
500 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
502 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
505 std::unique_ptr< QgsSimpleFillSymbolLayer > fillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( fillColor, brushStyle, lineColor, penStyle, penWidthInPoints );
507 layers.append( fillLayer.release() );
509 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
513 std::unique_ptr<QgsFillSymbol> QgsArcGisRestUtils::parseEsriPictureFillSymbolJson(
const QVariantMap &symbolData )
517 double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
521 const double xScale = symbolData.value( QStringLiteral(
"xscale" ) ).toDouble( &ok );
523 widthInPixels *= xScale;
525 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
530 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
531 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
533 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
534 symbolPath.prepend( QLatin1String(
"base64:" ) );
537 std::unique_ptr< QgsRasterFillSymbolLayer > fillLayer = std::make_unique< QgsRasterFillSymbolLayer >( symbolPath );
538 fillLayer->setWidth( widthInPixels );
539 fillLayer->setAngle( angleCW );
541 fillLayer->setOffset( QPointF( xOffset, yOffset ) );
543 layers.append( fillLayer.release() );
545 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
546 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
547 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
548 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
550 std::unique_ptr< QgsSimpleLineSymbolLayer > lineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( lineColor, penWidthInPoints, penStyle );
552 layers.append( lineLayer.release() );
554 std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers );
558 Qgis::MarkerShape QgsArcGisRestUtils::parseEsriMarkerShape(
const QString &style )
560 if ( style == QLatin1String(
"esriSMSCircle" ) )
562 else if ( style == QLatin1String(
"esriSMSCross" ) )
564 else if ( style == QLatin1String(
"esriSMSDiamond" ) )
566 else if ( style == QLatin1String(
"esriSMSSquare" ) )
568 else if ( style == QLatin1String(
"esriSMSX" ) )
570 else if ( style == QLatin1String(
"esriSMSTriangle" ) )
576 std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriMarkerSymbolJson(
const QVariantMap &symbolData )
578 QColor fillColor =
convertColor( symbolData.value( QStringLiteral(
"color" ) ) );
580 const double sizeInPoints = symbolData.value( QStringLiteral(
"size" ) ).toDouble( &ok );
583 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
588 Qgis::MarkerShape shape = parseEsriMarkerShape( symbolData.value( QStringLiteral(
"style" ) ).toString() );
590 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
591 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
593 const QVariantMap outlineData = symbolData.value( QStringLiteral(
"outline" ) ).toMap();
594 QColor lineColor =
convertColor( outlineData.value( QStringLiteral(
"color" ) ) );
595 Qt::PenStyle penStyle =
convertLineStyle( outlineData.value( QStringLiteral(
"style" ) ).toString() );
596 double penWidthInPoints = outlineData.value( QStringLiteral(
"width" ) ).toDouble( &ok );
599 std::unique_ptr< QgsSimpleMarkerSymbolLayer > markerLayer = std::make_unique< QgsSimpleMarkerSymbolLayer >( shape, sizeInPoints, angleCW,
Qgis::ScaleMethod::ScaleArea, fillColor, lineColor );
602 markerLayer->setStrokeStyle( penStyle );
603 markerLayer->setStrokeWidth( penWidthInPoints );
604 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
606 layers.append( markerLayer.release() );
608 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
612 std::unique_ptr<QgsMarkerSymbol> QgsArcGisRestUtils::parseEsriPictureMarkerSymbolJson(
const QVariantMap &symbolData )
615 const double widthInPixels = symbolData.value( QStringLiteral(
"width" ) ).toInt( &ok );
618 const double heightInPixels = symbolData.value( QStringLiteral(
"height" ) ).toInt( &ok );
622 const double angleCCW = symbolData.value( QStringLiteral(
"angle" ) ).toDouble( &ok );
627 const double xOffset = symbolData.value( QStringLiteral(
"xoffset" ) ).toDouble();
628 const double yOffset = symbolData.value( QStringLiteral(
"yoffset" ) ).toDouble();
632 QString symbolPath( symbolData.value( QStringLiteral(
"imageData" ) ).toString() );
633 symbolPath.prepend( QLatin1String(
"base64:" ) );
636 std::unique_ptr< QgsRasterMarkerSymbolLayer > markerLayer = std::make_unique< QgsRasterMarkerSymbolLayer >( symbolPath, widthInPixels, angleCW,
Qgis::ScaleMethod::ScaleArea );
640 if ( !
qgsDoubleNear(
static_cast< double >( heightInPixels ) / widthInPixels, markerLayer->defaultAspectRatio() ) )
641 markerLayer->setFixedAspectRatio(
static_cast< double >( heightInPixels ) / widthInPixels );
643 markerLayer->setOffset( QPointF( xOffset, yOffset ) );
645 layers.append( markerLayer.release() );
647 std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers );
653 if ( labelingData.empty() )
660 for (
const QVariant &lbl : labelingData )
662 const QVariantMap labeling = lbl.toMap();
667 const QString placement = labeling.value( QStringLiteral(
"labelPlacement" ) ).toString();
668 if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveCenter" ) )
671 settings->
quadOffset = Qgis::LabelQuadrantPosition::Above;
673 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowCenter" ) )
676 settings->
quadOffset = Qgis::LabelQuadrantPosition::Below;
678 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterCenter" ) )
681 settings->
quadOffset = Qgis::LabelQuadrantPosition::Over;
683 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveLeft" ) )
686 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveLeft;
688 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowLeft" ) )
691 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowLeft;
693 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterLeft" ) )
696 settings->
quadOffset = Qgis::LabelQuadrantPosition::Left;
698 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementAboveRight" ) )
701 settings->
quadOffset = Qgis::LabelQuadrantPosition::AboveRight;
703 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementBelowRight" ) )
706 settings->
quadOffset = Qgis::LabelQuadrantPosition::BelowRight;
708 else if ( placement == QLatin1String(
"esriServerPointLabelPlacementCenterRight" ) )
711 settings->
quadOffset = Qgis::LabelQuadrantPosition::Right;
713 else if ( placement == QLatin1String(
"esriServerLinePlacementAboveAfter" ) ||
714 placement == QLatin1String(
"esriServerLinePlacementAboveStart" ) ||
715 placement == QLatin1String(
"esriServerLinePlacementAboveAlong" ) )
720 else if ( placement == QLatin1String(
"esriServerLinePlacementBelowAfter" ) ||
721 placement == QLatin1String(
"esriServerLinePlacementBelowStart" ) ||
722 placement == QLatin1String(
"esriServerLinePlacementBelowAlong" ) )
727 else if ( placement == QLatin1String(
"esriServerLinePlacementCenterAfter" ) ||
728 placement == QLatin1String(
"esriServerLinePlacementCenterStart" ) ||
729 placement == QLatin1String(
"esriServerLinePlacementCenterAlong" ) )
734 else if ( placement == QLatin1String(
"esriServerPolygonPlacementAlwaysHorizontal" ) )
739 const double minScale = labeling.value( QStringLiteral(
"minScale" ) ).toDouble();
740 const double maxScale = labeling.value( QStringLiteral(
"maxScale" ) ).toDouble();
742 QVariantMap symbol = labeling.value( QStringLiteral(
"symbol" ) ).toMap();
744 const double haloSize = symbol.value( QStringLiteral(
"haloSize" ) ).toDouble();
755 const QString fontFamily = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"family" ) ).toString();
756 const QString fontStyle = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"style" ) ).toString();
757 const QString fontWeight = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"weight" ) ).toString();
758 const int fontSize = symbol.value( QStringLiteral(
"font" ) ).toMap().value( QStringLiteral(
"size" ) ).toInt();
759 QFont font( fontFamily, fontSize );
760 font.setStyleName( fontStyle );
761 font.setWeight( fontWeight == QLatin1String(
"bold" ) ? QFont::Bold : QFont::Normal );
769 QString where = labeling.value( QStringLiteral(
"where" ) ).toString();
788 const QString type = rendererData.value( QStringLiteral(
"type" ) ).toString();
789 if ( type == QLatin1String(
"simple" ) )
791 const QVariantMap symbolProps = rendererData.value( QStringLiteral(
"symbol" ) ).toMap();
792 std::unique_ptr< QgsSymbol > symbol(
convertSymbol( symbolProps ) );
798 else if ( type == QLatin1String(
"uniqueValue" ) )
800 const QString field1 = rendererData.value( QStringLiteral(
"field1" ) ).toString();
801 const QString field2 = rendererData.value( QStringLiteral(
"field2" ) ).toString();
802 const QString field3 = rendererData.value( QStringLiteral(
"field3" ) ).toString();
804 if ( !field2.isEmpty() || !field3.isEmpty() )
806 const QString delimiter = rendererData.value( QStringLiteral(
"fieldDelimiter" ) ).toString();
807 if ( !field3.isEmpty() )
809 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\",'%4',\"%5\")" ).arg( field1, delimiter, field2, delimiter, field3 );
813 attribute = QStringLiteral(
"concat(\"%1\",'%2',\"%3\")" ).arg( field1, delimiter, field2 );
821 const QVariantList categories = rendererData.value( QStringLiteral(
"uniqueValueInfos" ) ).toList();
823 for (
const QVariant &category : categories )
825 const QVariantMap categoryData = category.toMap();
826 const QString value = categoryData.value( QStringLiteral(
"value" ) ).toString();
827 const QString label = categoryData.value( QStringLiteral(
"label" ) ).toString();
835 std::unique_ptr< QgsSymbol > defaultSymbol(
convertSymbol( rendererData.value( QStringLiteral(
"defaultSymbol" ) ).toMap() ) );
838 categoryList.append(
QgsRendererCategory( QVariant(), defaultSymbol.release(), rendererData.value( QStringLiteral(
"defaultLabel" ) ).toString() ) );
841 if ( categoryList.empty() )
846 else if ( type == QLatin1String(
"classBreaks" ) )
851 else if ( type == QLatin1String(
"heatmap" ) )
856 else if ( type == QLatin1String(
"vectorField" ) )
866 QString expression = string;
869 expression = expression.replace( QRegularExpression(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)CONCAT(\\s|$)" ), QStringLiteral(
"\\4||\\5" ) );
870 expression = expression.replace( QRegularExpression(
"(?=([^\"\\\\]*(\\\\.|\"([^\"\\\\]*\\\\.)*[^\"\\\\]*\"))*[^\"]*$)(\\s|^)NEWLINE(\\s|$)" ), QStringLiteral(
"\\4'\\n'\\5" ) );
873 expression = expression.replace( QRegularExpression(
"\"(.*?(?<!\\\\))\"" ), QStringLiteral(
"'\\1'" ) );
874 expression = expression.replace( QRegularExpression(
"\\\\\"" ), QStringLiteral(
"\"" ) );
877 expression = expression.replace( QRegularExpression(
"\\[([^]]*)\\]" ), QStringLiteral(
"\"\\1\"" ) );
884 const QVariantList colorParts = colorData.toList();
885 if ( colorParts.count() < 4 )
888 int red = colorParts.at( 0 ).toInt();
889 int green = colorParts.at( 1 ).toInt();
890 int blue = colorParts.at( 2 ).toInt();
891 int alpha = colorParts.at( 3 ).toInt();
892 return QColor( red, green, blue, alpha );
897 if ( style == QLatin1String(
"esriSLSSolid" ) )
898 return Qt::SolidLine;
899 else if ( style == QLatin1String(
"esriSLSDash" ) )
901 else if ( style == QLatin1String(
"esriSLSDashDot" ) )
902 return Qt::DashDotLine;
903 else if ( style == QLatin1String(
"esriSLSDashDotDot" ) )
904 return Qt::DashDotDotLine;
905 else if ( style == QLatin1String(
"esriSLSDot" ) )
907 else if ( style == QLatin1String(
"esriSLSNull" ) )
910 return Qt::SolidLine;
915 if ( style == QLatin1String(
"esriSFSBackwardDiagonal" ) )
916 return Qt::BDiagPattern;
917 else if ( style == QLatin1String(
"esriSFSCross" ) )
918 return Qt::CrossPattern;
919 else if ( style == QLatin1String(
"esriSFSDiagonalCross" ) )
920 return Qt::DiagCrossPattern;
921 else if ( style == QLatin1String(
"esriSFSForwardDiagonal" ) )
922 return Qt::FDiagPattern;
923 else if ( style == QLatin1String(
"esriSFSHorizontal" ) )
924 return Qt::HorPattern;
925 else if ( style == QLatin1String(
"esriSFSNull" ) )
927 else if ( style == QLatin1String(
"esriSFSSolid" ) )
928 return Qt::SolidPattern;
929 else if ( style == QLatin1String(
"esriSFSVertical" ) )
930 return Qt::VerPattern;
932 return Qt::SolidPattern;
937 if ( value.isNull() )
940 QDateTime dt = QDateTime::fromMSecsSinceEpoch( value.toLongLong( &ok ) );
943 QgsDebugMsg( QStringLiteral(
"Invalid value %1 for datetime" ).arg( value.toString() ) );