~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/contrib/gis/geos/prepared.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
5
class 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)