19 Commits

Author SHA1 Message Date
Nyall Dawson
75885d70d5 Rename various WKT/WKB/GeoJSON/GML methods for consistency
and consistent capitalisation
2017-11-15 20:51:05 +10:00
Nyall Dawson
fc6c69bedf Fix calculation of distance to vertex for multi part, multi ring
and curved geometries
2017-11-14 21:52:28 +11:00
Nyall Dawson
c67e39812d Improvements to QgsAbstractGeometry::snappedToGrid
- Fix loss of coordinates when not rounding a particular dimension
- Don't segmentize curved geometries
- Add extra unit tests
- Make createEmptyWithSameType() protected and skip from Python bindings.
This method relies on low-level manipulation of the returned geometry
which we do not want to expose as public/fixed API
2017-10-27 14:37:35 +10:00
Martí Angelats i Ribera
3f5b11bffe Make asGridified and newSameType (helper function) 2017-10-27 11:22:47 +10:00
Nyall Dawson
70361063d8 Rename QgsGeometry::geometry as QgsGeometry::get()
Because feature.geometry().geometry() is confusing, and impossible
to search for in python code (e.g. is input.geometry() a QgsGeometry
or a QgsAbstractGeometry?)

But more importantantly: also add a const version
QgsGeometry::constGet(). The non-const
version is slow, since it now forces a detach to avoid corrupting
geometries (since QgsGeometry is shared, it's not safe to directly
access its primitive QgsAbstractGeometry and start messing with
it without first detaching). This is a big risk in the 2.x API
which could potentially corrupt feature geometries with unexpected
outcomes.

Update all uses to constGet where possible.
2017-10-26 07:06:34 +10:00
Nyall Dawson
5d675720bb Optimise calculation of QgsGeometry::vertexNrFromVertexId
By moving logic to abstract geometry subclasses so that they
can trivially retrieve the vertex number, instead of relying
on the inefficient coordinateSequence method.

Has flow on speed boosts to many geometry operations like
calculation of closest points in a geometry, which will
benefit snapping related operations.
2017-10-23 08:03:22 +11:00
Nyall Dawson
2e8e72d02d Optimise determination of adjacent vertices and move to QgsAbstractGeometry
Previously the method in QgsGeometryUtils was relying on
QgsAbstractGeometry::coordinateSequence, which is an absolute
performance killer.

Instead move to optimised methods in the various abstract
geometry subclasses which rely only on trivial calculations.
2017-10-23 08:03:22 +11:00
Martin Dobias
7e34beec8c New API for traversal of geometry's vertices using iterator pattern
Introducing:
1. STL-style iterator: QgsAbstractGeometry::vertex_iterator
2. Java-style iterator: QgsVertexIterator (built on top of STL-style)

The iterators are modeled after Qt's STL-style and Java-style iterators,
the idea is to replace nextVertex() method and later introduce iterators
for other bits (e.g. part_iterator, ring_iterator).
2017-10-14 13:23:14 +02:00
Nyall Dawson
01d34ede9d Sip sync 2017-09-25 17:12:03 +10:00
Nyall Dawson
9e61cd63df Move overriden methods from headers to cpp files
Since they can't be inlined anyway
2017-09-19 17:22:33 +10:00
Nyall Dawson
bb425e4540 Cleaner signature for QgsAbstractGeometry::closestSegment 2017-09-19 17:22:33 +10:00
Nyall Dawson
54c988f918 Make QgsAbstractGeometry::toCurveType pure virtual, and implement
for all geometry types

Previously this method would return nullptrs for many geometry
types
2017-09-19 17:22:33 +10:00
Matthias Kuhn
501081f863 Remove unrequired SIP_SKIP 2017-06-14 07:37:31 +02:00
Matthias Kuhn
37a306e3f2 Fix tests 2017-06-14 07:37:31 +02:00
Matthias Kuhn
96cf4b7026 Projecting a 2D point with inclination assumes 0 for Z 2017-06-14 07:37:31 +02:00
Matthias Kuhn
1808dc9c95 More intuitive QgsPoint python constructors
In python, the wkb type of a QgsPoint will by default be determined from
the provided parameters, where Z and M will be added as required if the
wkbType is Undefined.

    QgsPoint(x, y, z=nan, m=nan, wkbType=QgsWkbTypes.Undefined)

Thanks to the python API support of named parameters, it's also
straightforward to specify z, m and wkbType in any desired combination.

On the other hand, on C++ side it's often preferable to use

    QgsPoint(QgsWkbTypes::WkbType wkbType, double x, double y, double z, double m);

due to the lack of named parameters which make it harder to specify a
specific type and the advantage of typesafety that makes it possible to
verload the first constructor with this one.
2017-06-14 07:37:31 +02:00
Matthias Kuhn
4db671e83b Fix sip bindings for QgsPoint 2017-06-14 07:37:31 +02:00
Matthias Kuhn
7e487190e8 Add an easy to use Z/M default value constructor to QgsPoint 2017-06-14 07:37:31 +02:00
Matthias Kuhn
4eae0872ab Fix QgsPoint(XY) sip bindings 2017-06-14 07:37:31 +02:00