These functions implement tests for pairs of geometries in OGC WKT format.
Usage
g_intersects(this_geom, other_geom)
g_disjoint(this_geom, other_geom)
g_touches(this_geom, other_geom)
g_contains(this_geom, other_geom)
g_within(this_geom, other_geom)
g_crosses(this_geom, other_geom)
g_overlaps(this_geom, other_geom)
g_equals(this_geom, other_geom)
Details
These functions use the GEOS library via GDAL headers.
g_intersects()
tests whether two geometries intersect.
g_disjoint()
tests if this geometry and the other geometry are disjoint.
g_touches()
tests if this geometry and the other geometry are touching.
g_contains()
tests if this geometry contains the other geometry.
g_within()
tests if this geometry is within the other geometry.
g_crosses()
tests if this geometry and the other geometry are crossing.
g_overlaps()
tests if this geometry and the other geometry overlap, that
is, their intersection has a non-zero area (they have some but not all
points in common).
g_equals()
tests whether two geometries are equivalent.
The GDAL documentation says: "This operation implements the SQL/MM
ST_OrderingEquals()
operation. The comparison is done in a structural way,
that is to say that the geometry types must be identical, as well as the
number and ordering of sub-geometries and vertices. Or equivalently, two
geometries are considered equal by this method if their WKT/WKB
representation is equal. Note: this must be distinguished from equality in
a spatial way."
Note
Geometry validity is not checked. In case you are unsure of the validity
of the input geometries, call g_is_valid()
before, otherwise the result
might be wrong.