_geos.pxd 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """Provides a wrapper for GEOS types and functions.
  2. Note: GEOS functions in Cython must be called using the get_geos_handle context
  3. manager.
  4. Examples
  5. --------
  6. with get_geos_handle() as geos_handle:
  7. SomeGEOSFunc(geos_handle, ...<other params>)
  8. """
  9. cdef extern from "geos_c.h":
  10. # Types
  11. ctypedef void *GEOSContextHandle_t
  12. ctypedef struct GEOSGeometry
  13. ctypedef struct GEOSCoordSequence
  14. ctypedef void (*GEOSMessageHandler_r)(const char *message, void *userdata)
  15. # GEOS Context & Messaging
  16. GEOSContextHandle_t GEOS_init_r() nogil
  17. void GEOS_finish_r(GEOSContextHandle_t handle) nogil
  18. void GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t handle, GEOSMessageHandler_r ef, void* userData) nogil
  19. void GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t handle, GEOSMessageHandler_r nf, void* userData) nogil
  20. # Geometry functions
  21. const GEOSGeometry* GEOSGetGeometryN_r(GEOSContextHandle_t handle, const GEOSGeometry* g, int n) nogil
  22. const GEOSGeometry* GEOSGetExteriorRing_r(GEOSContextHandle_t handle, const GEOSGeometry* g) nogil
  23. const GEOSGeometry* GEOSGetInteriorRingN_r(GEOSContextHandle_t handle, const GEOSGeometry* g, int n) nogil
  24. int GEOSGeomTypeId_r(GEOSContextHandle_t handle, GEOSGeometry* g) nogil
  25. # Geometry creation / destruction
  26. GEOSGeometry* GEOSGeom_clone_r(GEOSContextHandle_t handle, const GEOSGeometry* g) nogil
  27. GEOSGeometry* GEOSGeom_createPoint_r(GEOSContextHandle_t handle, GEOSCoordSequence* s) nogil
  28. GEOSGeometry* GEOSGeom_createLineString_r(GEOSContextHandle_t handle, GEOSCoordSequence* s) nogil
  29. GEOSGeometry* GEOSGeom_createLinearRing_r(GEOSContextHandle_t handle, GEOSCoordSequence* s) nogil
  30. GEOSGeometry* GEOSGeom_createEmptyPolygon_r(GEOSContextHandle_t handle) nogil
  31. GEOSGeometry* GEOSGeom_createPolygon_r(GEOSContextHandle_t handle, GEOSGeometry* shell, GEOSGeometry** holes, unsigned int nholes) nogil
  32. GEOSGeometry* GEOSGeom_createCollection_r(GEOSContextHandle_t handle, int type, GEOSGeometry** geoms, unsigned int ngeoms) nogil
  33. void GEOSGeom_destroy_r(GEOSContextHandle_t handle, GEOSGeometry* g) nogil
  34. # Coordinate sequences
  35. const GEOSCoordSequence* GEOSGeom_getCoordSeq_r(GEOSContextHandle_t handle, const GEOSGeometry* g)
  36. GEOSCoordSequence* GEOSCoordSeq_clone_r(GEOSContextHandle_t handle, const GEOSCoordSequence* s)
  37. GEOSCoordSequence* GEOSCoordSeq_create_r(GEOSContextHandle_t handle, unsigned int size, unsigned int dims) nogil
  38. void GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle, GEOSCoordSequence* s) nogil
  39. int GEOSCoordSeq_setX_r(GEOSContextHandle_t handle, GEOSCoordSequence* s, unsigned int idx, double val) nogil
  40. int GEOSCoordSeq_setY_r(GEOSContextHandle_t handle, GEOSCoordSequence* s, unsigned int idx, double val) nogil
  41. int GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle, GEOSCoordSequence* s, unsigned int idx, double val) nogil
  42. int GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle, GEOSCoordSequence* s, unsigned int* size) nogil
  43. cdef class get_geos_handle:
  44. cdef GEOSContextHandle_t handle
  45. cdef char* last_error
  46. cdef char* last_warning
  47. cdef GEOSContextHandle_t __enter__(self)