121 Commits

Author SHA1 Message Date
Nyall Dawson
c975764c12 Port processing oriented minimum bounding box alg to QgsGeometry 2016-12-07 20:13:29 +10:00
Nyall Dawson
45a52dfacd Rename minimum area paremeter, fix docs for QgsCurvePolygon::removeInteriorRing 2016-11-29 08:43:23 +10:00
Nyall Dawson
57f482e2d9 Add method to QgsGeometry to remove interior rings from a polygon
With an optional area threshold
2016-11-28 12:08:21 +10:00
Nyall Dawson
b44093914b Fix test failure, report distance from pole 2016-11-14 15:52:41 +10:00
Nyall Dawson
d6f09c012e [FEATURE] Add method to calculate pole of inaccessibility for polygons
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.
2016-11-14 15:52:41 +10:00
Nyall Dawson
d5c307eb05 Add method to find distance from a point to a poylgon's boundary 2016-11-14 15:52:41 +10:00
Martin Dobias
9872b4848d Remove caching of GEOS representation within QgsGeometry (legacy) 2016-11-14 13:36:12 +08:00
Martin Dobias
d729951dcd Remove caching of WKB from QgsGeometry (was kept just for compatibility)
Also improves the API to export/import WKB as QByteArray
2016-11-14 13:36:12 +08:00
Nyall Dawson
f9bb230665 Avoid some QgsGeometry pointer use in QgsGeometry API 2016-11-08 11:09:19 +10:00
Nyall Dawson
983fe24806 Port some API from QgsPoint to QgsPointV2 2016-11-07 12:20:59 +10:00
Martin Dobias
5984b21852 Add missing /Factory/ annotations to geometry classes 2016-11-05 12:13:52 +08:00
Martin Dobias
24fbe1a080 Fix crash in node tool after deleting the whole geometry (fixes #15659)
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)
2016-10-31 12:51:21 +08:00
Nyall Dawson
ef34e393dc Add method to QgsGeometry to extend the start/end of a linestring 2016-10-31 07:56:24 +10:00
Nyall Dawson
49432a8468 Optimise QgsAbstractGeometry
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
2016-10-26 17:22:09 +10:00
Hugo Mercier
67c05b51c2 Fix some /Transfer/ annotations 2016-09-23 15:35:37 +02:00
Nyall Dawson
3c4f46dc79 Remove more code disabled under Qt5
Add todo note for QgsHttpTransaction and disable under docs and
sip bindings
2016-09-21 09:12:54 +10:00
Nyall Dawson
4d60d0cdb5 [FEATURE] Add option to QgsGeometry::smooth to not smooth
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
2016-09-03 08:31:33 +10:00
Patrick Valsecchi
db91330b66 Avoid back and forth with WKB in rendering 2016-08-29 06:55:52 +02:00
Nyall Dawson
986b5313ed Add QgsGeometry method to get bisector of angle at vertex
Sponsored by Andreas Neumann
2016-08-29 11:01:52 +10:00
Nyall Dawson
93c7f5f8b2 Add geometry methods for interpolating angle along geometry
Sponsored by Andreas Neumann
2016-08-29 08:57:10 +10:00
nirvn
2a326ef8ad [FEATURE] support aggregation of geometry
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.
2016-08-24 08:39:05 +07:00
Nyall Dawson
409dfdf539 [FEATURE] Expose GEOS linear referencing function to QgsGeometry
Adds a new QgsGeometry::lineLocatePoint() function for
retrieving the distance along a linestring to the nearest
position on the linestring to a given point.
2016-08-21 20:48:54 +10:00
Nyall Dawson
e3f0d3d88f [FEATURE] Expose GEOS single sided buffer through QgsGeometry
Makes it easy for PyQGIS code to perform a single sided buffer
operation
2016-08-17 06:43:02 +10:00
Martin Dobias
b6d03209b9 Fix closest segment for points (#3383)
* 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
2016-08-11 17:23:01 +02:00
Matthias Kuhn
7ee55a78f1 [pyqt5] Aliases for indistinguishable method overloads (#3099)
See
https://www.riverbankcomputing.com/pipermail/pyqt/2016-May/037500.html
2016-08-10 20:58:39 +02:00
Juergen E. Fischer
3f22a7a77f another scripts/replacev2.sh with minor manual fixes 2016-08-10 12:12:28 +02:00
Juergen E. Fischer
0688621046 scripts/replacev2.sh run 2016-08-10 12:08:52 +02:00
Juergen E. Fischer
8a4574436f replacev2.sh: replace V2 classes and methods 2016-08-10 12:08:52 +02:00
Matthias Kuhn
bb79d13e82 Remove deprecated Qgis::WKBType and API cleanup (#3325)
* 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
2016-08-04 09:10:08 +02:00
Nyall Dawson
d075b128a8 Add missing docs 2016-08-02 07:26:11 +10:00
Nyall Dawson
4b78b1c208 Make all QgsGeometry methods return values, not pointers
Reduces likelihood of crashes and leaks
2016-08-01 22:41:55 +10:00
Nyall Dawson
bd7d913379 Refine QgsFeature geometry getters/setters
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
2016-08-01 16:25:46 +10:00
Nyall Dawson
10c92394e7 [FEATURE] API + expression function for merging linestrings
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.
2016-07-28 20:33:27 +10:00
Nyall Dawson
85f37eebb3 Add method to QgsAbstractGeometryV2 for boundary
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
2016-07-28 08:16:57 +10:00
Nyall Dawson
1a2231f10c Rename QGis class to Qgis, for capitalisation consistency 2016-07-21 22:01:38 +10:00
Juergen E. Fischer
e451b9ad6f indentation and spelling fixes 2016-07-08 12:59:38 +02:00
Nyall Dawson
1729531773 Don't transform z coordinates by default
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
2016-06-30 07:38:13 +10:00
Matthias Kuhn
c07f02d6dc QgsAbstractGeometryV2::wkbType always returns a valid type 2016-06-07 10:37:20 +02:00
Matthias Kuhn
fdb28c09aa More string comparison fixes 2016-06-07 10:37:20 +02:00
Sandro Mani
f077f1a560 Fix QgsCurvePolygon sip bindings 2016-06-07 07:26:34 +10:00
Sandro Mani
2738c5097e Add provider for ArcGIS Map and Feature REST services 2016-06-02 13:36:08 +02:00
Nyall Dawson
0fcff9f2a0 Allow direct QVariant creation from some QGIS metatypes 2016-05-20 09:48:18 +10:00
Marco Hugentobler
c0d12dcdeb [FEATURE]: possibility to set the segmentation tolerance (maximum angle or maximum difference) 2016-05-19 11:02:43 +02:00
Marco Hugentobler
bd6d22d8b6 Update sip bindings 2016-04-29 11:53:34 +02:00
Nyall Dawson
4c704be606 Add geometry methods for calculating the distance to a specified
vertex from the start of the geometry
2016-04-06 20:55:26 +10:00
Nyall Dawson
3a1f6c429d Improve documentation for QgsGeometry::closestVertex 2016-04-06 20:55:26 +10:00
Juergen E. Fischer
e503c705a1 change QgsAbstractGeometryV2::coordinateSequence() to return a
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.
2016-02-21 21:49:51 +01:00
Nyall Dawson
6116fdcdb4 Add a bunch of missing geometry cache clears 2016-02-21 19:55:15 +11:00
Nyall Dawson
50f01a2ac8 Optimise storage/calculation of geometry bounding boxes
- 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.
2016-02-21 16:26:45 +11:00
Juergen E. Fischer
a90be95f7b sip sync 2016-02-14 03:50:49 +01:00