QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgsinternalgeometryengine.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsinternalgeometryengine.h - QgsInternalGeometryEngine
3
4 ---------------------
5 begin : 13.1.2016
6 copyright : (C) 2016 by Matthias Kuhn
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSINTERNALGEOMETRYENGINE_H
17#define QGSINTERNALGEOMETRYENGINE_H
18
19
20#include <functional>
21
22#include "qgspointxy.h"
23
24#define SIP_NO_FILE
25
26class QgsGeometry;
28class QgsLineString;
30class QgsFeedback;
31
41
43{
44 public:
45
51 explicit QgsInternalGeometryEngine( const QgsGeometry &geometry );
52
58 QString lastError() const;
59
73 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
74
83 QgsGeometry extrude( double x, double y ) const;
84
94 QgsGeometry poleOfInaccessibility( double precision, double *distanceFromBoundary = nullptr ) const;
95
103 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
104
112 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
113
126 QgsGeometry densifyByDistance( double distance ) const;
127
142 QgsGeometry variableWidthBuffer( int segments, const std::function< std::unique_ptr< double[] >( const QgsLineString *line ) > &widthFunction ) const;
143
158 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
159
170 QgsGeometry variableWidthBufferByM( int segments ) const;
171
192 QVector< QgsPointXY > randomPointsInPolygon( int count,
193 const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 );
194
210 QgsGeometry convertToCurves( double distanceTolerance, double angleTolerance ) const;
211
223 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
224
237 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
238
257 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
258
271 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
272
291 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
292
293
306 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
307
326 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
327
341 QgsGeometry applyDashPattern( const QVector< double > &pattern,
345 double patternOffset = 0 ) const;
346
347 private:
348 const QgsAbstractGeometry *mGeometry = nullptr;
349
350 mutable QString mLastError;
351};
352
359class CORE_EXPORT QgsRay2D
360{
361 public:
362
367 QgsRay2D( const QgsPointXY &origin, QgsVector direction )
368 : origin( origin )
369 , direction( direction )
370 {}
371
379 bool intersects( const QgsLineSegment2D &segment, QgsPointXY &intersectPoint ) const;
380
381 private:
382
383 QgsPointXY origin;
384 QgsVector direction;
385};
386
388
389// adapted for QGIS geometry classes from original work at https://github.com/trylock/visibility by trylock
390
400class CORE_EXPORT QgsLineSegmentDistanceComparer
401{
402 public:
403
408 explicit QgsLineSegmentDistanceComparer( const QgsPointXY &origin )
409 : mOrigin( origin )
410 {}
411
419 bool operator()( QgsLineSegment2D ab, QgsLineSegment2D cd ) const;
420
421 private:
422
423 QgsPointXY mOrigin;
424
425};
426
427
428// adapted for QGIS geometry classes from original work at https://github.com/trylock/visibility by trylock
429
436class CORE_EXPORT QgsClockwiseAngleComparer
437{
438 public:
439 explicit QgsClockwiseAngleComparer( const QgsPointXY &origin )
440 : mVertex( origin )
441 {}
442
443 bool operator()( const QgsPointXY &a, const QgsPointXY &b ) const;
444
445 private:
446
447 QgsPointXY mVertex;
448
449};
450
452
453#endif // QGSINTERNALGEOMETRYENGINE_H
DashPatternSizeAdjustment
Dash pattern size adjustment options.
Definition qgis.h:3377
@ ScaleBothDashAndGap
Both the dash and gap lengths are adjusted equally.
Definition qgis.h:3378
DashPatternLineEndingRule
Dash pattern line ending rules.
Definition qgis.h:3362
@ NoRule
No special rule.
Definition qgis.h:3363
Abstract base class for all geometries.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A geometry is the spatial representation of a feature.
QgsGeometry triangularWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized triangular waves along the boundary of the geometry, with the specified wavelen...
QgsGeometry triangularWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs triangular waves along the boundary of the geometry, with the specified wavelength and amp...
QgsInternalGeometryEngine(const QgsGeometry &geometry)
The caller is responsible that the geometry is available and unchanged for the whole lifetime of this...
QgsGeometry roundWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs rounded (sine-like) waves along the boundary of the geometry, with the specified wavelengt...
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
QgsGeometry squareWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs square waves along the boundary of the geometry, with the specified wavelength and amplitu...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer using the m-values from a (multi)line geometry.
QgsGeometry extrude(double x, double y) const
Will extrude a line or (segmentized) curve by a given offset and return a polygon representation of i...
QgsGeometry roundWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized rounded (sine-like) waves along the boundary of the geometry,...
QgsGeometry orthogonalize(double tolerance=1.0E-8, int maxIterations=1000, double angleThreshold=15.0) const
Attempts to orthogonalize a line or polygon geometry by shifting vertices to make the geometries angl...
QgsGeometry variableWidthBuffer(int segments, const std::function< std::unique_ptr< double[] >(const QgsLineString *line) > &widthFunction) const
Calculates a variable width buffer for a (multi)curve geometry.
QString lastError() const
Returns an error string referring to the last error encountered.
QgsGeometry orientedMinimumBoundingBox(double &area, double &angle, double &width, double &height) const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a tapered width buffer for a (multi)curve geometry.
QVector< QgsPointXY > randomPointsInPolygon(int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr, int maxTriesPerPoint=0)
Returns a list of count random points generated inside a polygon geometry (if acceptPoint is specifie...
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
QgsGeometry applyDashPattern(const QVector< double > &pattern, Qgis::DashPatternLineEndingRule startRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternLineEndingRule endRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternSizeAdjustment adjustment=Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap, double patternOffset=0) const
Applies a dash pattern to a geometry, returning a MultiLineString geometry which is the input geometr...
QgsGeometry squareWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized square waves along the boundary of the geometry, with the specified wavelength ...
QgsGeometry convertToCurves(double distanceTolerance, double angleTolerance) const
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
Represents a single 2D line segment, consisting of a 2D start and end vertex only.
Line string geometry type, with support for z-dimension and m-values.
Represents a 2D point.
Definition qgspointxy.h:62
QgsRay2D(const QgsPointXY &origin, QgsVector direction)
Constructor for a ray starting at the given origin and extending an infinite distance in the specifie...
Represent a 2-dimensional vector.
Definition qgsvector.h:34
#define SIP_OUT
Definition qgis_sip.h:57
QLineF segment(int index, QRectF rect, double radius)