246 Commits

Author SHA1 Message Date
Nyall Dawson
2b6c3c1db2 Fix PyQGIS QgsLineString constructor only accepts lists of QgsPoint,
not QgsPointXY as indicated by the documentation

Also add support for constructing QgsLineString using arrays of
arrays of floats, given that we're having to hand-roll sip conversion
code anyway!

Now the following is supported:

  line = QgsLineString([[1,2], [3,4], [5,6]])

which is much nicer and more "pythonic" then the explicit
QgsPoint/QgsPointXY sequences!

Fixes #43200
2021-05-25 21:07:50 +10:00
Nyall Dawson
adab3fe6a1 Dox 2021-05-24 10:11:37 +10:00
Nyall Dawson
0d768faa43 Add QgsAbstractGeometry::simplifiedTypeRef
Returns a reference to the simplest lossless representation of this geometry,
e.g. if the geometry is a multipart geometry type with a single member geometry,
a reference to that part will be returned.

This method employs the following logic:

- For multipart geometries containing a single part only a direct reference to that part will be returned.
- For compound curve geometries containing a single curve only a direct reference to that curve will be returned.

This method returns a reference only, and does not involve any geometry cloning.
2021-05-24 10:11:37 +10:00
Nyall Dawson
928e3ee2fe Dox 2021-05-05 06:57:58 +10:00
Nyall Dawson
2f77f6f015 Dox++ 2021-05-05 06:57:58 +10:00
Nyall Dawson
755182c134 Expose more geos methods 2021-05-05 06:57:58 +10:00
Loïc Bartoletti
0a48e804c8 dox++ 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
24dba98ab2 fix DocCoverage and Doxygen 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
e837b6f5b5 deprecate and replace setZValueFromPoints by transferFirstZValuteToPoint 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
95cff79cec replace setMValueFromPoints by transferFirstMValuteToPoint 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
4231134f78 add a warning 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
dcfa1bd02d Update setMValueFromPoints dox 2021-04-29 11:15:34 +10:00
Loïc Bartoletti
9e81011908 Adds setMValueFromPoints 2021-04-29 11:15:34 +10:00
Nyall Dawson
f22c63ec77 Rely on upstream GEOS makevalid algorithm for GEOS 3.9+
No point having our own internal fork of this code now that it's
included (and more importantly, maintained) upstream!
2021-04-29 08:45:25 +10:00
Nyall Dawson
1c11a91811 Add QgsGeometry::normalize()
A port of the equivalent method from GEOS, but with added support
for curved geometries and M values

Reorganizes the geometry into a normalized form (or "canonical" form).

Polygon rings will be rearranged so that their starting vertex is
the lower left and ring orientation follows the right hand rule, collections
are ordered by geometry type, and other normalization techniques are applied.
The resultant geometry will be geometrically equivalent to the original geometry.
2021-04-29 05:33:25 +10:00
Nyall Dawson
e3a73a1ac5 Add method to "scroll" the vertices of a closed curve geometry,
so that a particular vertex is the first one
2021-04-29 05:33:25 +10:00
Nyall Dawson
417d444429 Add api to condense compound curves by merging adjacent parts of the
same type to single parts
2021-04-28 11:15:17 +10:00
Nyall Dawson
bab01b1b75 Dox ++ 2021-04-27 21:13:22 +10:00
Nyall Dawson
9c53fb8635 Add QgsAbstractGeometry::compareTo( QgsAbstractGeometry*)
Allows for comparison of geometry objects, e.g. to allow for stable
sorting of them.

Ported from the GEOS equivalent method, but with addition of support
for M values and curved geometry types
2021-04-27 21:13:22 +10:00
Nyall Dawson
36e52f8514 Add method to split QgsCurve geometries into two parts at a specific
vertex index
2021-04-27 19:15:51 +10:00
Nyall Dawson
a9a6e38665 Add QgsCircularString::append( const QgsCircularString* )
Appends the contents of one circular string to the end of another
2021-04-27 19:15:33 +10:00
Nyall Dawson
1c94f6b941 Dox++ 2021-04-27 14:53:20 +10:00
Nyall Dawson
063f2ee852 Add optimised method to create QgsCircularString direct from coordinate
arrays
2021-04-27 14:53:20 +10:00
Nyall Dawson
729792d981 Add QgsCurve::indexOf to retrieve index of a specified QgsPoint
within the curve
2021-04-27 11:26:49 +10:00
Nyall Dawson
9c4375b4c7 Add QgsGeometry::isAxisParallelRectangle for checking whether
a geometry is a axis-parallel rectangle

