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

« back to all changes in this revision

Viewing changes to django/contrib/gis/geos/prototypes/topology.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
           'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate']
9
9
 
10
10
from ctypes import c_char_p, c_double, c_int
11
 
from django.contrib.gis.geos.libgeos import lgeos, GEOM_PTR, GEOS_PREPARE
 
11
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
12
12
from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string
13
13
from django.contrib.gis.geos.prototypes.geom import geos_char_p
 
14
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
14
15
 
15
16
def topology(func, *args):
16
17
    "For GEOS unary topology functions."
22
23
    return func
23
24
 
24
25
### Topology Routines ###
25
 
geos_boundary = topology(lgeos.GEOSBoundary)
26
 
geos_buffer = topology(lgeos.GEOSBuffer, c_double, c_int)
27
 
geos_centroid = topology(lgeos.GEOSGetCentroid)
28
 
geos_convexhull = topology(lgeos.GEOSConvexHull)
29
 
geos_difference = topology(lgeos.GEOSDifference, GEOM_PTR)
30
 
geos_envelope = topology(lgeos.GEOSEnvelope)
31
 
geos_intersection = topology(lgeos.GEOSIntersection, GEOM_PTR)
32
 
geos_linemerge = topology(lgeos.GEOSLineMerge)
33
 
geos_pointonsurface = topology(lgeos.GEOSPointOnSurface)
34
 
geos_preservesimplify = topology(lgeos.GEOSTopologyPreserveSimplify, c_double)
35
 
geos_simplify = topology(lgeos.GEOSSimplify, c_double)
36
 
geos_symdifference = topology(lgeos.GEOSSymDifference, GEOM_PTR)
37
 
geos_union = topology(lgeos.GEOSUnion, GEOM_PTR)
 
26
geos_boundary = topology(GEOSFunc('GEOSBoundary'))
 
27
geos_buffer = topology(GEOSFunc('GEOSBuffer'), c_double, c_int)
 
28
geos_centroid = topology(GEOSFunc('GEOSGetCentroid'))
 
29
geos_convexhull = topology(GEOSFunc('GEOSConvexHull'))
 
30
geos_difference = topology(GEOSFunc('GEOSDifference'), GEOM_PTR)
 
31
geos_envelope = topology(GEOSFunc('GEOSEnvelope'))
 
32
geos_intersection = topology(GEOSFunc('GEOSIntersection'), GEOM_PTR)
 
33
geos_linemerge = topology(GEOSFunc('GEOSLineMerge'))
 
34
geos_pointonsurface = topology(GEOSFunc('GEOSPointOnSurface'))
 
35
geos_preservesimplify = topology(GEOSFunc('GEOSTopologyPreserveSimplify'), c_double)
 
36
geos_simplify = topology(GEOSFunc('GEOSSimplify'), c_double)
 
37
geos_symdifference = topology(GEOSFunc('GEOSSymDifference'), GEOM_PTR)
 
38
geos_union = topology(GEOSFunc('GEOSUnion'), GEOM_PTR)
38
39
 
39
40
# GEOSRelate returns a string, not a geometry.
40
 
geos_relate = lgeos.GEOSRelate
 
41
geos_relate = GEOSFunc('GEOSRelate')
41
42
geos_relate.argtypes = [GEOM_PTR, GEOM_PTR]
42
43
geos_relate.restype = geos_char_p
43
44
geos_relate.errcheck = check_string
44
45
 
45
46
# Routines only in GEOS 3.1+
46
47
if GEOS_PREPARE:
47
 
    geos_cascaded_union = lgeos.GEOSUnionCascaded
 
48
    geos_cascaded_union = GEOSFunc('GEOSUnionCascaded')
48
49
    geos_cascaded_union.argtypes = [GEOM_PTR]
49
50
    geos_cascaded_union.restype = GEOM_PTR
50
51
    __all__.append('geos_cascaded_union')