Exemple #1
0
 def callback(item1, item2, distance, userdata):
     try:
         geom1 = ctypes.cast(item1, ctypes.py_object).value
         geom2 = ctypes.cast(item2, ctypes.py_object).value
         dist = ctypes.cast(distance, ctypes.POINTER(ctypes.c_double))
         lgeos.GEOSDistance(geom1._geom, geom2._geom, dist)
         return 1
     except Exception:
         return 0
Exemple #2
0
        def callback(item1, item2, distance, userdata):
            try:
                callback_userdata = ctypes.cast(userdata,
                                                ctypes.py_object).value
                idx = ctypes.cast(item1, ctypes.py_object).value
                geom2 = ctypes.cast(item2, ctypes.py_object).value
                dist = ctypes.cast(distance, ctypes.POINTER(ctypes.c_double))
                if callback_userdata["exclusive"] and self._geoms[idx].equals(
                        geom2):
                    dist[0] = sys.float_info.max
                else:
                    lgeos.GEOSDistance(self._geoms[idx]._geom, geom2._geom,
                                       dist)

                return 1
            except Exception:
                log.exception("Caught exception")
                return 0