324 Commits

Author SHA1 Message Date
Martí Angelats i Ribera
3f5b11bffe Make asGridified and newSameType (helper function) 2017-10-27 11:22:47 +10:00
lbartoletti
6bcbbeb708 - A triangle can have double points or colinear points, my bad. It is a
degenerate triangle
- remove duplicate tests (triangle2())
2017-10-26 13:30:32 +02:00
Nyall Dawson
55203a0fc2 Merge pull request #5359 from nyalldawson/primitive
Rename (and make safe) QgsGeometry::geometry()
2017-10-26 11:04:34 +11:00
Nyall Dawson
a2f380b2bd Add missing override 2017-10-26 09:13:08 +10:00
Nyall Dawson
a9f8e60064 Merge pull request #5428 from lbartoletti/triangleGML
ADD GML export to QgsTriangle
2017-10-26 08:38:10 +11: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
lbartoletti
7922608ef3 Change the approach: returns an empty element 2017-10-25 15:01:28 +02:00
Sandro Mani
ea0e09b322 Merge pull request #5410 from manisandro/geomchecker
[FEATURE][Geometry checker] Support checking multiple layers at once, add new checks
2017-10-23 23:32:45 +02:00
Nyall Dawson
46a6f25d6f Merge pull request #5418 from nyalldawson/from_polyline
Rename QgsGeometry::fromPolyline as QgsGeometry::fromPolylineXY
2017-10-24 08:21:30 +11:00
Sandro Mani
fde740a3ba Re-add QgsGeometryEngine::combine taking a list of QgsAbstractGeometries 2017-10-23 17:25:08 +02:00
lbartoletti
0d89504ee5 ADD GML export to QgsTriangle 2017-10-23 14:29:08 +02:00
Nyall Dawson
a48c2e8fd4 Merge pull request #4947 from lbartoletti/regularShape_gui
[FEATURE][needs-docs] Add gui to draw Circle, Ellipse, Rectangle and Regular Polygon
2017-10-23 16:04:23 +11: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
Nyall Dawson
c4f3832af2 Rename QgsGeometry::fromPolyline as QgsGeometry::fromPolylineXY
and add new QgsGeometry::fromPolyline which uses QgsPoint

We want to encourage people not to use the QgsPointXY method, as it drops
Z/M values. So it's moved across to a different name to make way
for a new QgsGeometry::fromPolyline which uses a QgsPoint list
instead of QgsPointXY, thus keeping Z/M values intact.

Similarly, QgsPolyline now is a list of QgsPoint (keeping z/m values)
and the old 2d QgsPolyline type was renamed to QgsPolylineXY.

Making the QgsPoint method the "preferred" method and making linestrings
just as easy to create from z/m dimensioned points as 2d points is
important to push people to write code which does not discard
these important dimensions.

As a bonus, the QgsPoint methods are more efficient anyway, since
they don't require creation of a temporary list.
2017-10-22 18:10:14 +10: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
947b0cc49e Safer memory management in geos
Also speed up avoid intersections by removing unnecessary geometry
cloning
2017-10-13 19:55:57 +10:00
Nyall Dawson
c3fdaa950d Some safer memory management for geos 2017-10-13 19:54:00 +10:00
Nyall Dawson
b922166d6e Rework internal geometry memory management
Use unique_ptrs wherever possible, and cleanup geometry
detachments
2017-10-13 19:18:55 +10:00
Etienne Trimaille
098611c3f6 add helper to build a QgsRectangle from a WKT string 2017-10-12 06:32:02 +10: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
4f34f9442c Added better version info to QgsRectangle::buffered 2017-10-04 09:05:21 +10:00
lbartoletti
74e12212f7 @return -> \returns 2017-10-03 18:03:30 +02:00
lbartoletti
870de2e8bb Merge branch 'master' into regularShape_gui 2017-10-03 14:39:12 +02:00
Nyall Dawson
92af1dacaf Replace default constructors/destructors with = default 2017-10-01 06:52:14 +10:00
lbartoletti
a8f9f9f96b Merge branch 'master' into regularShape_gui 2017-09-28 21:48:23 +02:00
lbartoletti
6602855ae4 Merge branch 'master' into regularShape_gui 2017-09-26 21:31:01 +02:00
Nyall Dawson
a87d352bd7 Run clang-tidy modernize-use-default-member-init to move member
initialization to headers (c++11 style)
2017-09-27 05:02:34 +10:00
Nyall Dawson
9518c90a8b Fix multipolygon allowing insertion of non polygon geometries 2017-09-26 12:05:04 +10:00
Nyall Dawson
5ed6605225 Fix multisurface allowing insertion of non surface geometries 2017-09-26 11:28:51 +10:00
Nyall Dawson
4d989f8fb6 Fix clearing multisurface should reset dimensionality 2017-09-26 10:58:32 +10:00
Nyall Dawson
31730f43be Ensure multisurface dimensionality is respected when adding new surfaces 2017-09-26 10:48:12 +10:00
Nyall Dawson
ed90bf4ded Fix multicurve allowing insertion of non curve geometries 2017-09-26 10:12:52 +10:00
Nyall Dawson
c9117fc585 Fix clearing multicurve should reset dimensionality 2017-09-26 09:03:28 +10:00
Nyall Dawson
f5004ed7ef Fix multi line string allowing insertion of non line geometries 2017-09-26 08:33:47 +10:00
Nyall Dawson
ed72e37f0b Fix clearing multilinestring should reset dimensionality 2017-09-26 06:29:36 +10:00
Nyall Dawson
ba50bf043b Fix multi point allowing insertion of non point geometries 2017-09-25 21:20:32 +10:00
Nyall Dawson
97930d13e2 Fix clearing multipoint should reset z/m status 2017-09-25 21:20:06 +10:00
Nyall Dawson
ffbf93a657 Fix incorrect /Transfer/ for geometry collection 2017-09-25 21:19:43 +10:00
Nyall Dawson
d704163884 Rename QgsRectangle::buffer to buffered and mark as const 2017-09-25 17:20:36 +10:00
Nyall Dawson
01d34ede9d Sip sync 2017-09-25 17:12:03 +10:00
Nyall Dawson
e7b08d520e Expand geometry test coverage 2017-09-22 09:54:23 +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
f387210e4a Move QgsPolygonV2 equality operators up to QgsCurvePolygon 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
Nyall Dawson
5bb359db90 Boost test coverage of geometry classes 2017-09-19 17:22:33 +10:00
Nyall Dawson
9b6e79cd18 Expand QgsTriangle test coverage 2017-09-19 17:22:32 +10:00
Nyall Dawson
a15340fc2c Extend geometry test coverage 2017-09-19 17:22:32 +10:00