QGIS API Documentation 4.3.0-Master (96c7fa699b4)
Loading...
Searching...
No Matches
qgsvectorlayerprofilegenerator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerprofilegenerator.h
3 ---------------
4 begin : March 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSVECTORLAYERPROFILEGENERATOR_H
18#define QGSVECTORLAYERPROFILEGENERATOR_H
19
20#include <memory>
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
28#include "qgsfeatureid.h"
29#include "qgsfillsymbol.h"
30#include "qgslinesymbol.h"
31#include "qgsmarkersymbol.h"
32
33#define SIP_NO_FILE
34
36class QgsCurve;
37class QgsVectorLayer;
40class QgsGeos;
41class QgsLineString;
42class QgsPolygon;
44
45
54{
55 public:
65
66 QHash< QgsFeatureId, QVector< Feature > > features;
67 QMap< double, QgsFeatureId > mDistanceToFeatureId;
68 QPointer< QgsVectorLayer > mLayer;
69
72 std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
74
75 QString type() const override;
76 QVector< QgsGeometry > asGeometries() const override;
77 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const override;
78 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context ) override;
79 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
80 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context ) override;
81 void renderResults( QgsProfileRenderContext &context ) override;
82 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
83
84 private:
85 void renderResultsAsIndividualFeatures( QgsProfileRenderContext &context );
86 void renderMarkersOverContinuousSurfacePlot( QgsProfileRenderContext &context );
87 QVector< QgsAbstractProfileResults::Feature > asIndividualFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const;
88 QgsProfileSnapResult snapPointToIndividualFeatures( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
89
90 void visitFeaturesAtPoint(
91 const QgsProfilePoint &point,
92 double maximumPointDistanceDelta,
93 double maximumPointElevationDelta,
94 double maximumSurfaceElevationDelta,
95 const std::function< void( QgsFeatureId, double delta, double distance, double elevation ) > &visitor,
96 bool visitWithin
97 ) const;
98 void visitFeaturesInRange( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const std::function<void( QgsFeatureId )> &visitor ) const;
99};
100
101
110{
111 public:
116
118
119 QString sourceId() const override;
122 QgsFeedback *feedback() const override;
123 QString type() const override;
124
125 private:
126 // We may need to split mProfileCurve into multiple parts, this will be
127 // called for each part.
128 bool generateProfileInner( const QgsProfileGenerationContext &context = QgsProfileGenerationContext() );
129
130 bool generateProfileForPoints();
131 bool generateProfileForLines();
132 bool generateProfileForPolygons();
133
134 void processIntersectionPoint( const QgsPoint *intersectionPoint, const QgsFeature &feature );
135 void processIntersectionCurve( const QgsLineString *intersectionCurve, const QgsFeature &feature );
136
137 QgsPoint interpolatePointOnTriangle( const QgsPolygon *triangle, double x, double y ) const;
138 void processTriangleIntersectForPoint(
139 const QgsPolygon *triangle, const QgsPoint *intersect, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts, const QgsFeatureId featureId
140 );
141 void processTriangleIntersectForLine(
142 const QgsPolygon *triangle, const QgsLineString *intersect, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts, const QgsFeatureId featureId
143 );
144 void processTriangleIntersectForPolygon(
145 const QgsPolygon *triangle, const QgsPolygon *intersectionPolygon, QVector< QgsGeometry > &transformedParts, QVector< QgsGeometry > &crossSectionParts, const QgsFeatureId featureId
146 );
147
148 double tolerance() const;
149
150 double terrainHeight( double x, double y ) const;
151 double featureZToHeight( double x, double y, double z, double offset ) const;
152
153 void clampAltitudes( QgsLineString *lineString, const QgsPoint &centroid, double offset ) const;
154 bool clampAltitudes( QgsPolygon *polygon, double offset ) const;
155
156 QString mId;
157 std::unique_ptr<QgsFeedback> mFeedback = nullptr;
158
159 std::unique_ptr< QgsCurve > mProfileCurve;
160 std::unique_ptr< QgsGeos > mProfileCurveEngine;
161
162 std::unique_ptr<QgsAbstractGeometry> mProfileBufferedCurve;
163 std::unique_ptr< QgsGeos > mProfileBufferedCurveEngine;
164
165 std::unique_ptr< QgsAbstractTerrainProvider > mTerrainProvider;
166
167 std::unique_ptr< QgsCurve > mTransformedCurve;
168 double mTolerance = 0;
169
170
173 QgsCoordinateTransformContext mTransformContext;
174 QgsRectangle mExtent;
175
176 std::unique_ptr< QgsVectorLayerFeatureSource > mSource;
177
178 double mOffset = 0;
179 double mScale = 1;
183 bool mExtrusionEnabled = false;
184 double mExtrusionHeight = 0;
185 bool mCustomToleranceEnabled = false;
186 double mCustomTolerance = 0;
187
188 QgsExpressionContext mExpressionContext;
189 QgsFields mFields;
190 QgsPropertyCollection mDataDefinedProperties;
191
193 QgsCoordinateTransform mLayerToTargetTransform;
194 QgsCoordinateTransform mTargetToTerrainProviderTransform;
195
196 std::unique_ptr< QgsVectorLayerProfileResults > mResults;
197 std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
198
199 bool mRespectLayerSymbology = true;
200 std::unique_ptr< QgsMarkerSymbol > mProfileMarkerSymbol;
201 bool mShowMarkerSymbolInSurfacePlots = false;
202
203 // NOT for use in the background thread!
204 QPointer< QgsVectorLayer > mLayer;
205
207};
208
209#endif // QGSVECTORLAYERPROFILEGENERATOR_H
AltitudeClamping
Altitude clamping.
Definition qgis.h:4245
@ Terrain
Elevation is clamped to terrain (final elevation = terrain elevation).
Definition qgis.h:4248
AltitudeBinding
Altitude binding.
Definition qgis.h:4258
@ Centroid
Clamp just centroid of feature.
Definition qgis.h:4260
VectorProfileType
Types of elevation profiles to generate for vector sources.
Definition qgis.h:4663
@ IndividualFeatures
Treat each feature as an individual object (eg buildings).
Definition qgis.h:4664
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4702
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:314
@ Unknown
Unknown.
Definition qgis.h:315
Abstract base class for objects which generate elevation profiles.
Abstract base class for storage of elevation profiles.
virtual QString type() const =0
Returns the unique string identifier for the results type.
QgsAbstractProfileSurfaceGenerator(const QgsProfileRequest &request)
Constructor for QgsAbstractProfileSurfaceGenerator.
Abstract base class for storage of elevation profiles which represent a continuous surface (e....
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< QgsGeometry > asGeometries() const override
Returns a list of geometries 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.
Abstract base class for terrain providers.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Handles coordinate transforms between two coordinate systems.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
QgsRange which stores a range of double values.
Definition qgsrange.h:217
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Container of fields for a vector layer.
Definition qgsfields.h:45
A geometry is the spatial representation of a feature.
Does vector analysis using the GEOS library and handles import, export, and exception handling.
Definition qgsgeos.h:192
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
Polygon geometry type.
Definition qgspolygon.h:37
Encapsulates the context in which an elevation profile is to be generated.
Encapsulates the context of identifying profile results.
Encapsulates a point on a distance-elevation profile.
Abstract base class for storage of elevation profiles.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Encapsulates the context of snapping a profile point.
Encapsulates results of snapping a profile point.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A rectangle specified with double values.
Partial snapshot of vector layer's state (only the members necessary for access to features).
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.
Implementation of QgsAbstractProfileResults for vector layers.
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol
QString type() const override
Returns the unique string identifier for the results type.
QHash< QgsFeatureId, QVector< Feature > > features
QMap< double, QgsFeatureId > mDistanceToFeatureId
Represents a vector layer which manages a vector based dataset.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QgsGeometry crossSectionGeometry
Cross section distance vs height geometry for feature.
QgsGeometry geometry
Feature's geometry with any terrain height adjustment and extrusion applied.