8
8
'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate']
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
15
16
def topology(func, *args):
16
17
"For GEOS unary topology functions."
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)
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
45
46
# Routines only in GEOS 3.1+
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')