47 return QStringLiteral(
"vector" );
52 QVector<QgsGeometry> res;
56 for (
const Feature &feature : it.value() )
58 res.append( feature.geometry );
70 return asIndividualFeatures(
type, feedback );
85 return snapPointToIndividualFeatures( point, context );
101 visitFeaturesInRange( distanceRange, elevationRange, visitFeature );
105 QVector< QVariantMap> idsList;
106 for (
auto it = ids.constBegin(); it != ids.constEnd(); ++it )
107 idsList.append( QVariantMap( {{QStringLiteral(
"id" ), *it}} ) );
114 QHash< QgsFeatureId, QVariantMap >
features;
115 auto visitFeature = [&
features](
QgsFeatureId featureId,
double delta,
double distance,
double elevation )
117 auto it =
features.find( featureId );
120 features[ featureId ] = QVariantMap( {{QStringLiteral(
"id" ), featureId },
121 {QStringLiteral(
"delta" ), delta },
122 {QStringLiteral(
"distance" ), distance },
123 {QStringLiteral(
"elevation" ), elevation }
128 const double currentDelta = it.value().value( QStringLiteral(
"delta" ) ).toDouble();
129 if ( delta < currentDelta )
131 *it = QVariantMap( {{QStringLiteral(
"id" ), featureId },
132 {QStringLiteral(
"delta" ), delta },
133 {QStringLiteral(
"distance" ), distance },
134 {QStringLiteral(
"elevation" ), elevation }
142 QVector< QVariantMap> attributes;
144 attributes.append( *it );
146 QVector<QgsProfileIdentifyResults> res;
148 if ( !attributes.empty() )
154 res.reserve( surfaceResults.size() );
167 double bestSnapDistance = std::numeric_limits< double >::max();
169 auto visitFeature = [&bestSnapDistance, &res](
QgsFeatureId,
double delta,
double distance,
double elevation )
171 if ( distance < bestSnapDistance )
173 bestSnapDistance = delta;
183void QgsVectorLayerProfileResults::visitFeaturesAtPoint(
const QgsProfilePoint &point,
double maximumPointDistanceDelta,
double maximumPointElevationDelta,
double maximumSurfaceElevationDelta,
const std::function<
void(
QgsFeatureId,
double delta,
double distance,
double elevation ) > &visitor,
bool visitWithin )
191 for (
const Feature &feature : it.value() )
193 const QgsRectangle featureBounds = feature.crossSectionGeometry.boundingBox();
194 if ( ( featureBounds.
xMinimum() - maximumPointDistanceDelta <= point.
distance() ) && ( featureBounds.
xMaximum() + maximumPointDistanceDelta >= point.
distance() ) )
196 switch ( feature.crossSectionGeometry.type() )
200 for (
auto partIt = feature.crossSectionGeometry.const_parts_begin(); partIt != feature.crossSectionGeometry.const_parts_end(); ++partIt )
202 if (
const QgsPoint *candidatePoint = qgsgeometry_cast< const QgsPoint * >( *partIt ) )
204 const double snapDistanceDelta = std::fabs( point.
distance() - candidatePoint->x() );
205 if ( snapDistanceDelta > maximumPointDistanceDelta )
208 const double snapHeightDelta = std::fabs( point.
elevation() - candidatePoint->y() );
209 if ( snapHeightDelta > maximumPointElevationDelta )
212 const double snapDistance = candidatePoint->distance( targetPoint );
213 visitor( feature.featureId, snapDistance, candidatePoint->x(), candidatePoint->y() );
221 for (
auto partIt = feature.crossSectionGeometry.const_parts_begin(); partIt != feature.crossSectionGeometry.const_parts_end(); ++partIt )
223 if (
const QgsCurve *line = qgsgeometry_cast< const QgsCurve * >( *partIt ) )
226 if (
const QgsLineString *lineString = qgsgeometry_cast< const QgsLineString * >( line ) )
228 if ( lineString->numPoints() == 2 &&
qgsDoubleNear( lineString->pointN( 0 ).x(), lineString->pointN( 1 ).x() ) )
230 const double snapDistanceDelta = std::fabs( point.
distance() - lineString->pointN( 0 ).x() );
231 if ( snapDistanceDelta > maximumPointDistanceDelta )
234 const double snapHeightDelta = std::fabs( point.
elevation() - lineString->pointN( 0 ).y() );
235 if ( snapHeightDelta <= maximumPointElevationDelta )
237 const double snapDistanceP1 = lineString->pointN( 0 ).distance( targetPoint );
238 visitor( feature.featureId, snapDistanceP1, lineString->pointN( 0 ).x(), lineString->pointN( 0 ).y() );
241 const double snapHeightDelta2 = std::fabs( point.
elevation() - lineString->pointN( 1 ).y() );
242 if ( snapHeightDelta2 <= maximumPointElevationDelta )
244 const double snapDistanceP2 = lineString->pointN( 1 ).distance( targetPoint );
245 visitor( feature.featureId, snapDistanceP2, lineString->pointN( 1 ).x(), lineString->pointN( 1 ).y() );
250 double elevation1 = lineString->pointN( 0 ).y();
251 double elevation2 = lineString->pointN( 1 ).y();
252 if ( elevation1 > elevation2 )
253 std::swap( elevation1, elevation2 );
257 const double snapDistance = std::fabs( lineString->pointN( 0 ).x() - point.
distance() );
258 visitor( feature.featureId, snapDistance, lineString->pointN( 0 ).x(), point.
elevation() );
265 const QgsRectangle partBounds = ( *partIt )->boundingBox();
275 const QgsGeometry points( cutLineGeos.intersection( line ) );
277 for (
auto vertexIt = points.vertices_begin(); vertexIt != points.vertices_end(); ++vertexIt )
279 const double snapHeightDelta = std::fabs( point.
elevation() - ( *vertexIt ).y() );
280 if ( snapHeightDelta > maximumSurfaceElevationDelta )
283 const double snapDistance = ( *vertexIt ).distance( targetPoint );
284 visitor( feature.featureId, snapDistance, ( *vertexIt ).x(), ( *vertexIt ).y() );
301 for (
auto partIt = feature.crossSectionGeometry.const_parts_begin(); partIt != feature.crossSectionGeometry.const_parts_end(); ++partIt )
303 if (
const QgsCurve *exterior = qgsgeometry_cast< const QgsPolygon * >( *partIt )->exteriorRing() )
305 const QgsRectangle partBounds = ( *partIt )->boundingBox();
315 const QgsGeometry points( cutLineGeos.intersection( exterior ) );
316 for (
auto vertexIt = points.vertices_begin(); vertexIt != points.vertices_end(); ++vertexIt )
318 const double snapHeightDelta = std::fabs( point.
elevation() - ( *vertexIt ).y() );
319 if ( snapHeightDelta > maximumSurfaceElevationDelta )
322 const double snapDistance = ( *vertexIt ).distance( targetPoint );
323 visitor( feature.featureId, snapDistance, ( *vertexIt ).x(), ( *vertexIt ).y() );
344 profileRangeGeos.prepareGeometry();
348 for (
const Feature &feature : it.value() )
350 if ( feature.crossSectionGeometry.boundingBoxIntersects( profileRange ) )
352 switch ( feature.crossSectionGeometry.type() )
356 for (
auto partIt = feature.crossSectionGeometry.const_parts_begin(); partIt != feature.crossSectionGeometry.const_parts_end(); ++partIt )
358 if (
const QgsPoint *candidatePoint = qgsgeometry_cast< const QgsPoint * >( *partIt ) )
360 if ( profileRange.contains( candidatePoint->x(), candidatePoint->y() ) )
362 visitor( feature.featureId );
372 if ( profileRangeGeos.intersects( feature.crossSectionGeometry.constGet() ) )
374 visitor( feature.featureId );
394 renderResultsAsIndividualFeatures( context );
399 renderMarkersOverContinuousSurfacePlot( context );
412 painter->setBrush( Qt::NoBrush );
413 painter->setPen( Qt::NoPen );
420 const QRectF visibleRegion( minDistance,
minZ, maxDistance - minDistance,
maxZ -
minZ );
421 QPainterPath clipPath;
422 clipPath.addPolygon( context.
worldTransform().map( visibleRegion ) );
423 painter->setClipPath( clipPath, Qt::ClipOperation::IntersectClip );
425 const QgsRectangle clipPathRect( clipPath.boundingRect() );
429 if ( profileFeature.crossSectionGeometry.isEmpty() )
432 QgsGeometry transformed = profileFeature.crossSectionGeometry;
439 switch ( transformed.
type() )
443 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( transformed.
constGet() ) )
445 markerSymbol->renderPoint( QPointF( point->x(), point->y() ),
nullptr, context.
renderContext() );
447 else if (
const QgsMultiPoint *multipoint = qgsgeometry_cast< const QgsMultiPoint * >( transformed.
constGet() ) )
449 const int numGeometries = multipoint->numGeometries();
450 for (
int i = 0; i < numGeometries; ++i )
452 markerSymbol->renderPoint( QPointF( multipoint->pointN( i )->x(), multipoint->pointN( i )->y() ),
nullptr, context.
renderContext() );
460 if (
const QgsLineString *line = qgsgeometry_cast< const QgsLineString * >( transformed.
constGet() ) )
462 lineSymbol->renderPolyline( line->asQPolygonF(),
nullptr, context.
renderContext() );
464 else if (
const QgsMultiLineString *multiLinestring = qgsgeometry_cast< const QgsMultiLineString * >( transformed.
constGet() ) )
466 const int numGeometries = multiLinestring->numGeometries();
467 for (
int i = 0; i < numGeometries; ++i )
469 lineSymbol->renderPolyline( multiLinestring->lineStringN( i )->asQPolygonF(),
nullptr, context.
renderContext() );
477 if (
const QgsPolygon *polygon = qgsgeometry_cast< const QgsPolygon * >( transformed.
constGet() ) )
479 if (
const QgsCurve *exterior = polygon->exteriorRing() )
480 fillSymbol->renderPolygon( exterior->asQPolygonF(),
nullptr,
nullptr, context.
renderContext() );
482 else if (
const QgsMultiPolygon *multiPolygon = qgsgeometry_cast< const QgsMultiPolygon * >( transformed.
constGet() ) )
484 const int numGeometries = multiPolygon->numGeometries();
485 for (
int i = 0; i < numGeometries; ++i )
487 fillSymbol->renderPolygon( multiPolygon->polygonN( i )->exteriorRing()->asQPolygonF(),
nullptr,
nullptr, context.
renderContext() );
504 std::unique_ptr< QgsFeatureRenderer > renderer(
mLayer->renderer()->clone() );
509 QSet<QString> attributes = renderer->usedAttributes( context.
renderContext() );
511 std::unique_ptr< QgsMarkerSymbol > marker(
mMarkerSymbol->clone() );
512 std::unique_ptr< QgsLineSymbol > line(
mLineSymbol->clone() );
513 std::unique_ptr< QgsFillSymbol > fill(
mFillSymbol->clone() );
514 attributes.unite( marker->usedAttributes( context.
renderContext() ) );
515 attributes.unite( line->usedAttributes( context.
renderContext() ) );
516 attributes.unite( fill->usedAttributes( context.
renderContext() ) );
526 if ( !rendererSymbol )
530 marker->setOpacity( rendererSymbol->
opacity() );
531 line->setColor( rendererSymbol->
color() );
532 line->setOpacity( rendererSymbol->
opacity() );
533 fill->setColor( rendererSymbol->
color() );
534 fill->setOpacity( rendererSymbol->
opacity() );
540 const QVector< Feature > profileFeatures =
features.value( feature.
id() );
541 for (
const Feature &profileFeature : profileFeatures )
543 renderResult( profileFeature,
545 rendererSymbol->
type() ==
Qgis::SymbolType::Line ? qgis::down_cast<
QgsLineSymbol * >( rendererSymbol ) : line.get(),
546 rendererSymbol->
type() ==
Qgis::SymbolType::Fill ? qgis::down_cast<
QgsFillSymbol * >( rendererSymbol ) : fill.get() );
558 QSet<QString> attributes;
573 const QVector< Feature > profileFeatures =
features.value( feature.
id() );
574 for (
const Feature &profileFeature : profileFeatures )
593 painter->setBrush( Qt::NoBrush );
594 painter->setPen( Qt::NoPen );
601 const QRectF visibleRegion( minDistance,
minZ, maxDistance - minDistance,
maxZ -
minZ );
602 QPainterPath clipPath;
603 clipPath.addPolygon( context.
worldTransform().map( visibleRegion ) );
604 painter->setClipPath( clipPath, Qt::ClipOperation::IntersectClip );
610 if ( std::isnan( pointIt.value() ) )
620 QVector<QgsAbstractProfileResults::Feature> res;
627 for (
const Feature &feature : it.value() )
634 outFeature.
attributes = {{QStringLiteral(
"id" ), feature.featureId }};
642 outFeature.
geometry = feature.crossSectionGeometry;
659 mId = vlGenerator->mId;
662 mMarkerSymbol.reset( vlGenerator->mProfileMarkerSymbol->clone() );
674 , mProfileCurve( request.profileCurve() ? request.profileCurve()->clone() : nullptr )
675 , mTerrainProvider( request.terrainProvider() ? request.terrainProvider()->clone() : nullptr )
676 , mTolerance( request.tolerance() )
677 , mSourceCrs( layer->crs3D() )
678 , mTargetCrs( request.
crs() )
679 , mTransformContext( request.transformContext() )
680 , mExtent( layer->extent() )
682 , mOffset( layer->elevationProperties()->zOffset() )
683 , mScale( layer->elevationProperties()->zScale() )
689 , mExpressionContext( request.expressionContext() )
690 , mFields( layer->fields() )
691 , mDataDefinedProperties( layer->elevationProperties()->dataDefinedProperties() )
692 , mWkbType( layer->wkbType() )
698 if ( mTerrainProvider )
699 mTerrainProvider->prepare();
703 mProfileCurve->dropZValue();
721 if ( !mProfileCurve || mFeedback->isCanceled() )
725 mTransformedCurve.reset( mProfileCurve->clone() );
727 if ( mTerrainProvider )
728 mTargetToTerrainProviderTransform =
QgsCoordinateTransform( mTargetCrs, mTerrainProvider->crs(), mTransformContext );
736 QgsDebugError( QStringLiteral(
"Error transforming profile line to vector CRS" ) );
740 const QgsRectangle profileCurveBoundingBox = mTransformedCurve->boundingBox();
741 if ( !profileCurveBoundingBox.
intersects( mExtent ) )
744 if ( mFeedback->isCanceled() )
747 mResults = std::make_unique< QgsVectorLayerProfileResults >();
748 mResults->mLayer = mLayer;
749 mResults->copyPropertiesFromGenerator(
this );
751 mProfileCurveEngine.reset(
new QgsGeos( mProfileCurve.get() ) );
752 mProfileCurveEngine->prepareGeometry();
754 if ( mTolerance == 0.0 )
756 mProfileBufferedCurve = std::unique_ptr<QgsAbstractGeometry>( mProfileCurve->clone() );
763 mProfileBufferedCurveEngine.reset(
new QgsGeos( mProfileBufferedCurve.get() ) );
764 mProfileBufferedCurveEngine->prepareGeometry();
766 mDataDefinedProperties.
prepare( mExpressionContext );
768 if ( mFeedback->isCanceled() )
774 if ( !generateProfileForPoints() )
779 if ( !generateProfileForLines() )
784 if ( !generateProfileForPolygons() )
798 return mResults.release();
803 return mFeedback.get();
806bool QgsVectorLayerProfileGenerator::generateProfileForPoints()
821 while ( !mFeedback->isCanceled() && it.
nextFeature( feature ) )
828 if ( mProfileBufferedCurveEngine->intersects( *it ) )
830 processIntersectionPoint( qgsgeometry_cast< const QgsPoint * >( *it ), feature );
834 return !mFeedback->isCanceled();
837void QgsVectorLayerProfileGenerator::processIntersectionPoint(
const QgsPoint *point,
const QgsFeature &feature )
842 const double height = featureZToHeight( point->
x(), point->
y(), point->
z(), offset );
843 mResults->mRawPoints.append(
QgsPoint( point->
x(), point->
y(), height ) );
844 mResults->minZ = std::min( mResults->minZ, height );
845 mResults->maxZ = std::max( mResults->maxZ, height );
847 const double distanceAlongProfileCurve = mProfileCurveEngine->lineLocatePoint( *point, &error );
848 mResults->mDistanceToHeightMap.insert( distanceAlongProfileCurve, height );
852 if ( mExtrusionEnabled )
857 QgsPoint( point->
x(), point->
y(), height + extrusion ) ) );
859 QgsPoint( distanceAlongProfileCurve, height + extrusion ) ) );
860 mResults->minZ = std::min( mResults->minZ, height + extrusion );
861 mResults->maxZ = std::max( mResults->maxZ, height + extrusion );
869 mResults->features[resultFeature.
featureId].append( resultFeature );
872void QgsVectorLayerProfileGenerator::processIntersectionCurve(
const QgsLineString *intersectionCurve,
const QgsFeature &feature )
878 double maxDistanceAlongProfileCurve = std::numeric_limits<double>::lowest();
883 const int numPoints = intersectionCurve->
numPoints();
884 QVector< double > newX( numPoints );
885 QVector< double > newY( numPoints );
886 QVector< double > newZ( numPoints );
887 QVector< double > newDistance( numPoints );
889 const double *inX = intersectionCurve->
xData();
890 const double *inY = intersectionCurve->
yData();
891 const double *inZ = intersectionCurve->
is3D() ? intersectionCurve->
zData() :
nullptr;
892 double *outX = newX.data();
893 double *outY = newY.data();
894 double *outZ = newZ.data();
895 double *outDistance = newDistance.data();
897 QVector< double > extrudedZ;
898 double *extZOut =
nullptr;
899 if ( mExtrusionEnabled )
901 extrudedZ.resize( numPoints );
902 extZOut = extrudedZ.data();
905 for (
int i = 0 ; ! mFeedback->isCanceled() && i < numPoints; ++i )
907 QgsPoint intersectionPoint( *inX, *inY, ( inZ ? *inZ : std::numeric_limits<double>::quiet_NaN() ) );
909 const double height = featureZToHeight( intersectionPoint.
x(), intersectionPoint.
y(), intersectionPoint.
z(), offset );
910 const double distanceAlongProfileCurve = mProfileCurveEngine->lineLocatePoint( intersectionPoint, &error );
912 maxDistanceAlongProfileCurve = std::max( maxDistanceAlongProfileCurve, distanceAlongProfileCurve );
914 mResults->mRawPoints.append(
QgsPoint( intersectionPoint.
x(), intersectionPoint.
y(), height ) );
915 mResults->minZ = std::min( mResults->minZ, height );
916 mResults->maxZ = std::max( mResults->maxZ, height );
918 mResults->mDistanceToHeightMap.insert( distanceAlongProfileCurve, height );
919 *outDistance++ = distanceAlongProfileCurve;
921 *outX++ = intersectionPoint.
x();
922 *outY++ = intersectionPoint.
y();
925 *extZOut++ = height + extrusion;
927 if ( mExtrusionEnabled )
929 mResults->minZ = std::min( mResults->minZ, height + extrusion );
930 mResults->maxZ = std::max( mResults->maxZ, height + extrusion );
938 mResults->mDistanceToHeightMap.insert( maxDistanceAlongProfileCurve + 0.000001, std::numeric_limits<double>::quiet_NaN() );
940 if ( mFeedback->isCanceled() )
944 if ( mExtrusionEnabled )
946 std::unique_ptr< QgsLineString > ring = std::make_unique< QgsLineString >( newX, newY, newZ );
947 std::unique_ptr< QgsLineString > extrudedRing = std::make_unique< QgsLineString >( newX, newY, extrudedZ );
948 std::unique_ptr< QgsLineString > reversedExtrusion( extrudedRing->reversed() );
949 ring->append( reversedExtrusion.get() );
953 std::unique_ptr< QgsLineString > distanceVHeightRing = std::make_unique< QgsLineString >( newDistance, newZ );
954 std::unique_ptr< QgsLineString > extrudedDistanceVHeightRing = std::make_unique< QgsLineString >( newDistance, extrudedZ );
955 std::unique_ptr< QgsLineString > reversedDistanceVHeightExtrusion( extrudedDistanceVHeightRing->reversed() );
956 distanceVHeightRing->append( reversedDistanceVHeightExtrusion.get() );
957 distanceVHeightRing->close();
966 mResults->features[resultFeature.
featureId].append( resultFeature );
969bool QgsVectorLayerProfileGenerator::generateProfileForLines()
974 if ( mTolerance > 0 )
985 auto processCurve = [
this](
const QgsFeature & feature,
const QgsCurve * featGeomPart )
988 std::unique_ptr< QgsAbstractGeometry > intersection( mProfileBufferedCurveEngine->intersection( featGeomPart, &error ) );
992 if ( mFeedback->isCanceled() )
997 if ( intersection->isEmpty() )
999 intersection.reset( featGeomPart->clone() );
1002 QgsGeos featGeomPartGeos( featGeomPart );
1003 featGeomPartGeos.prepareGeometry();
1005 for (
auto it = intersection->const_parts_begin();
1006 !mFeedback->isCanceled() && it != intersection->const_parts_end();
1009 if (
const QgsPoint *intersectionPoint = qgsgeometry_cast< const QgsPoint * >( *it ) )
1013 const double distance = featGeomPartGeos.lineLocatePoint( *intersectionPoint, &error );
1014 std::unique_ptr< QgsPoint > interpolatedPoint( featGeomPart->interpolatePoint( distance ) );
1016 processIntersectionPoint( interpolatedPoint.get(), feature );
1018 else if (
const QgsLineString *intersectionCurve = qgsgeometry_cast< const QgsLineString * >( *it ) )
1020 processIntersectionCurve( intersectionCurve, feature );
1027 while ( !mFeedback->isCanceled() && it.
nextFeature( feature ) )
1034 if ( mProfileBufferedCurveEngine->intersects( *it ) )
1036 processCurve( feature, qgsgeometry_cast< const QgsCurve * >( *it ) );
1041 return !mFeedback->isCanceled();
1044QgsPoint QgsVectorLayerProfileGenerator::interpolatePointOnTriangle(
const QgsPolygon *triangle,
double x,
double y )
const
1051 const double z = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, p1.
z(), p2.
z(), p3.
z(),
QgsPointXY( x, y ) );
1055void QgsVectorLayerProfileGenerator::processTriangleIntersectForPoint(
const QgsPolygon *triangle,
const QgsPoint *p, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts )
1057 const QgsPoint interpolatedPoint = interpolatePointOnTriangle( triangle, p->
x(), p->
y() );
1058 mResults->mRawPoints.append( interpolatedPoint );
1059 mResults->minZ = std::min( mResults->minZ, interpolatedPoint.
z() );
1060 mResults->maxZ = std::max( mResults->maxZ, interpolatedPoint.
z() );
1063 const double distance = mProfileCurveEngine->lineLocatePoint( *p, &lastError );
1064 mResults->mDistanceToHeightMap.insert( distance, interpolatedPoint.
z() );
1066 if ( mExtrusionEnabled )
1071 QgsPoint( interpolatedPoint.
x(), interpolatedPoint.
y(), interpolatedPoint.
z() + extrusion ) ) ) );
1073 QgsPoint( distance, interpolatedPoint.
z() + extrusion ) ) ) );
1074 mResults->minZ = std::min( mResults->minZ, interpolatedPoint.
z() + extrusion );
1075 mResults->maxZ = std::max( mResults->maxZ, interpolatedPoint.
z() + extrusion );
1084void QgsVectorLayerProfileGenerator::processTriangleIntersectForLine(
const QgsPolygon *triangle,
const QgsLineString *intersectionLine, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts )
1089 int numPoints = intersectionLine->
numPoints();
1090 QVector< double > newX( numPoints );
1091 QVector< double > newY( numPoints );
1092 QVector< double > newZ( numPoints );
1093 QVector< double > newDistance( numPoints );
1095 const double *inX = intersectionLine->
xData();
1096 const double *inY = intersectionLine->
yData();
1097 const double *inZ = intersectionLine->
is3D() ? intersectionLine->
zData() :
nullptr;
1098 double *outX = newX.data();
1099 double *outY = newY.data();
1100 double *outZ = newZ.data();
1101 double *outDistance = newDistance.data();
1103 double lastDistanceAlongProfileCurve = 0.0;
1104 QVector< double > extrudedZ;
1105 double *extZOut =
nullptr;
1106 double extrusion = 0;
1108 if ( mExtrusionEnabled )
1110 extrudedZ.resize( numPoints );
1111 extZOut = extrudedZ.data();
1117 for (
int i = 0 ; ! mFeedback->isCanceled() && i < numPoints; ++i )
1121 double z = inZ ? *inZ++ : 0;
1123 QgsPoint interpolatedPoint( x, y, z );
1129 interpolatedPoint = interpolatePointOnTriangle( triangle, x, y );
1131 double tempOutZ = std::isnan( interpolatedPoint.
z() ) ? 0.0 : interpolatedPoint.
z();
1134 if ( mExtrusionEnabled )
1135 *extZOut++ = tempOutZ + extrusion;
1137 mResults->mRawPoints.append( interpolatedPoint );
1138 mResults->minZ = std::min( mResults->minZ, interpolatedPoint.
z() );
1139 mResults->maxZ = std::max( mResults->maxZ, interpolatedPoint.
z() );
1140 if ( mExtrusionEnabled )
1142 mResults->minZ = std::min( mResults->minZ, interpolatedPoint.
z() + extrusion );
1143 mResults->maxZ = std::max( mResults->maxZ, interpolatedPoint.
z() + extrusion );
1146 const double distance = mProfileCurveEngine->lineLocatePoint( interpolatedPoint, &lastError );
1147 *outDistance++ = distance;
1149 mResults->mDistanceToHeightMap.insert( distance, interpolatedPoint.
z() );
1150 lastDistanceAlongProfileCurve = distance;
1154 mResults->mDistanceToHeightMap.insert( lastDistanceAlongProfileCurve + 0.000001, std::numeric_limits<double>::quiet_NaN() );
1156 if ( mFeedback->isCanceled() )
1159 if ( mExtrusionEnabled )
1161 std::unique_ptr< QgsLineString > ring = std::make_unique< QgsLineString >( newX, newY, newZ );
1162 std::unique_ptr< QgsLineString > extrudedRing = std::make_unique< QgsLineString >( newX, newY, extrudedZ );
1163 std::unique_ptr< QgsLineString > reversedExtrusion( extrudedRing->reversed() );
1164 ring->append( reversedExtrusion.get() );
1168 std::unique_ptr< QgsLineString > distanceVHeightRing = std::make_unique< QgsLineString >( newDistance, newZ );
1169 std::unique_ptr< QgsLineString > extrudedDistanceVHeightRing = std::make_unique< QgsLineString >( newDistance, extrudedZ );
1170 std::unique_ptr< QgsLineString > reversedDistanceVHeightExtrusion( extrudedDistanceVHeightRing->reversed() );
1171 distanceVHeightRing->append( reversedDistanceVHeightExtrusion.get() );
1172 distanceVHeightRing->close();
1182void QgsVectorLayerProfileGenerator::processTriangleIntersectForPolygon(
const QgsPolygon *sourcePolygon,
const QgsPolygon *intersectionPolygon, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts )
1184 bool oldExtrusion = mExtrusionEnabled;
1217 mExtrusionEnabled =
false;
1218 if ( mProfileBufferedCurveEngine->contains( sourcePolygon ) )
1222 QgsLineString *exteriorLine = qgsgeometry_cast<QgsLineString *>( exterior );
1223 processTriangleIntersectForLine( sourcePolygon, exteriorLine, transformedParts, crossSectionParts );
1228 processTriangleIntersectForLine( sourcePolygon, interiorLine, transformedParts, crossSectionParts );
1236 QgsLineString *exteriorLine = qgsgeometry_cast<QgsLineString *>( exterior )->
clone();
1238 processTriangleIntersectForLine( sourcePolygon, exteriorLine, transformedParts, crossSectionParts );
1239 delete exteriorLine;
1244 if ( mProfileBufferedCurveEngine->contains( interiorLine ) )
1246 processTriangleIntersectForLine( sourcePolygon, interiorLine, transformedParts, crossSectionParts );
1250 interiorLine = qgsgeometry_cast<QgsLineString *>( intersectionPolygon->
interiorRing( i ) )->
clone();
1252 processTriangleIntersectForLine( sourcePolygon, interiorLine, transformedParts, crossSectionParts );
1253 delete interiorLine;
1258 mExtrusionEnabled = oldExtrusion;
1261bool QgsVectorLayerProfileGenerator::generateProfileForPolygons()
1266 if ( mTolerance > 0 )
1277 std::function< void(
const QgsPolygon *triangle,
const QgsAbstractGeometry *intersect, QVector< QgsGeometry > &, QVector< QgsGeometry > & ) > processTriangleLineIntersect;
1278 processTriangleLineIntersect = [
this](
const QgsPolygon * triangle,
const QgsAbstractGeometry * intersection, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts )
1280 for (
auto it = intersection->const_parts_begin();
1281 ! mFeedback->isCanceled() && it != intersection->const_parts_end();
1288 if (
const QgsPoint *p = qgsgeometry_cast< const QgsPoint * >( *it ) )
1290 processTriangleIntersectForPoint( triangle, p, transformedParts, crossSectionParts );
1295 if (
const QgsLineString *intersectionLine = qgsgeometry_cast< const QgsLineString * >( *it ) )
1297 processTriangleIntersectForLine( triangle, intersectionLine, transformedParts, crossSectionParts );
1302 if (
const QgsPolygon *poly = qgsgeometry_cast< const QgsPolygon * >( *it ) )
1304 processTriangleIntersectForPolygon( triangle, poly, transformedParts, crossSectionParts );
1315 auto triangleIsCollinearInXYPlane = [](
const QgsPolygon * polygon )->
bool
1317 const QgsLineString *ring = qgsgeometry_cast< const QgsLineString * >( polygon->exteriorRing() );
1319 ring->
xAt( 1 ), ring->
yAt( 1 ),
1320 ring->
xAt( 2 ), ring->
yAt( 2 ), 0.005 );
1323 auto processPolygon = [
this, &processTriangleLineIntersect, &triangleIsCollinearInXYPlane](
const QgsCurvePolygon * polygon, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts,
double offset,
bool & wasCollinear )
1325 std::unique_ptr< QgsPolygon > clampedPolygon;
1326 if (
const QgsPolygon *p = qgsgeometry_cast< const QgsPolygon * >( polygon ) )
1328 clampedPolygon.reset( p->
clone() );
1332 clampedPolygon.reset( qgsgeometry_cast< QgsPolygon * >( polygon->segmentize() ) );
1334 clampAltitudes( clampedPolygon.get(), offset );
1336 if ( mFeedback->isCanceled() )
1339 if ( mTolerance > 0.0 )
1342 if ( mProfileBufferedCurveEngine->intersects( clampedPolygon.get(), &error ) )
1344 std::unique_ptr< QgsAbstractGeometry > intersection;
1345 intersection.reset( mProfileBufferedCurveEngine->intersection( clampedPolygon.get(), &error ) );
1346 if ( error.isEmpty() )
1348 processTriangleLineIntersect( clampedPolygon.get(), intersection.get(), transformedParts, crossSectionParts );
1355 QgsLineString *ring = qgsgeometry_cast< QgsLineString * >( clampedPolygon->exteriorRing() );
1357 QVector< double > newX( numPoints );
1358 QVector< double > newY( numPoints );
1359 QVector< double > newZ( numPoints );
1360 double *outX = newX.data();
1361 double *outY = newY.data();
1362 double *outZ = newZ.data();
1364 const double *inX = ring->
xData();
1365 const double *inY = ring->
yData();
1366 const double *inZ = ring->
zData();
1367 for (
int i = 0 ; ! mFeedback->isCanceled() && i < ring->numPoints() - 1; ++i )
1369 *outX++ = inX[i] + i * 1.0e-9;
1370 *outY++ = inY[i] + i * 1.0e-9;
1373 std::unique_ptr< QgsPolygon > shiftedPoly;
1376 intersection.reset( mProfileBufferedCurveEngine->intersection( shiftedPoly.get(), &error ) );
1377 if ( intersection.get() )
1378 processTriangleLineIntersect( clampedPolygon.get(), intersection.get(), transformedParts, crossSectionParts );
1380 QgsDebugMsgLevel( QStringLiteral(
"processPolygon after shift bad geom! error: %1" ).arg( error ), 0 );
1388 if ( clampedPolygon->numInteriorRings() == 0 && clampedPolygon->exteriorRing() && clampedPolygon->exteriorRing()->numPoints() == 4 && clampedPolygon->exteriorRing()->isClosed() )
1391 std::unique_ptr< QgsMultiPolygon > multiPolygon = std::make_unique< QgsMultiPolygon >();
1392 multiPolygon->addGeometry( clampedPolygon.release() );
1393 tessellation =
QgsGeometry( std::move( multiPolygon ) );
1397 const QgsRectangle bounds = clampedPolygon->boundingBox();
1399 t.addPolygon( *clampedPolygon, 0 );
1402 if ( mFeedback->isCanceled() )
1409 const int numTriangles = qgsgeometry_cast< const QgsMultiPolygon * >( tessellation.
constGet() )->numGeometries();
1410 for (
int i = 0; ! mFeedback->isCanceled() && i < numTriangles; ++i )
1412 const QgsPolygon *triangle = qgsgeometry_cast< const QgsPolygon * >( qgsgeometry_cast< const QgsMultiPolygon * >( tessellation.
constGet() )->geometryN( i ) );
1414 if ( triangleIsCollinearInXYPlane( triangle ) )
1416 wasCollinear =
true;
1417 const QgsLineString *ring = qgsgeometry_cast< const QgsLineString * >( polygon->exteriorRing() );
1420 if (
const QgsLineString *ls = qgsgeometry_cast< const QgsLineString * >( mProfileCurve.get() ) )
1422 for (
int curveSegmentIndex = 0; curveSegmentIndex < mProfileCurve->numPoints() - 1; ++curveSegmentIndex )
1424 const QgsPoint p1 = ls->pointN( curveSegmentIndex );
1425 const QgsPoint p2 = ls->pointN( curveSegmentIndex + 1 );
1428 double minZ = std::numeric_limits< double >::max();
1429 double maxZ = std::numeric_limits< double >::lowest();
1431 for (
auto vertexPair : std::array<std::pair<int, int>, 3> {{ { 0, 1}, {1, 2}, {2, 0} }} )
1433 bool isIntersection =
false;
1437 const double intersectionZ = ring->
zAt( vertexPair.first ) + ( ring->
zAt( vertexPair.second ) - ring->
zAt( vertexPair.first ) ) * fraction;
1438 minZ = std::min( minZ, intersectionZ );
1439 maxZ = std::max( maxZ, intersectionZ );
1443 if ( !intersectionPoint.
isEmpty() )
1446 mResults->mRawPoints.append( intersectionPoint );
1447 mResults->minZ = std::min( mResults->minZ, minZ );
1448 mResults->maxZ = std::max( mResults->maxZ, maxZ );
1450 const double distance = mProfileCurveEngine->lineLocatePoint( intersectionPoint, &lastError );
1452 crossSectionParts.append(
QgsGeometry(
new QgsLineString( QVector< double > {distance, distance}, QVector< double > {minZ, maxZ} ) ) );
1454 mResults->mDistanceToHeightMap.insert( distance, minZ );
1455 mResults->mDistanceToHeightMap.insert( distance, maxZ );
1462 QgsDebugError( QStringLiteral(
"Collinear triangles with curved profile lines are not supported yet" ) );
1468 if ( mProfileBufferedCurveEngine->intersects( triangle, &error ) )
1470 std::unique_ptr< QgsAbstractGeometry > intersection( mProfileBufferedCurveEngine->intersection( triangle, &error ) );
1471 processTriangleLineIntersect( triangle, intersection.get(), transformedParts, crossSectionParts );
1481 while ( ! mFeedback->isCanceled() && it.
nextFeature( feature ) )
1483 if ( !mProfileBufferedCurveEngine->intersects( feature.
geometry().
constGet() ) )
1490 QVector< QgsGeometry > transformedParts;
1491 QVector< QgsGeometry > crossSectionParts;
1492 bool wasCollinear =
false;
1497 if ( mProfileBufferedCurveEngine->intersects( *it ) )
1499 if (
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast< const QgsCurvePolygon * >( *it ) )
1501 processPolygon( curvePolygon, transformedParts, crossSectionParts, offset, wasCollinear );
1503 else if (
const QgsPolyhedralSurface *polySurface = qgsgeometry_cast< const QgsPolyhedralSurface * >( *it ) )
1505 for (
int i = 0; i < polySurface->numPatches(); ++i )
1507 const QgsPolygon *polygon = polySurface->patchN( i );
1508 if ( mProfileBufferedCurveEngine->intersects( polygon ) )
1510 processPolygon( polygon, transformedParts, crossSectionParts, offset, wasCollinear );
1516 QgsDebugError( QStringLiteral(
"Unhandled Geometry type: %1" ).arg( ( *it )->wktTypeStr() ) );
1521 if ( mFeedback->isCanceled() )
1528 if ( !crossSectionParts.empty() )
1530 if ( !wasCollinear )
1551 mResults->features[resultFeature.
featureId].append( resultFeature );
1556double QgsVectorLayerProfileGenerator::terrainHeight(
double x,
double y )
1558 if ( !mTerrainProvider )
1559 return std::numeric_limits<double>::quiet_NaN();
1569 return std::numeric_limits<double>::quiet_NaN();
1572 return mTerrainProvider->heightAt( x, y );
1575double QgsVectorLayerProfileGenerator::featureZToHeight(
double x,
double y,
double z,
double offset )
1577 switch ( mClamping )
1585 const double terrainZ = terrainHeight( x, y );
1586 if ( !std::isnan( terrainZ ) )
1588 switch ( mClamping )
1591 if ( std::isnan( z ) )
1609 return ( std::isnan( z ) ? 0 : z ) * mScale + offset;
1612void QgsVectorLayerProfileGenerator::clampAltitudes(
QgsLineString *lineString,
const QgsPoint ¢roid,
double offset )
1616 if ( mFeedback->isCanceled() )
1619 double terrainZ = 0;
1620 switch ( mClamping )
1629 pt.
setX( lineString->
xAt( i ) );
1630 pt.
setY( lineString->
yAt( i ) );
1634 pt.
set( centroid.
x(), centroid.
y() );
1638 terrainZ = terrainHeight( pt.
x(), pt.
y() );
1648 switch ( mClamping )
1652 geomZ = lineString->
zAt( i );
1659 const double z = ( terrainZ + ( std::isnan( geomZ ) ? 0 : geomZ ) ) * mScale + offset;
1660 lineString->
setZAt( i, z );
1664bool QgsVectorLayerProfileGenerator::clampAltitudes(
QgsPolygon *polygon,
double offset )
1666 if ( !polygon->
is3D() )
1681 QgsLineString *lineString = qgsgeometry_cast<QgsLineString *>( curve );
1685 clampAltitudes( lineString, centroid, offset );
1689 if ( mFeedback->isCanceled() )
1693 QgsLineString *lineString = qgsgeometry_cast<QgsLineString *>( curve );
1697 clampAltitudes( lineString, centroid, offset );
The Qgis class provides global constants for use throughout the application.
@ Relative
Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation)
@ Terrain
Elevation is clamped to terrain (final elevation = terrain elevation)
@ Absolute
Elevation is taken directly from feature and is independent of terrain height (final elevation = feat...
VertexType
Types of vertex.
@ Round
Use rounded joins.
@ Centroid
Clamp just centroid of feature.
@ Vertex
Clamp every vertex of feature.
@ Flat
Flat cap (in line with start/end of line)
@ ContinuousSurface
The features should be treated as representing values on a continuous surface (eg contour lines)
@ IndividualFeatures
Treat each feature as an individual object (eg buildings)
ProfileExportType
Types of export for elevation profiles.
@ Profile2D
Export profiles as 2D profile lines, with elevation stored in exported geometry Y dimension and dista...
@ Features3D
Export profiles as 3D features, with elevation values stored in exported geometry Z values.
@ DistanceVsElevationTable
Export profiles as a table of sampled distance vs elevation values.
@ Reverse
Reverse/inverse transform (from destination to source)
Abstract base class for all geometries.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
Abstract base class for objects which generate elevation profiles.
Abstract base class for storage of elevation profiles.
Abstract base class for objects which generate elevation profiles which represent a continuous surfac...
std::unique_ptr< QgsLineSymbol > mLineSymbol
Qgis::ProfileSurfaceSymbology mSymbology
std::unique_ptr< QgsFillSymbol > mFillSymbol
std::unique_ptr< QgsFillSymbol > mFillSymbol
QMap< double, double > mDistanceToHeightMap
std::unique_ptr< QgsLineSymbol > mLineSymbol
void renderResults(QgsProfileRenderContext &context) override
Renders the results to the specified context.
void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator) override
Copies properties from specified generator to the results object.
QVector< QgsAbstractProfileResults::Feature > asFeatures(Qgis::ProfileExportType type, QgsFeedback *feedback=nullptr) const override
Returns a list of features representing the calculated elevation results.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context) override
Snaps a point to the generated elevation profile.
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
Abstract base class for curved geometry type.
virtual int numPoints() const =0
Returns the number of points in the curve.
virtual bool pointAt(int node, QgsPoint &point, Qgis::VertexType &type) const =0
Returns the point and vertex id of a point within the curve.
QgsRange which stores a range of double values.
RAII class to pop scope from an expression context on destruction.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform which will be used to transform the feature's geometries.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsFeatureRequest & setDistanceWithin(const QgsGeometry &geometry, double distance)
Sets a reference geometry and a maximum distance from this geometry to retrieve features within.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const
Tells whether the operation has been canceled already.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static double pointFractionAlongLine(double x1, double y1, double x2, double y2, double px, double py)
Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at w...
static bool pointsAreCollinear(double x1, double y1, double x2, double y2, double x3, double y3, double epsilon)
Given the points (x1, y1), (x2, y2) and (x3, y3) returns true if these points can be considered colli...
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
Compute the intersection between two segments.
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries, const QgsGeometryParameters ¶meters=QgsGeometryParameters())
Compute the unary union on a list of geometries.
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
Does vector analysis using the geos library and handles import, export, exception handling*.
Line string geometry type, with support for z-dimension and m-values.
const double * yData() const
Returns a const pointer to the y vertex data.
const double * xData() const
Returns a const pointer to the x vertex data.
const double * zData() const
Returns a const pointer to the z vertex data, or nullptr if the linestring does not have z values.
int numPoints() const override
Returns the number of points in the curve.
QgsPoint pointN(int i) const
Returns the specified point from inside the line string.
int nCoordinates() const override
Returns the number of nodes contained in the geometry.
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
void setZAt(int index, double z)
Sets the z-coordinate of the specified node in the line string.
bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
double zAt(int index) const override
Returns the z-coordinate of the specified node in the line string.
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
A line symbol type, for rendering LineString and MultiLineString geometries.
@ ExtrusionHeight
Extrusion height.
A marker symbol type, for rendering Point and MultiPoint geometries.
Multi line string geometry collection.
Multi point geometry collection.
Multi polygon geometry collection.
A class to represent a 2D point.
void setY(double y)
Sets the y value of the point.
void set(double x, double y)
Sets the x and y value of the point.
void setX(double x)
Sets the x value of the point.
Point geometry type, with support for z-dimension and m-values.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
bool isEmpty() const override
Returns true if the geometry is empty.
Polyhedral surface geometry type.
Encapsulates the context in which an elevation profile is to be generated.
Encapsulates the context of identifying profile results.
double maximumPointElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a point.
double maximumPointDistanceDelta
Maximum allowed snapping delta for the distance values when identifying a point.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a continuous elevation surfa...
Stores identify results generated by a QgsAbstractProfileResults object.
Encapsulates a point on a distance-elevation profile.
double elevation() const
Returns the elevation of the point.
double distance() const
Returns the distance of the point.
Abstract base class for storage of elevation profiles.
const QTransform & worldTransform() const
Returns the transform from world coordinates to painter coordinates.
QgsDoubleRange elevationRange() const
Returns the range of elevations to include in the render.
QgsDoubleRange distanceRange() const
Returns the range of distances to include in the render.
QgsRenderContext & renderContext()
Returns a reference to the component QgsRenderContext.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Encapsulates the context of snapping a profile point.
double maximumPointDistanceDelta
Maximum allowed snapping delta for the distance values when snapping to a point.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a continuous elevation surfa...
double maximumPointElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a point.
Encapsulates results of snapping a profile point.
QgsProfilePoint snappedPoint
Snapped point.
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const final
Prepares the collection against a specified expression context.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const final
Returns the set of any fields referenced by the active properties from the collection.
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
A rectangle specified with double values.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
Scoped object for saving and restoring a QPainter object's state.
Abstract base class for all rendered symbols.
void setColor(const QColor &color) const
Sets the color for the symbol.
qreal opacity() const
Returns the opacity for the symbol.
QColor color() const
Returns the symbol's color.
Qgis::SymbolType type() const
Returns the symbol's type.
Class that takes care of tessellation of polygons into triangles.
Vector layer specific subclass of QgsMapLayerElevationProperties.
Partial snapshot of vector layer's state (only the members necessary for access to features)
Implementation of QgsAbstractProfileGenerator for vector layers.
QgsAbstractProfileResults * takeResults() override
Takes results from the generator.
bool generateProfile(const QgsProfileGenerationContext &context=QgsProfileGenerationContext()) override
Generate the profile (based on data stored in the class).
QString sourceId() const override
Returns a unique identifier representing the source of the profile.
~QgsVectorLayerProfileGenerator() override
QgsFeedback * feedback() const override
Access to feedback object of the generator (may be nullptr)
QgsVectorLayerProfileGenerator(QgsVectorLayer *layer, const QgsProfileRequest &request)
Constructor for QgsVectorLayerProfileGenerator.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
Qgis::VectorProfileType profileType
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol
bool respectLayerSymbology
bool mShowMarkerSymbolInSurfacePlots
QVector< QgsGeometry > asGeometries() const override
Returns a list of geometries representing the calculated elevation results.
QPointer< QgsVectorLayer > mLayer
void renderResults(QgsProfileRenderContext &context) override
Renders the results to the specified context.
QVector< QgsAbstractProfileResults::Feature > asFeatures(Qgis::ProfileExportType type, QgsFeedback *feedback=nullptr) const override
Returns a list of features representing the calculated elevation results.
QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context) override
Snaps a point to the generated elevation profile.
QString type() const override
Returns the unique string identifier for the results type.
QHash< QgsFeatureId, QVector< Feature > > features
void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator) override
Copies properties from specified generator to the results object.
Represents a vector layer which manages a vector based data sets.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
#define BUILTIN_UNREACHABLE
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
const QgsCoordinateReferenceSystem & crs
Encapsulates information about a feature exported from the profile results.
QString layerIdentifier
Identifier for grouping output features.
QVariantMap attributes
Exported attributes.
QgsGeometry geometry
Exported geometry.
QgsGeometry crossSectionGeometry
Cross section distance vs height geometry for feature.
QgsFeatureId featureId
Original feature ID.
QgsGeometry geometry
Feature's geometry with any terrain height adjustment and extrusion applied.
Utility class for identifying a unique vertex within a geometry.