PageRenderTime 62ms CodeModel.GetById 30ms app.highlight 6ms RepoModel.GetById 15ms app.codeStats 0ms

/django/contrib/gis/geos/prototypes/predicates.py

https://code.google.com/p/mango-py/
Python | 44 lines | 33 code | 4 blank | 7 comment | 1 complexity | 93a5033bb8356c65d2ffc56b95ab1c83 MD5 | raw file
 1"""
 2 This module houses the GEOS ctypes prototype functions for the
 3 unary and binary predicate operations on geometries.
 4"""
 5from ctypes import c_char, c_char_p, c_double
 6from django.contrib.gis.geos.libgeos import GEOM_PTR
 7from django.contrib.gis.geos.prototypes.errcheck import check_predicate
 8from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
 9
10## Binary & unary predicate functions ##
11def binary_predicate(func, *args):
12    "For GEOS binary predicate functions."
13    argtypes = [GEOM_PTR, GEOM_PTR]
14    if args: argtypes += args
15    func.argtypes = argtypes
16    func.restype = c_char
17    func.errcheck = check_predicate
18    return func
19
20def unary_predicate(func):
21    "For GEOS unary predicate functions."
22    func.argtypes = [GEOM_PTR]
23    func.restype = c_char
24    func.errcheck = check_predicate
25    return func
26
27## Unary Predicates ##
28geos_hasz = unary_predicate(GEOSFunc('GEOSHasZ'))
29geos_isempty = unary_predicate(GEOSFunc('GEOSisEmpty'))
30geos_isring = unary_predicate(GEOSFunc('GEOSisRing'))
31geos_issimple = unary_predicate(GEOSFunc('GEOSisSimple'))
32geos_isvalid = unary_predicate(GEOSFunc('GEOSisValid'))
33
34## Binary Predicates ##
35geos_contains = binary_predicate(GEOSFunc('GEOSContains'))
36geos_crosses = binary_predicate(GEOSFunc('GEOSCrosses'))
37geos_disjoint = binary_predicate(GEOSFunc('GEOSDisjoint'))
38geos_equals = binary_predicate(GEOSFunc('GEOSEquals'))
39geos_equalsexact = binary_predicate(GEOSFunc('GEOSEqualsExact'), c_double)
40geos_intersects = binary_predicate(GEOSFunc('GEOSIntersects'))
41geos_overlaps = binary_predicate(GEOSFunc('GEOSOverlaps'))
42geos_relatepattern = binary_predicate(GEOSFunc('GEOSRelatePattern'), c_char_p)
43geos_touches = binary_predicate(GEOSFunc('GEOSTouches'))
44geos_within = binary_predicate(GEOSFunc('GEOSWithin'))