Implements a method in QgsGeometry and a processing algorithm to
calculate the pole of inaccessibility for a surface, which is the
most distant internal point from the boundary of the surface. This function
uses the 'polylabel' algorithm (Vladimir Agafonkin, 2016), which is an iterative
approach guaranteed to find the true pole of inaccessibility within a specified
tolerance. More precise tolerances require more iterations and will take longer
to calculate.
Made sure that both closestVertex() and closestSegment() return negative
distance on error (e.g. with null or emtpy geometry).
Also fixes snapping when dealing with layers with null/invalid geometries
(cherry picked from commit c093d5188fad685c4a596ff23c27aad7d151dac2)
Make nCoordinates virtual, and provide shortcuts for some
geometry types. The base method which calls coordinateSequence()
is quite slow in certain circumstances.
Speeds up rendering point layers by ~25%, also likely to
speed up lots of geometry heavy operations throughout QGIS
Refs #15752
segments shorter than a certain threshold or sharp corners
with an angle exceeding a threshold
Expose the angle threshold to processing smooth algorithm
Also:
- optimise QgsGeometry::smooth for new geometry classes
- Fix smooth does not work with geometries containing Z/M
This feature adds a 'collect' aggregation method resulting in a
single multipart geometry from a list of geometries. This is exposed
in the expression engine via the existing aggregate() function,
as well as a new collect() function.
Adds a new QgsGeometry::lineLocatePoint() function for
retrieving the distance along a linestring to the nearest
position on the linestring to a given point.
* Make closestSegment() behave as expected by QgsGeometry::closestSegmentWithContext
This fixes a bug that QgsPointLocator::nearestEdge() would return valid match even for point layers.
* Shortcut if using QgsPointLocator with a wrong layer type
* Remove deprecated Qgis::WKBType and API cleanup
Renames QgsWKBTypes to QgsWkbTypes
Replaces usage of the enums:
* Qgis::WKBType with QgsWkbTypes::Type
* Qgis::GeometryType with QgsWkbTypes::GeometryType
Their values should be forward compatible (a fact that was already
explited up to now by casting between the types)
Renames some SSLxxx to SslXxx and URIxxx to UriXxx
* Fix build warnings and simplify type handling
* Add a fixer to rewrite imports
* The forgotten rebase conflictThe forgotten rebase conflicts
* QgsDataSourcURI > QgsDataSourceUri
* QgsWKBTypes > QgsWkbTypes
* Qgis.WKBGeom > QgsWkbTypes.Geom
* Further python fixes
* Guess what... Qgis::wkbDimensions != QgsWkbTypes::wkbDimensions
* Fix tests
* Python 3 updates
* [travis] pull request caching cannot be disabled
so at least use it in r/w mode
* Fix python3 print in plugins
All pointer based methods have been removed.
Now we have only:
void setGeometry( const QgsGeometry& geom )
and
QgsGeometry geometry() const
Benefits include avoiding a whole lot of tricky pointer lifetime
issues, potential memory leaks, and finally closing #777, which
has survived for over 9 years!...
Impacts on PyQGIS code:
- no more need for the messy
g = QgsGeometry( feature.geometry() )
workaround, just use g = feature.geometry() instead
- IMPORTANT: you can no longer test whether a feature has geometry
using `if f.geometry():`, since QgsFeature::geometry() will
*always* return an object. Instead, use
`if not f.geometry().isEmpty():`, or preferably the new method
`if not f.hasGeometry():`
Fix#777
Adds a new method to QgsGeometry for merging linestrings.
By passing a multilinestring, any connected lines will
be joined into single linestrings. Behind the scenes this
uses GEOS' line merge.
A corresponding expression function "line_merge" has also
been added.
Returns the closure of the combinatorial boundary of the
geometry (ie the topological boundary of the geometry).
For instance, a polygon geometry will have a boundary
consisting of the linestrings for each ring in the polygon.
Follows OGC / SQL/MM specs for boundary calculation
Since z coordinates can represent potentially any height
unit and reference point, it's not safe to assume that they
always represent height in metres relative to the ellipsoid.
Instead, leave z values untouched by default with geometry
transforms, and make transforming z an optional parameter
Refs #14702
implicitly shared copy of an internal cache instead of recreating the
coordinate sequence again and again.
Improves performance of the nodetool on large features a lot (refs #13963)
Also introduce Qgs(Coordinate|Ring|Point)SequenceV2 typedefs.
- removes storage of bounding box from QgsPointV2 (gives significant
decrease in size of object)
- more efficient calculation of bounding box for linestrings
Additionally, this commit moves the bounding box invalidation to a
virtual QgsAbstractGeometryV2::clearCache() method, so that other
non-bounding box caches can also be cleared when the geometry
is modified.