app/django/contrib/gis/geos/prototypes/topology.py
changeset 323 ff1a9aa48cfd
equal deleted inserted replaced
322:6641e941ef1e 323:ff1a9aa48cfd
       
     1 """
       
     2  This module houses the GEOS ctypes prototype functions for the 
       
     3  topological operations on geometries.
       
     4 """
       
     5 from ctypes import c_char_p, c_double, c_int
       
     6 from django.contrib.gis.geos.libgeos import lgeos, GEOM_PTR
       
     7 from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string
       
     8 
       
     9 def topology(func, *args):
       
    10     "For GEOS unary topology functions."
       
    11     argtypes = [GEOM_PTR]
       
    12     if args: argtypes += args
       
    13     func.argtypes = argtypes
       
    14     func.restype = GEOM_PTR
       
    15     func.errcheck = check_geom
       
    16     return func
       
    17 
       
    18 ### Topology Routines ###
       
    19 geos_boundary = topology(lgeos.GEOSBoundary)
       
    20 geos_buffer = topology(lgeos.GEOSBuffer, c_double, c_int)
       
    21 geos_centroid = topology(lgeos.GEOSGetCentroid)
       
    22 geos_convexhull = topology(lgeos.GEOSConvexHull)
       
    23 geos_difference = topology(lgeos.GEOSDifference, GEOM_PTR)
       
    24 geos_envelope = topology(lgeos.GEOSEnvelope)
       
    25 geos_intersection = topology(lgeos.GEOSIntersection, GEOM_PTR)
       
    26 geos_pointonsurface = topology(lgeos.GEOSPointOnSurface)
       
    27 geos_preservesimplify = topology(lgeos.GEOSTopologyPreserveSimplify, c_double)
       
    28 geos_simplify = topology(lgeos.GEOSSimplify, c_double)
       
    29 geos_symdifference = topology(lgeos.GEOSSymDifference, GEOM_PTR)
       
    30 geos_union = topology(lgeos.GEOSUnion, GEOM_PTR)
       
    31 
       
    32 # GEOSRelate returns a string, not a geometry.
       
    33 geos_relate = lgeos.GEOSRelate
       
    34 geos_relate.argtypes = [GEOM_PTR, GEOM_PTR]
       
    35 geos_relate.errcheck = check_string