PageRenderTime 31ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/gis/geos/prepared.py

https://code.google.com/p/mango-py/
Python | 30 lines | 18 code | 7 blank | 5 comment | 2 complexity | 38f146df1c8bce228225b89a051fbfea MD5 | raw file
Possible License(s): BSD-3-Clause
  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
  4. class PreparedGeometry(GEOSBase):
  5. """
  6. A geometry that is prepared for performing certain operations.
  7. At the moment this includes the contains covers, and intersects
  8. operations.
  9. """
  10. ptr_type = capi.PREPGEOM_PTR
  11. def __init__(self, geom):
  12. if not isinstance(geom, GEOSGeometry): raise TypeError
  13. self.ptr = capi.geos_prepare(geom.ptr)
  14. def __del__(self):
  15. if self._ptr: capi.prepared_destroy(self._ptr)
  16. def contains(self, other):
  17. return capi.prepared_contains(self.ptr, other.ptr)
  18. def contains_properly(self, other):
  19. return capi.prepared_contains_properly(self.ptr, other.ptr)
  20. def covers(self, other):
  21. return capi.prepared_covers(self.ptr, other.ptr)
  22. def intersects(self, other):
  23. return capi.prepared_intersects(self.ptr, other.ptr)