63 Commits

Author SHA1 Message Date
bdm-oslandia
40089e6230 qgsabstractgeometry: Add support for box3d intersection 2023-09-02 12:38:44 +10:00
bdm-oslandia
5774acf8d0 qgsabstractgeometry: Add boundingBox3D logic
With this change `QgsAbstractGeometry::calculateBoundingBox()` is now
computed from `QgsAbstractGeometry::calculateBoundingBox3D()`.
2023-09-02 12:38:44 +10:00
Nyall Dawson
50c76929e1
Followup 30700f1, ensure links to Qgis members are set in docstrings 2023-03-31 10:46:24 +10:00
Nyall Dawson
046883fa9c Promote QgsWkbTypes enums to enum class, move to Qgis 2023-02-22 12:39:21 +10:00
Damiano Lombardi
619170e4a8 QgsVectorFileWriter map NaN to -DBL_MAX exporting to Shape 2022-11-15 14:02:45 +01:00
Juergen E. Fischer
c6008b7ee1 fix MSVC build: reverts fee62e4, dff05dd and e3a77b9484c effectivly
reverting 3fb0f66 (followup #45348)

Using --no-public-is-protected (default on Windows) also works on Linux
and fixes #45331 too
2021-10-21 23:03:48 +02:00
nirvn
ef84e48a09 Run sipify_all.sh 2021-10-12 16:34:05 +10:00
Denis Rouzaud
ec16736306 run sipify 2021-10-12 16:34:05 +10:00
Nyall Dawson
e733b517b3 Split QgsVertexId out to own file, promote type to enum class 2021-10-12 14:54:26 +10:00
Nyall Dawson
e6b39077a2
Promote QgsCoordinateTransform::TransformDirection to enum class, move to Qgis
This enum was forcing an include of qgscoordinatetransform.h within the
widely used qgsabstractgeometry.h header, causing an absolute explosion
of includes of a bunch of very heavy header classes all across QGIS. By
removing the forced include we can avoid a ton of unwanted includes
and make wider use of forward declarations...
2021-09-22 16:40:49 +10:00
Nyall Dawson
01e3e1dddc [api] Move QgsGeometry enums to Qgis, promote to enum classes 2021-08-04 09:54:32 +10:00
Denis Rouzaud
35c557a234 run sipify 2021-05-26 14:30:54 +02: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
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
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
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01: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
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
Even Rouault
7ac4b51885 Add QgsGeometry::wkbSize() 2020-10-19 09:25:10 +10:00
Nyall Dawson
fe70bb2440 Dox 2020-09-18 11:50:27 +10:00
Nyall Dawson
fe5615ea44 Hold the GIL for more geometry related methods 2020-09-18 11:50:27 +10:00
Harrissou Sant-anna
5c83cd07cc Move some cpp code samples to python 2020-07-21 10:13:45 +10:00
Nyall Dawson
205273e7cd Add method to QgsAbstractGeometry to convert geometry to QPainterPath
Unlike QgsGeometry::asQPolygonF, this allows for correct handling
of multipolygons and rings, etc.

And potentially, the generated QPainterPaths could use arc segments
instead of segmentizing geometries. In fact, there's been disabled
code which seems to do this in place since the new geometry engine
was introduced back in 2.10! TODO: check if this code works correctly...
2020-07-03 15:24:32 +10:00
Denis Rouzaud
0cb8408425
more flags warnings fixes for Qt 5.15 (#37309)
* more flags warnings fixes for Qt 5.15

* fix sip compilation
2020-06-19 12:02:00 +02:00
Nyall Dawson
81a9db9f57 [sipify] Fix creation of cross references 2020-06-15 13:43:58 +10:00
Nyall Dawson
a5101f2ade [sipify] Fix header formatting 2020-06-13 16:49:14 +10:00
Nyall Dawson
cedd73ee4d More list formatting fixes 2020-06-13 16:49:14 +10:00
Nyall Dawson
d3a54eed6f Add flags to control geometry to WKB export behavior
With initial flag to force conversion of triangle types to polygons
2020-06-11 05:32:26 +10:00
Nyall Dawson
93648dd552 Add Python repr for QgsVertexId 2020-05-22 15:32:44 +10:00
Sandro Mani
6c32a6ae85 Add QgsAbstractGeometry::asKml 2020-01-16 14:36:31 +01:00
Nyall Dawson
77191597ff Spelling 2019-08-22 17:36:43 +10:00
Nyall Dawson
3583e7ad0c More explicit documentation of geometry classes, with warnings
that calculations are Cartesian only and point users to QgsDistanceArea
for ellipsoidal calculations

Fixes #31275
2019-08-22 17:36:43 +10:00
Juergen E. Fischer
e9a80d6799 fix build 2019-05-12 17:19:50 +02:00
Alessandro Pasotti
bbd836f4d3 Update tests for geometry classes 2019-05-02 13:52:46 +02:00
Alessandro Pasotti
63711510b6 Dear Qt, I love you but ...
... you are too slow and QJson API is so ugly.

Now using this wonderful json lib:
https://github.com/nlohmann/json

Results in release mode (QJson tests are not shown but
QJson was even slower than string concat).

PASS   : TestQgsJsonUtils::testExportAttributesJson(Use json)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use json":
     0.0022 msecs per iteration (total: 75, iterations: 32768)
PASS   : TestQgsJsonUtils::testExportAttributesJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use old string concat":
     0.0032 msecs per iteration (total: 54, iterations: 16384)
PASS   : TestQgsJsonUtils::testExportFeatureJson(Use json)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use json":
     0.011 msecs per iteration (total: 96, iterations: 8192)
PASS   : TestQgsJsonUtils::testExportFeatureJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use old string concat":
     0.015 msecs per iteration (total: 64, iterations: 4096)
PASS   : TestQgsJsonUtils::testExportGeomToJson(Use json)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use json":
     0.76 msecs per iteration (total: 98, iterations: 128)
PASS   : TestQgsJsonUtils::testExportGeomToJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use old string concat":
     0.85 msecs per iteration (total: 55, iterations: 64)
PASS   : TestQgsJsonUtils::cleanupTestCase()
2019-04-18 17:04:30 +02:00
Alessandro Pasotti
64fdbe3d76 Added tests and doxy 2019-04-16 15:17:25 +02:00
Alessandro Pasotti
be8822ed8b Precision and 3d 2019-04-16 14:00:59 +02:00
Alessandro Pasotti
6967a21882 toJsonV2 2019-04-16 14:00:59 +02:00
Nyall Dawson
1dc447e1f2 Dox++ 2019-03-21 12:44:16 +10:00
Nyall Dawson
75697d77ed Cache validity check results
For non-point geometry subclasses (points are always valid!) we
now cache the results of a geometry validity check. Subsequent
checks utilise the cached result wherever possible.

Because QgsGeometry/QgsFeature objects are implicitly shared, this
means that we avoid a *lot* of duplicate validity checks as
features and geometries are thrown around during processing model
execution.
2019-03-01 08:06:31 +10:00
Nyall Dawson
107b48a430 Add NULLPTR macro for use in doxygen comments
For the c++ api dox this expands to "\c nullptr" (the
\c directive indicates a code literal value), and for sipify/Python
it expands to ``None`` (`` is sphinx annotation for literal values)

Makes for nicer dox for both c++ and Python!
2019-02-27 09:41:11 +10:00
Nyall Dawson
b6d66becab Sipify 2019-02-27 09:41:11 +10:00
Nyall Dawson
384d310233 Minor improvements to PyQGIS returns for SIP_OUT params 2019-02-05 04:55:34 +11:00
Pierre-Eric Pelloux-Prayer
f1760ee56b Remove include "qgsapplication.h" from qgswkbptr.h
qgswkbptr.h is included indirectly by a large number of source files.
So this commit does the following:
  - remove #include "qgsapplication.h" from qgswkbptr.h, and copy-paste the swap_endian
    function where it's used.
  - add the missing #include "qgsapplication.h" in other files

The rationale for this change is:
  - qgswkbptr.h doesn't really needs QgsApplication, since it only used swap_endian.
    We don't need to add a fake dependency on QgsApplication on every (indirect) "includers"
    of qgswkbptr.h
 - qgsapplication.h depends on qgsconfig.h which itself changes quite often (on every git op
   at least). Before this change, a 'git commit' would trigger a rebuild of about 3500 files.
   With this change we're down to ~700.
2019-01-22 21:45:38 +01:00
Denis Rouzaud
166e952c33 run sipify 2018-12-19 08:04:27 -04:00
Denis Rouzaud
32e844f9f8 fix multiline comments on out params 2018-12-18 17:29:04 -04:00
Denis Rouzaud
edfb7e1465 run sipify 2018-12-18 17:17:25 -04:00