Debian Codegraph @

django/contrib/gis/geos/prototypes/predicates.py

raw
1 """
2 This module houses the GEOS ctypes prototype functions for the
3 unary and binary predicate operations on geometries.
4 """
5
6 from ctypes import c_byte, c_char_p, c_double
7
8 from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory
9 from django.contrib.gis.geos.prototypes.errcheck import check_predicate
10
11
12 # ## Binary & unary predicate factories ##
13 class UnaryPredicate(GEOSFuncFactory):
14 "For GEOS unary predicate functions."
15
16 argtypes = [GEOM_PTR]
17 restype = c_byte
18 errcheck = staticmethod(check_predicate)
19
20
21 class BinaryPredicate(UnaryPredicate):
22 "For GEOS binary predicate functions."
23
24 argtypes = [GEOM_PTR, GEOM_PTR]
25
26
27 # ## Unary Predicates ##
28 geos_hasz = UnaryPredicate("GEOSHasZ")
29 geos_isclosed = UnaryPredicate("GEOSisClosed")
30 geos_isempty = UnaryPredicate("GEOSisEmpty")
31 geos_isring = UnaryPredicate("GEOSisRing")
32 geos_issimple = UnaryPredicate("GEOSisSimple")
33 geos_isvalid = UnaryPredicate("GEOSisValid")
34
35 # ## Binary Predicates ##
36 geos_contains = BinaryPredicate("GEOSContains")
37 geos_covers = BinaryPredicate("GEOSCovers")
38 geos_crosses = BinaryPredicate("GEOSCrosses")
39 geos_disjoint = BinaryPredicate("GEOSDisjoint")
40 geos_equals = BinaryPredicate("GEOSEquals")
41 geos_equalsexact = BinaryPredicate(
42 "GEOSEqualsExact", argtypes=[GEOM_PTR, GEOM_PTR, c_double]
43 )
44 geos_equalsidentical = BinaryPredicate("GEOSEqualsIdentical")
45 geos_intersects = BinaryPredicate("GEOSIntersects")
46 geos_overlaps = BinaryPredicate("GEOSOverlaps")
47 geos_relatepattern = BinaryPredicate(
48 "GEOSRelatePattern", argtypes=[GEOM_PTR, GEOM_PTR, c_char_p]
49 )
50 geos_touches = BinaryPredicate("GEOSTouches")
51 geos_within = BinaryPredicate("GEOSWithin")