1
from django.contrib.gis.geos.base import GEOSBase
2
from django.contrib.gis.geos.geometry import GEOSGeometry
3
from django.contrib.gis.geos.prototypes import prepared as capi
5
class PreparedGeometry(GEOSBase):
7
A geometry that is prepared for performing certain operations.
8
At the moment this includes the contains covers, and intersects
11
ptr_type = capi.PREPGEOM_PTR
13
def __init__(self, geom):
14
if not isinstance(geom, GEOSGeometry): raise TypeError
15
self.ptr = capi.geos_prepare(geom.ptr)
18
if self._ptr: capi.prepared_destroy(self._ptr)
20
def contains(self, other):
21
return capi.prepared_contains(self.ptr, other.ptr)
23
def contains_properly(self, other):
24
return capi.prepared_contains_properly(self.ptr, other.ptr)
26
def covers(self, other):
27
return capi.prepared_covers(self.ptr, other.ptr)
29
def intersects(self, other):
30
return capi.prepared_intersects(self.ptr, other.ptr)