You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

predicates.py 1.5KB

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