/django/contrib/gis/geos/prepared.py
Python | 30 lines | 18 code | 7 blank | 5 comment | 3 complexity | 38f146df1c8bce228225b89a051fbfea MD5 | raw file
Possible License(s): BSD-3-Clause
1from django.contrib.gis.geos.base import GEOSBase 2from django.contrib.gis.geos.geometry import GEOSGeometry 3from django.contrib.gis.geos.prototypes import prepared as capi 4 5class PreparedGeometry(GEOSBase): 6 """ 7 A geometry that is prepared for performing certain operations. 8 At the moment this includes the contains covers, and intersects 9 operations. 10 """ 11 ptr_type = capi.PREPGEOM_PTR 12 13 def __init__(self, geom): 14 if not isinstance(geom, GEOSGeometry): raise TypeError 15 self.ptr = capi.geos_prepare(geom.ptr) 16 17 def __del__(self): 18 if self._ptr: capi.prepared_destroy(self._ptr) 19 20 def contains(self, other): 21 return capi.prepared_contains(self.ptr, other.ptr) 22 23 def contains_properly(self, other): 24 return capi.prepared_contains_properly(self.ptr, other.ptr) 25 26 def covers(self, other): 27 return capi.prepared_covers(self.ptr, other.ptr) 28 29 def intersects(self, other): 30 return capi.prepared_intersects(self.ptr, other.ptr)