Added `merged` property to LineString & MultiLineString, which returns the output of the GEOS line merging operation.
2 This module houses the GEOS ctypes prototype functions for the
3 topological operations on geometries.
5 __all__ = ['geos_boundary', 'geos_buffer', 'geos_centroid', 'geos_convexhull',
6 'geos_difference', 'geos_envelope', 'geos_intersection',
7 'geos_linemerge', 'geos_pointonsurface', 'geos_preservesimplify',
8 'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate']
10 from ctypes import c_char_p, c_double, c_int
11 from django.contrib.gis.geos.libgeos import lgeos, GEOM_PTR, GEOS_PREPARE
12 from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string
14 def topology(func, *args):
15 "For GEOS unary topology functions."
17 if args: argtypes += args
18 func.argtypes = argtypes
19 func.restype = GEOM_PTR
20 func.errcheck = check_geom
23 ### Topology Routines ###
24 geos_boundary = topology(lgeos.GEOSBoundary)
25 geos_buffer = topology(lgeos.GEOSBuffer, c_double, c_int)
26 geos_centroid = topology(lgeos.GEOSGetCentroid)
27 geos_convexhull = topology(lgeos.GEOSConvexHull)
28 geos_difference = topology(lgeos.GEOSDifference, GEOM_PTR)
29 geos_envelope = topology(lgeos.GEOSEnvelope)
30 geos_intersection = topology(lgeos.GEOSIntersection, GEOM_PTR)
31 geos_linemerge = topology(lgeos.GEOSLineMerge)
32 geos_pointonsurface = topology(lgeos.GEOSPointOnSurface)
33 geos_preservesimplify = topology(lgeos.GEOSTopologyPreserveSimplify, c_double)
34 geos_simplify = topology(lgeos.GEOSSimplify, c_double)
35 geos_symdifference = topology(lgeos.GEOSSymDifference, GEOM_PTR)
36 geos_union = topology(lgeos.GEOSUnion, GEOM_PTR)
38 # GEOSRelate returns a string, not a geometry.
39 geos_relate = lgeos.GEOSRelate
40 geos_relate.argtypes = [GEOM_PTR, GEOM_PTR]
41 geos_relate.errcheck = check_string
43 # Routines only in GEOS 3.1+
45 geos_cascaded_union = lgeos.GEOSUnionCascaded
46 geos_cascaded_union.argtypes = [GEOM_PTR]
47 geos_cascaded_union.restype = GEOM_PTR
48 __all__.append('geos_cascaded_union')