We only previously had methods for exact intersections - this
commit adds a new QgsGeometry.boundingBoxIntersects() method
which can be used to test if just the bounding boxes of
geometries/rectangles intersect.
It's fast, and doesn't care about invalid geometries (unlike
the exact intersects checks)
This is used a lot, yet the current constructor calls the
normalize() method which does a bunch of operations for no
result.
So instead provide a simple optimised null QgsRectangle
constructor and save a lot of cycles.
Refs #17809
Before we had two checks - equals() and isGeosEqual() which
performed the exact same check (since equals() called the geos
equality test)
Since the geos equality test is a slow, topological test, which
considers two geometries equal if their component edges overlap,
but disregards ordering of vertices this is not always what we
want. There's also the issue that geos cannot consider m values
when testing the geometries, so two geometries with different
m values would be reported equal.
So, now calling QgsGeometry::equals performs a very fast, strict
equality test where geometries are only equal if the have exactly
the same vertices, type, and order.
And swap most code which was calling the slow geos test to instead
use the fast strict native test.
Run clang-tidy modernize-use-override to remove all the redundant
virtual keywords from overridden methods, and add some missing
overrides.
Another benefit is that this has also added the overrides
on destructors, which will cause a build failure if a base
class is missing a virtual destructor.
Removes duplicate nodes from the geometry, wherever removing the
nodes does not result in a degenerate geometry.
By default, z values are not considered when detecting duplicate
nodes. E.g. two nodes with the same x and y coordinate but
different z values will still be considered duplicate and one
will be removed. If useZValues is true, then the z values are
also tested and nodes with the same x and y but different z
will be maintained.
Note that duplicate nodes are not tested between different
parts of a multipart geometry. E.g. a multipoint geometry
with overlapping points will not be changed by this method.
The function will return true if nodes were removed, or false
if no duplicate nodes were found.
Includes unit tests and a processing algorithm which exposes
this functionality.
Now instead of mixing bools/numeric returns, we always use
ints, where:
-1 = left
0 = test failed, e.g. point on line
1 = right
Also fix a bunch of extra issues identified with left of tests
as a result of these changes