36 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
5d476e51df Use QVector where possible in geometry classes 2017-11-14 21:52:09 +11:00
Nyall Dawson
871f71305d Use clang-tidy modernize-use-default-member-init to modernize initializers 2017-11-11 10:54:44 +10:00
Matthias Kuhn
7f3ad76882
Rename QgsMultiPolygonV2 to QgsMultiPolygon 2017-10-30 09:14:04 +01:00
Matthias Kuhn
3fcdcd87af
Rename QgsMultiPointV2 to QgsMultiPoint 2017-10-30 09:14:04 +01:00
Matthias Kuhn
b6f46eae11
Rename QgsPolygonV2 to QgsPolygon 2017-10-30 09:14:04 +01:00
Nyall Dawson
4372ac2658 [FEATURE][processing] Native c++ snap to grid algorithm
With support for snapping Z/M values, keeping curves
2017-10-27 15:16:15 +10: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
Matthias Kuhn
6b418decd6 Spelling: use vertices rather than vertexes
... because that's what's used almost consistently throughout the codebase.
2017-10-09 10:13:13 +02:00
Denis Rouzaud
6e14854f90 [sipify] remove redundant private sections 2017-10-09 09:51:40 +02:00
Nyall Dawson
92af1dacaf Replace default constructors/destructors with = default 2017-10-01 06:52:14 +10:00
Nyall Dawson
01d34ede9d Sip sync 2017-09-25 17:12:03 +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
639d0640a9
NULL to nullptr 2017-08-12 19:26:20 +02:00
Matthias Kuhn
a6800d6a5a
Add qgsgeometry_cast
Because it
- is faster than dynamic_cast
- doesn't rely on RTTI
- encapsulates type checking in one place
2017-08-12 19:26:20 +02:00
Sandro Santilli
57bf9daaac Document semantic of SegmentationToleranceType
.. and default of QgsCircularString::curveToLine

[ci skip]
2017-06-21 18:35:32 +02:00
Matthias Kuhn
a9d7630a69 Rename QgsPointV2 to QgsPoint and QgsPoint to QgsPointXY
Because 3D coordinates should be the default.

References https://github.com/qgis/qgis3.0_api/issues/36
2017-06-02 19:53:37 +02:00
Denis Rouzaud
8231d7528b sipify QgsExpressionContext, QgsFeatureRequest, QgsOptionalExpression 2017-05-17 15:20:31 +02:00
Martin Dobias
040c4b32f9 Small cleanup of QgsAbstractGeometry header 2017-05-06 20:33:46 +08:00
Matthias Kuhn
28a21209b9 [sipify] seealso 2017-04-30 16:52:05 +02:00
Denis Rouzaud
b0d4a4c201 sipify geometry classes 2017-04-30 11:29:45 +02:00
Nyall Dawson
7c79803cc3 Add missing dynamic cast for QgsTriangle to sip bindings 2017-03-22 10:20:01 +10:00
Nyall Dawson
af0d68b882 Implement QgsGeometry::isEmpty()
Faster than QgsGeometry::isGeosEmpty() because it avoids the
conversion to GEOS geometries and just uses the QgsAbstractGeometry
subclasses directly.

Also implements faster isEmpty() overrides for specific
QgsAbstractGeometry subclasses.
2017-01-31 07:15:51 +10:00
Harrissou Sant-anna
ef85cdcf83 Replace "eg" by "e.g." or "for example" 2016-12-30 00:03:22 +01: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
Martin Dobias
5984b21852 Add missing /Factory/ annotations to geometry classes 2016-11-05 12:13:52 +08: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
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
Juergen E. Fischer
3f22a7a77f another scripts/replacev2.sh with minor manual fixes 2016-08-10 12:12:28 +02:00