Credit to @stefanuhrig
2021-04-24 06:25:02 +10:00
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01:00
Nyall Dawson
0c5ffe7ecf Spelling 2021-03-19 18:47:23 +10:00
Nyall Dawson
425f27186f Add method to determine closest side of rectangle to a point 2021-03-19 18:47:23 +10:00
Nyall Dawson
ba6d96725b Add geometry util to calculate a point along a segment offset in a perpendicular direction by a set offset amount 2021-03-19 18:47:23 +10:00
Nyall Dawson
7c410120e3 Super-optimised version of geometry bounding box intersects test
Apply some fancy logic to make this test as cheap as possible
to run
2021-03-12 05:46:14 +10:00
Nyall Dawson
5445aceaff Add QgsRectangle::contains overload which doesn't require QgsPoint/QgsPointXY objects 2021-03-12 05:46:14 +10:00
Nyall Dawson
7fb3c83e76 Sipify 2021-03-12 05:46:14 +10:00
Nyall Dawson
afccd31720 Add method to add a linestring to compound curves where we extend
the existing final part if it's a linestring and the newly added
curve is also a linestring, instead of adding a whole new curve
2021-03-05 04:28:31 +10:00
Nyall Dawson
6ab4ecfa58 Another attempt 2021-02-25 11:08:56 +10:00
Nyall Dawson
73658c5910 Fix mac build 2021-02-25 11:08:56 +10:00
Nyall Dawson
bd82925df3 Replace qgis::make_unique with std::make_unique
Now that we require c++14 features, we don't need to use the custom
backported version anymore...
2021-02-25 11:08:56 +10:00
Nyall Dawson
d007901f14 Allow QgsRectangle constructors to bypass the automatic normalization
step, when they know in advance they are already normalized

This step isn't free, and can add up when many rectangles are
constructed
2021-02-23 16:02:06 +10:00
Nyall Dawson
7dfef3a0b1 Newer doxygen versions don't auto convert the first line in a class'
documentation to a brief note, so we have to do it explicitly...
2021-02-19 08:15:29 +10:00
Loïc Bartoletti
e336b831c2 Remove automagic fix and tiny refacto 2021-02-13 09:25:19 +10:00
Loïc Bartoletti
7e7732218b Add a message if a geometry was fixed 2021-02-13 09:25:19 +10:00
Nyall Dawson
6f4b32f658 Create class QgsAbstractGeometryTransformer, which can be used
to transform the vertices of a QgsAbstractGeometry

E.g.

        class Transformer(QgsAbstractGeometryTransformer):

            def transformPoint(self, x, y, z, m):
                return True, x * 2, y + 1, z, m

        transformer = Transformer()
        g = QgsGeometry.fromWkt('LineString(3 0, 10 0, 10 10)')
        g.get().transform(transformer)
        print(g.asWkt()) # 'LineString (6 1, 20 1, 20 11)'
2021-02-08 12:12:53 +10:00
Nyall Dawson
50b9beaad6 [sipify] Catch more class references and insert :py:class: annotations 2021-01-31 05:41:22 +10:00
Harrissou Sant-anna
8a8d2a2c66 Fix some formatting in pyQGIS doc 2021-01-30 08:25:03 +10:00
Belgacem
f362eab3d8 fix indentation 2021-01-13 15:47:40 +01:00
Belgacem
0167d07eaa fix tests 2021-01-13 15:47:40 +01:00
Belgacem
be88fff95c add some QgsRay3D tests 2021-01-13 15:47:40 +01:00
Belgacem
2c9c6f94b9 fix somethings and testRayFromScreenPoint 2021-01-13 15:47:40 +01:00
Belgacem
fa7e3d4f7d fix sip and add Nyall suggestions 2021-01-13 15:47:40 +01:00
Belgacem
59bb58f880 cleanup and fix symbol nullptr bug 2021-01-13 15:47:40 +01:00
Belgacem
0073c35b65 remove distanceFromPoint 2021-01-13 15:47:40 +01:00