gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2164 line
92KB

  1. /************************************************************************
  2. *
  3. *
  4. * C-Wrapper for GEOS library
  5. *
  6. * Copyright (C) 2010 2011 Sandro Santilli <strk@kbt.io>
  7. * Copyright (C) 2005 Refractions Research Inc.
  8. *
  9. * This is free software; you can redistribute and/or modify it under
  10. * the terms of the GNU Lesser General Public Licence as published
  11. * by the Free Software Foundation.
  12. * See the COPYING file for more information.
  13. *
  14. * Author: Sandro Santilli <strk@kbt.io>
  15. *
  16. ***********************************************************************
  17. *
  18. * GENERAL NOTES:
  19. *
  20. * - Remember to call initGEOS() before any use of this library's
  21. * functions, and call finishGEOS() when done.
  22. *
  23. * - Currently you have to explicitly GEOSGeom_destroy() all
  24. * GEOSGeom objects to avoid memory leaks, and GEOSFree()
  25. * all returned char * (unless const).
  26. *
  27. * - Functions ending with _r are thread safe; see details in RFC 3
  28. * http://trac.osgeo.org/geos/wiki/RFC3.
  29. * To avoid using by accident non _r functions,
  30. * define GEOS_USE_ONLY_R_API before including geos_c.h
  31. *
  32. ***********************************************************************/
  33. #ifndef GEOS_C_H_INCLUDED
  34. #define GEOS_C_H_INCLUDED
  35. #ifndef __cplusplus
  36. # include <stddef.h> /* for size_t definition */
  37. #else
  38. # include <cstddef>
  39. using std::size_t;
  40. #endif
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /************************************************************************
  45. *
  46. * Version
  47. *
  48. ***********************************************************************/
  49. /*
  50. * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
  51. * when building with Visual C++ compiler.
  52. *
  53. */
  54. #if defined(_MSC_VER)
  55. #include <geos/version.h>
  56. #define GEOS_CAPI_VERSION_MAJOR 1
  57. #define GEOS_CAPI_VERSION_MINOR 11
  58. #define GEOS_CAPI_VERSION_PATCH 0
  59. #define GEOS_CAPI_VERSION "3.7.2-CAPI-1.11.0"
  60. #else
  61. #ifndef GEOS_VERSION_MAJOR
  62. #define GEOS_VERSION_MAJOR 3
  63. #endif
  64. #ifndef GEOS_VERSION_MINOR
  65. #define GEOS_VERSION_MINOR 7
  66. #endif
  67. #ifndef GEOS_VERSION_PATCH
  68. #define GEOS_VERSION_PATCH 2
  69. #endif
  70. #ifndef GEOS_VERSION
  71. #define GEOS_VERSION "3.7.2"
  72. #endif
  73. #ifndef GEOS_JTS_PORT
  74. #define GEOS_JTS_PORT "1.13.0"
  75. #endif
  76. #define GEOS_CAPI_VERSION_MAJOR 1
  77. #define GEOS_CAPI_VERSION_MINOR 11
  78. #define GEOS_CAPI_VERSION_PATCH 2
  79. #define GEOS_CAPI_VERSION "3.7.2-CAPI-1.11.2"
  80. #endif
  81. #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
  82. #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
  83. /************************************************************************
  84. *
  85. * (Abstract) type definitions
  86. *
  87. ************************************************************************/
  88. typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
  89. typedef void (*GEOSMessageHandler)(const char *fmt, ...);
  90. /*
  91. * A GEOS message handler function.
  92. *
  93. * @param message the message contents
  94. * @param userdata the user data pointer that was passed to GEOS when registering this message handler.
  95. *
  96. *
  97. * @see GEOSContext_setErrorMessageHandler
  98. * @see GEOSContext_setNoticeMessageHandler
  99. */
  100. typedef void (*GEOSMessageHandler_r)(const char *message, void *userdata);
  101. /* When we're included by geos_c.cpp, those are #defined to the original
  102. * JTS definitions via preprocessor. We don't touch them to allow the
  103. * compiler to cross-check the declarations. However, for all "normal"
  104. * C-API users, we need to define them as "opaque" struct pointers, as
  105. * those clients don't have access to the original C++ headers, by design.
  106. */
  107. #ifndef GEOSGeometry
  108. typedef struct GEOSGeom_t GEOSGeometry;
  109. typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
  110. typedef struct GEOSCoordSeq_t GEOSCoordSequence;
  111. typedef struct GEOSSTRtree_t GEOSSTRtree;
  112. typedef struct GEOSBufParams_t GEOSBufferParams;
  113. #endif
  114. /* Those are compatibility definitions for source compatibility
  115. * with GEOS 2.X clients relying on that type.
  116. */
  117. typedef GEOSGeometry* GEOSGeom;
  118. typedef GEOSCoordSequence* GEOSCoordSeq;
  119. /* Supported geometry types
  120. * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
  121. * break compatibility, this issue is still under investigation.
  122. */
  123. enum GEOSGeomTypes {
  124. GEOS_POINT,
  125. GEOS_LINESTRING,
  126. GEOS_LINEARRING,
  127. GEOS_POLYGON,
  128. GEOS_MULTIPOINT,
  129. GEOS_MULTILINESTRING,
  130. GEOS_MULTIPOLYGON,
  131. GEOS_GEOMETRYCOLLECTION
  132. };
  133. /* Byte orders exposed via the C API */
  134. enum GEOSByteOrders {
  135. GEOS_WKB_XDR = 0, /* Big Endian */
  136. GEOS_WKB_NDR = 1 /* Little Endian */
  137. };
  138. typedef void (*GEOSQueryCallback)(void *item, void *userdata);
  139. typedef int (*GEOSDistanceCallback)(const void *item1, const void* item2, double* distance, void* userdata);
  140. /************************************************************************
  141. *
  142. * Initialization, cleanup, version
  143. *
  144. ***********************************************************************/
  145. #include <geos/export.h>
  146. /*
  147. * Register an interruption checking callback
  148. *
  149. * The callback will be invoked _before_ checking for
  150. * interruption, so can be used to request it.
  151. */
  152. typedef void (GEOSInterruptCallback)();
  153. extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb);
  154. /* Request safe interruption of operations */
  155. extern void GEOS_DLL GEOS_interruptRequest();
  156. /* Cancel a pending interruption request */
  157. extern void GEOS_DLL GEOS_interruptCancel();
  158. /*
  159. * @deprecated in 3.5.0
  160. * initialize using GEOS_init_r() and set the message handlers using
  161. * GEOSContext_setNoticeHandler_r and/or GEOSContext_setErrorHandler_r
  162. */
  163. extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
  164. GEOSMessageHandler notice_function,
  165. GEOSMessageHandler error_function);
  166. /*
  167. * @deprecated in 3.5.0 replaced by GEOS_finish_r.
  168. */
  169. extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
  170. extern GEOSContextHandle_t GEOS_DLL GEOS_init_r();
  171. extern void GEOS_DLL GEOS_finish_r(GEOSContextHandle_t handle);
  172. extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
  173. GEOSMessageHandler nf);
  174. extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
  175. GEOSMessageHandler ef);
  176. /*
  177. * Sets a notice message handler on the given GEOS context.
  178. *
  179. * @param extHandle the GEOS context
  180. * @param nf the message handler
  181. * @param userData optional user data pointer that will be passed to the message handler
  182. *
  183. * @return the previously configured message handler or NULL if no message handler was configured
  184. */
  185. extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle,
  186. GEOSMessageHandler_r nf,
  187. void *userData);
  188. /*
  189. * Sets an error message handler on the given GEOS context.
  190. *
  191. * @param extHandle the GEOS context
  192. * @param ef the message handler
  193. * @param userData optional user data pointer that will be passed to the message handler
  194. *
  195. * @return the previously configured message handler or NULL if no message handler was configured
  196. */
  197. extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle,
  198. GEOSMessageHandler_r ef,
  199. void *userData);
  200. extern const char GEOS_DLL *GEOSversion();
  201. /************************************************************************
  202. *
  203. * NOTE - These functions are DEPRECATED. Please use the new Reader and
  204. * writer APIS!
  205. *
  206. ***********************************************************************/
  207. extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
  208. const char *wkt);
  209. extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
  210. const GEOSGeometry* g);
  211. /*
  212. * Specify whether output WKB should be 2d or 3d.
  213. * Return previously set number of dimensions.
  214. */
  215. extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
  216. extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
  217. int newDims);
  218. /*
  219. * Specify whether the WKB byte order is big or little endian.
  220. * The return value is the previous byte order.
  221. */
  222. extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
  223. extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
  224. int byteOrder);
  225. extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
  226. const unsigned char *wkb,
  227. size_t size);
  228. extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
  229. const GEOSGeometry* g,
  230. size_t *size);
  231. extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
  232. const unsigned char *hex,
  233. size_t size);
  234. extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
  235. const GEOSGeometry* g,
  236. size_t *size);
  237. /************************************************************************
  238. *
  239. * Coordinate Sequence functions
  240. *
  241. ***********************************************************************/
  242. /*
  243. * Create a Coordinate sequence with ``size'' coordinates
  244. * of ``dims'' dimensions.
  245. * Return NULL on exception.
  246. */
  247. extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
  248. GEOSContextHandle_t handle,
  249. unsigned int size,
  250. unsigned int dims);
  251. /*
  252. * Clone a Coordinate Sequence.
  253. * Return NULL on exception.
  254. */
  255. extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
  256. GEOSContextHandle_t handle,
  257. const GEOSCoordSequence* s);
  258. /*
  259. * Destroy a Coordinate Sequence.
  260. */
  261. extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
  262. GEOSCoordSequence* s);
  263. /*
  264. * Set ordinate values in a Coordinate Sequence.
  265. * Return 0 on exception.
  266. */
  267. extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
  268. GEOSCoordSequence* s, unsigned int idx,
  269. double val);
  270. extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
  271. GEOSCoordSequence* s, unsigned int idx,
  272. double val);
  273. extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
  274. GEOSCoordSequence* s, unsigned int idx,
  275. double val);
  276. extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
  277. GEOSCoordSequence* s,
  278. unsigned int idx,
  279. unsigned int dim, double val);
  280. /*
  281. * Get ordinate values from a Coordinate Sequence.
  282. * Return 0 on exception.
  283. */
  284. extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
  285. const GEOSCoordSequence* s,
  286. unsigned int idx, double *val);
  287. extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
  288. const GEOSCoordSequence* s,
  289. unsigned int idx, double *val);
  290. extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
  291. const GEOSCoordSequence* s,
  292. unsigned int idx, double *val);
  293. extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
  294. const GEOSCoordSequence* s,
  295. unsigned int idx,
  296. unsigned int dim, double *val);
  297. /*
  298. * Get size and dimensions info from a Coordinate Sequence.
  299. * Return 0 on exception.
  300. */
  301. extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
  302. const GEOSCoordSequence* s,
  303. unsigned int *size);
  304. extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
  305. const GEOSCoordSequence* s,
  306. unsigned int *dims);
  307. /*
  308. * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
  309. * if it has counter-clockwise orientation, 0 otherwise.
  310. * Return 0 on exception, 1 on success.
  311. */
  312. extern int GEOS_DLL GEOSCoordSeq_isCCW_r(GEOSContextHandle_t handle,
  313. const GEOSCoordSequence* s,
  314. char* is_ccw);
  315. /************************************************************************
  316. *
  317. * Linear referencing functions -- there are more, but these are
  318. * probably sufficient for most purposes
  319. *
  320. ***********************************************************************/
  321. /*
  322. * GEOSGeometry ownership is retained by caller
  323. */
  324. /* Return distance of point 'p' projected on 'g' from origin
  325. * of 'g'. Geometry 'g' must be a lineal geometry */
  326. extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
  327. const GEOSGeometry *g,
  328. const GEOSGeometry *p);
  329. /* Return closest point to given distance within geometry
  330. * Geometry must be a LineString */
  331. extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
  332. const GEOSGeometry *g,
  333. double d);
  334. extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
  335. const GEOSGeometry *g,
  336. const GEOSGeometry *p);
  337. extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
  338. GEOSContextHandle_t handle,
  339. const GEOSGeometry *g,
  340. double d);
  341. /************************************************************************
  342. *
  343. * Buffer related functions
  344. *
  345. ***********************************************************************/
  346. /* @return NULL on exception */
  347. extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
  348. const GEOSGeometry* g,
  349. double width, int quadsegs);
  350. enum GEOSBufCapStyles {
  351. GEOSBUF_CAP_ROUND=1,
  352. GEOSBUF_CAP_FLAT=2,
  353. GEOSBUF_CAP_SQUARE=3
  354. };
  355. enum GEOSBufJoinStyles {
  356. GEOSBUF_JOIN_ROUND=1,
  357. GEOSBUF_JOIN_MITRE=2,
  358. GEOSBUF_JOIN_BEVEL=3
  359. };
  360. /* @return 0 on exception */
  361. extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
  362. GEOSContextHandle_t handle);
  363. extern void GEOS_DLL GEOSBufferParams_destroy_r(
  364. GEOSContextHandle_t handle,
  365. GEOSBufferParams* parms);
  366. /* @return 0 on exception */
  367. extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
  368. GEOSContextHandle_t handle,
  369. GEOSBufferParams* p,
  370. int style);
  371. /* @return 0 on exception */
  372. extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
  373. GEOSContextHandle_t handle,
  374. GEOSBufferParams* p,
  375. int joinStyle);
  376. /* @return 0 on exception */
  377. extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
  378. GEOSContextHandle_t handle,
  379. GEOSBufferParams* p,
  380. double mitreLimit);
  381. /* @return 0 on exception */
  382. extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
  383. GEOSContextHandle_t handle,
  384. GEOSBufferParams* p,
  385. int quadSegs);
  386. /* @param singleSided: 1 for single sided, 0 otherwise */
  387. /* @return 0 on exception */
  388. extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
  389. GEOSContextHandle_t handle,
  390. GEOSBufferParams* p,
  391. int singleSided);
  392. /* @return NULL on exception */
  393. extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
  394. GEOSContextHandle_t handle,
  395. const GEOSGeometry* g,
  396. const GEOSBufferParams* p,
  397. double width);
  398. /* These functions return NULL on exception. */
  399. extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
  400. const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
  401. int joinStyle, double mitreLimit);
  402. /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
  403. /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
  404. extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
  405. GEOSContextHandle_t handle,
  406. const GEOSGeometry* g, double width, int quadsegs,
  407. int joinStyle, double mitreLimit, int leftSide);
  408. /*
  409. * Only LINESTRINGs are accepted.
  410. * @param width : offset distance.
  411. * negative for right side offset.
  412. * positive for left side offset.
  413. * @return NULL on exception
  414. */
  415. extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
  416. const GEOSGeometry* g, double width, int quadsegs,
  417. int joinStyle, double mitreLimit);
  418. /************************************************************************
  419. *
  420. * Geometry Constructors.
  421. * GEOSCoordSequence* arguments will become ownership of the returned object.
  422. * All functions return NULL on exception.
  423. *
  424. ***********************************************************************/
  425. extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
  426. GEOSContextHandle_t handle,
  427. GEOSCoordSequence* s);
  428. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
  429. GEOSContextHandle_t handle);
  430. extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
  431. GEOSContextHandle_t handle,
  432. GEOSCoordSequence* s);
  433. extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
  434. GEOSContextHandle_t handle,
  435. GEOSCoordSequence* s);
  436. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
  437. GEOSContextHandle_t handle);
  438. /*
  439. * Second argument is an array of GEOSGeometry* objects.
  440. * The caller remains owner of the array, but pointed-to
  441. * objects become ownership of the returned GEOSGeometry.
  442. */
  443. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
  444. GEOSContextHandle_t handle);
  445. extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
  446. GEOSContextHandle_t handle,
  447. GEOSGeometry* shell,
  448. GEOSGeometry** holes,
  449. unsigned int nholes);
  450. extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
  451. GEOSContextHandle_t handle, int type,
  452. GEOSGeometry* *geoms,
  453. unsigned int ngeoms);
  454. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
  455. GEOSContextHandle_t handle, int type);
  456. extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
  457. const GEOSGeometry* g);
  458. /************************************************************************
  459. *
  460. * Memory management
  461. *
  462. ***********************************************************************/
  463. extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
  464. GEOSGeometry* g);
  465. /************************************************************************
  466. *
  467. * Topology operations - return NULL on exception.
  468. *
  469. ***********************************************************************/
  470. extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
  471. const GEOSGeometry* g);
  472. extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
  473. const GEOSGeometry* g1,
  474. const GEOSGeometry* g2);
  475. extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
  476. const GEOSGeometry* g);
  477. /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
  478. * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
  479. * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
  480. * be used as an extremely generalized representation for the given geometry.
  481. */
  482. extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t handle,
  483. const GEOSGeometry* g);
  484. /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
  485. * The minimum diameter is defined to be the width of the smallest band that
  486. * contains the geometry, where a band is a strip of the plane defined
  487. * by two parallel lines. This can be thought of as the smallest hole that the geometry
  488. * can be moved through, with a single rotation.
  489. */
  490. extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth_r(GEOSContextHandle_t handle,
  491. const GEOSGeometry* g);
  492. extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine_r(GEOSContextHandle_t handle,
  493. const GEOSGeometry* g);
  494. extern int GEOS_DLL GEOSMinimumClearance_r(GEOSContextHandle_t handle,
  495. const GEOSGeometry* g,
  496. double* distance);
  497. extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
  498. const GEOSGeometry* g1,
  499. const GEOSGeometry* g2);
  500. extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
  501. const GEOSGeometry* g1,
  502. const GEOSGeometry* g2);
  503. extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
  504. const GEOSGeometry* g);
  505. extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
  506. const GEOSGeometry* g1,
  507. const GEOSGeometry* g2);
  508. extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
  509. const GEOSGeometry* g);
  510. /* @deprecated in 3.3.0: use GEOSUnaryUnion_r instead */
  511. extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
  512. const GEOSGeometry* g);
  513. extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
  514. const GEOSGeometry* g);
  515. extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
  516. const GEOSGeometry* g);
  517. extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
  518. const GEOSGeometry* g);
  519. /* Fast, non-robust intersection between an arbitrary geometry and
  520. * a rectangle. The returned geometry may be invalid. */
  521. extern GEOSGeometry GEOS_DLL *GEOSClipByRect_r(GEOSContextHandle_t handle,
  522. const GEOSGeometry* g,
  523. double xmin, double ymin,
  524. double xmax, double ymax);
  525. /*
  526. * all arguments remain ownership of the caller
  527. * (both Geometries and pointers)
  528. */
  529. /*
  530. * Polygonizes a set of Geometries which contain linework that
  531. * represents the edges of a planar graph.
  532. *
  533. * Any dimension of Geometry is handled - the constituent linework
  534. * is extracted to form the edges.
  535. *
  536. * The edges must be correctly noded; that is, they must only meet
  537. * at their endpoints.
  538. * The Polygonizer will still run on incorrectly noded input
  539. * but will not form polygons from incorrectly noded edges.
  540. *
  541. * The Polygonizer reports the follow kinds of errors:
  542. *
  543. * - Dangles - edges which have one or both ends which are
  544. * not incident on another edge endpoint
  545. * - Cut Edges - edges which are connected at both ends but
  546. * which do not form part of polygon
  547. * - Invalid Ring Lines - edges which form rings which are invalid
  548. * (e.g. the component lines contain a self-intersection)
  549. *
  550. * Errors are reported to output parameters "cuts", "dangles" and
  551. * "invalid" (if not-null). Formed polygons are returned as a
  552. * collection. NULL is returned on exception. All returned
  553. * geometries must be destroyed by caller.
  554. *
  555. */
  556. extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
  557. const GEOSGeometry *const geoms[],
  558. unsigned int ngeoms);
  559. extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
  560. GEOSContextHandle_t handle,
  561. const GEOSGeometry * const geoms[],
  562. unsigned int ngeoms);
  563. extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
  564. const GEOSGeometry* input, GEOSGeometry** cuts,
  565. GEOSGeometry** dangles, GEOSGeometry** invalidRings);
  566. extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
  567. const GEOSGeometry* g);
  568. extern GEOSGeometry GEOS_DLL *GEOSReverse_r(GEOSContextHandle_t handle,
  569. const GEOSGeometry* g);
  570. extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
  571. const GEOSGeometry* g,
  572. double tolerance);
  573. extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
  574. GEOSContextHandle_t handle,
  575. const GEOSGeometry* g, double tolerance);
  576. /*
  577. * Return all distinct vertices of input geometry as a MULTIPOINT.
  578. * Note that only 2 dimensions of the vertices are considered when
  579. * testing for equality.
  580. */
  581. extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
  582. GEOSContextHandle_t handle,
  583. const GEOSGeometry* g);
  584. /*
  585. * Find paths shared between the two given lineal geometries.
  586. *
  587. * Returns a GEOMETRYCOLLECTION having two elements:
  588. * - first element is a MULTILINESTRING containing shared paths
  589. * having the _same_ direction on both inputs
  590. * - second element is a MULTILINESTRING containing shared paths
  591. * having the _opposite_ direction on the two inputs
  592. *
  593. * Returns NULL on exception
  594. */
  595. extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
  596. const GEOSGeometry* g1, const GEOSGeometry* g2);
  597. /*
  598. * Snap first geometry on to second with given tolerance
  599. * Returns a newly allocated geometry, or NULL on exception
  600. */
  601. extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
  602. const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
  603. /*
  604. * Return a Delaunay triangulation of the vertex of the given geometry
  605. *
  606. * @param g the input geometry whose vertex will be used as "sites"
  607. * @param tolerance optional snapping tolerance to use for improved robustness
  608. * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
  609. * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
  610. *
  611. * @return a newly allocated geometry, or NULL on exception
  612. */
  613. extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
  614. GEOSContextHandle_t handle,
  615. const GEOSGeometry *g,
  616. double tolerance,
  617. int onlyEdges);
  618. /*
  619. * Returns the Voronoi polygons of a set of Vertices given as input
  620. *
  621. * @param g the input geometry whose vertex will be used as sites.
  622. * @param tolerance snapping tolerance to use for improved robustness
  623. * @param onlyEdges whether to return only edges of the Voronoi cells
  624. * @param env clipping envelope for the returned diagram, automatically
  625. * determined if NULL.
  626. * The diagram will be clipped to the larger
  627. * of this envelope or an envelope surrounding the sites.
  628. *
  629. * @return a newly allocated geometry, or NULL on exception.
  630. */
  631. extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
  632. GEOSContextHandle_t extHandle,
  633. const GEOSGeometry *g,
  634. const GEOSGeometry *env,
  635. double tolerance,
  636. int onlyEdges);
  637. /*
  638. * Computes the coordinate where two line segments intersect, if any
  639. *
  640. * @param ax0 x-coordinate of first point in first segment
  641. * @param ay0 y-coordinate of first point in first segment
  642. * @param ax1 x-coordinate of second point in first segment
  643. * @param ay1 y-coordinate of second point in first segment
  644. * @param bx0 x-coordinate of first point in second segment
  645. * @param by0 y-coordinate of first point in second segment
  646. * @param bx1 x-coordinate of second point in second segment
  647. * @param by1 y-coordinate of second point in second segment
  648. * @param cx x-coordinate of intersection point
  649. * @param cy y-coordinate of intersection point
  650. *
  651. * @return 0 on error, 1 on success, -1 if segments do not intersect
  652. */
  653. extern int GEOS_DLL GEOSSegmentIntersection_r(
  654. GEOSContextHandle_t extHandle,
  655. double ax0, double ay0,
  656. double ax1, double ay1,
  657. double bx0, double by0,
  658. double bx1, double by1,
  659. double* cx, double* cy);
  660. /************************************************************************
  661. *
  662. * Binary predicates - return 2 on exception, 1 on true, 0 on false
  663. *
  664. ***********************************************************************/
  665. extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
  666. const GEOSGeometry* g1,
  667. const GEOSGeometry* g2);
  668. extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
  669. const GEOSGeometry* g1,
  670. const GEOSGeometry* g2);
  671. extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
  672. const GEOSGeometry* g1,
  673. const GEOSGeometry* g2);
  674. extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
  675. const GEOSGeometry* g1,
  676. const GEOSGeometry* g2);
  677. extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
  678. const GEOSGeometry* g1,
  679. const GEOSGeometry* g2);
  680. extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
  681. const GEOSGeometry* g1,
  682. const GEOSGeometry* g2);
  683. extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
  684. const GEOSGeometry* g1,
  685. const GEOSGeometry* g2);
  686. extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
  687. const GEOSGeometry* g1,
  688. const GEOSGeometry* g2);
  689. extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
  690. const GEOSGeometry* g1,
  691. const GEOSGeometry* g2,
  692. double tolerance);
  693. extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
  694. const GEOSGeometry* g1,
  695. const GEOSGeometry* g2);
  696. extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
  697. const GEOSGeometry* g1,
  698. const GEOSGeometry* g2);
  699. /************************************************************************
  700. *
  701. * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
  702. *
  703. ***********************************************************************/
  704. /*
  705. * GEOSGeometry ownership is retained by caller
  706. */
  707. extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
  708. GEOSContextHandle_t handle,
  709. const GEOSGeometry* g);
  710. extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
  711. const GEOSPreparedGeometry* g);
  712. extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
  713. const GEOSPreparedGeometry* pg1,
  714. const GEOSGeometry* g2);
  715. extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
  716. const GEOSPreparedGeometry* pg1,
  717. const GEOSGeometry* g2);
  718. extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
  719. const GEOSPreparedGeometry* pg1,
  720. const GEOSGeometry* g2);
  721. extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
  722. const GEOSPreparedGeometry* pg1,
  723. const GEOSGeometry* g2);
  724. extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
  725. const GEOSPreparedGeometry* pg1,
  726. const GEOSGeometry* g2);
  727. extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
  728. const GEOSPreparedGeometry* pg1,
  729. const GEOSGeometry* g2);
  730. extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
  731. const GEOSPreparedGeometry* pg1,
  732. const GEOSGeometry* g2);
  733. extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
  734. const GEOSPreparedGeometry* pg1,
  735. const GEOSGeometry* g2);
  736. extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
  737. const GEOSPreparedGeometry* pg1,
  738. const GEOSGeometry* g2);
  739. extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
  740. const GEOSPreparedGeometry* pg1,
  741. const GEOSGeometry* g2);
  742. /************************************************************************
  743. *
  744. * STRtree functions
  745. *
  746. ***********************************************************************/
  747. /*
  748. * GEOSGeometry ownership is retained by caller
  749. */
  750. extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
  751. GEOSContextHandle_t handle,
  752. size_t nodeCapacity);
  753. extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
  754. GEOSSTRtree *tree,
  755. const GEOSGeometry *g,
  756. void *item);
  757. extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
  758. GEOSSTRtree *tree,
  759. const GEOSGeometry *g,
  760. GEOSQueryCallback callback,
  761. void *userdata);
  762. extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest_r(GEOSContextHandle_t handle,
  763. GEOSSTRtree *tree,
  764. const GEOSGeometry* geom);
  765. extern const void GEOS_DLL *GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t handle,
  766. GEOSSTRtree *tree,
  767. const void* item,
  768. const GEOSGeometry* itemEnvelope,
  769. GEOSDistanceCallback distancefn,
  770. void* userdata);
  771. extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
  772. GEOSSTRtree *tree,
  773. GEOSQueryCallback callback,
  774. void *userdata);
  775. extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
  776. GEOSSTRtree *tree,
  777. const GEOSGeometry *g,
  778. void *item);
  779. extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
  780. GEOSSTRtree *tree);
  781. /************************************************************************
  782. *
  783. * Unary predicate - return 2 on exception, 1 on true, 0 on false
  784. *
  785. ***********************************************************************/
  786. extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
  787. const GEOSGeometry* g);
  788. extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
  789. const GEOSGeometry* g);
  790. extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
  791. const GEOSGeometry* g);
  792. extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
  793. const GEOSGeometry* g);
  794. extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
  795. const GEOSGeometry *g);
  796. /************************************************************************
  797. *
  798. * Dimensionally Extended 9 Intersection Model related
  799. *
  800. ***********************************************************************/
  801. /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
  802. enum GEOSRelateBoundaryNodeRules {
  803. /* MOD2 and OGC are the same rule, and is the default
  804. * used by GEOSRelatePattern
  805. */
  806. GEOSRELATE_BNR_MOD2=1,
  807. GEOSRELATE_BNR_OGC=1,
  808. GEOSRELATE_BNR_ENDPOINT=2,
  809. GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
  810. GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
  811. };
  812. /* return 2 on exception, 1 on true, 0 on false */
  813. extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
  814. const GEOSGeometry* g1,
  815. const GEOSGeometry* g2,
  816. const char *pat);
  817. /* return NULL on exception, a string to GEOSFree otherwise */
  818. extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
  819. const GEOSGeometry* g1,
  820. const GEOSGeometry* g2);
  821. /* return 2 on exception, 1 on true, 0 on false */
  822. extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
  823. const char *mat,
  824. const char *pat);
  825. /* return NULL on exception, a string to GEOSFree otherwise */
  826. extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
  827. const GEOSGeometry* g1,
  828. const GEOSGeometry* g2,
  829. int bnr);
  830. /************************************************************************
  831. *
  832. * Validity checking
  833. *
  834. ***********************************************************************/
  835. /* These are for use with GEOSisValidDetail (flags param) */
  836. enum GEOSValidFlags {
  837. GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
  838. };
  839. /* return 2 on exception, 1 on true, 0 on false */
  840. extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
  841. const GEOSGeometry* g);
  842. /* return NULL on exception, a string to GEOSFree otherwise */
  843. extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
  844. const GEOSGeometry* g);
  845. /*
  846. * Caller has the responsibility to destroy 'reason' (GEOSFree)
  847. * and 'location' (GEOSGeom_destroy) params
  848. * return 2 on exception, 1 when valid, 0 when invalid
  849. */
  850. extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
  851. const GEOSGeometry* g,
  852. int flags,
  853. char** reason,
  854. GEOSGeometry** location);
  855. /************************************************************************
  856. *
  857. * Geometry info
  858. *
  859. ***********************************************************************/
  860. /* Return NULL on exception, result must be freed by caller. */
  861. extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
  862. const GEOSGeometry* g);
  863. /* Return -1 on exception */
  864. extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
  865. const GEOSGeometry* g);
  866. /* Return 0 on exception */
  867. extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
  868. const GEOSGeometry* g);
  869. extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
  870. GEOSGeometry* g, int SRID);
  871. extern void GEOS_DLL *GEOSGeom_getUserData_r(GEOSContextHandle_t handle,
  872. const GEOSGeometry* g);
  873. extern void GEOS_DLL GEOSGeom_setUserData_r(GEOSContextHandle_t handle,
  874. GEOSGeometry* g, void* userData);
  875. /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
  876. * for non-multi geometries. Older GEOS versions only accept
  877. * GeometryCollections or Multi* geometries here, and are likely to crash
  878. * when fed simple geometries, so beware if you need compatibility with
  879. * old GEOS versions.
  880. */
  881. extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
  882. const GEOSGeometry* g);
  883. /*
  884. * Return NULL on exception.
  885. * Returned object is a pointer to internal storage:
  886. * it must NOT be destroyed directly.
  887. * Up to GEOS 3.2.0 the input geometry must be a Collection, in
  888. * later version it doesn't matter (getGeometryN(0) for a single will
  889. * return the input).
  890. */
  891. extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
  892. GEOSContextHandle_t handle,
  893. const GEOSGeometry* g, int n);
  894. /* Return -1 on exception */
  895. extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
  896. GEOSGeometry* g);
  897. /** This option causes #GEOSGeom_setPrecision_r()
  898. * to not attempt at preserving the topology */
  899. #define GEOS_PREC_NO_TOPO (1<<0)
  900. /** This option causes #GEOSGeom_setPrecision_r()
  901. * to retain collapsed elements */
  902. #define GEOS_PREC_KEEP_COLLAPSED (1<<1)
  903. /**
  904. * Set the geometry's precision, optionally rounding all its
  905. * coordinates to the precision grid (if it changes).
  906. *
  907. * Note that operations will always be performed in the precision
  908. * of the geometry with higher precision (smaller "gridSize").
  909. * That same precision will be attached to the operation outputs.
  910. *
  911. * @param gridSize size of the precision grid, or 0 for FLOATING
  912. * precision.
  913. * @param flags The bitwise OR of one of more of the
  914. * @ref GEOS_PREC_NO_TOPO "precision options"
  915. * @retuns NULL on exception or a new GEOSGeometry object
  916. *
  917. */
  918. extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision_r(
  919. GEOSContextHandle_t handle,
  920. const GEOSGeometry *g,
  921. double gridSize, int flags);
  922. /**
  923. * Get a geometry's precision
  924. *
  925. * @return the size of the geometry's precision grid, 0 for FLOATING
  926. * precision or -1 on exception
  927. */
  928. extern double GEOS_DLL GEOSGeom_getPrecision_r(
  929. GEOSContextHandle_t handle,
  930. const GEOSGeometry *g);
  931. /* Return -1 on exception */
  932. extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
  933. const GEOSGeometry* g);
  934. /* Return -1 on exception, Geometry must be a LineString. */
  935. extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
  936. const GEOSGeometry* g);
  937. /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
  938. extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x);
  939. extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y);
  940. extern int GEOS_DLL GEOSGeomGetZ_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *z);
  941. /*
  942. * Return NULL on exception, Geometry must be a Polygon.
  943. * Returned object is a pointer to internal storage:
  944. * it must NOT be destroyed directly.
  945. */
  946. extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
  947. GEOSContextHandle_t handle,
  948. const GEOSGeometry* g, int n);
  949. /*
  950. * Return NULL on exception, Geometry must be a Polygon.
  951. * Returned object is a pointer to internal storage:
  952. * it must NOT be destroyed directly.
  953. */
  954. extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
  955. GEOSContextHandle_t handle,
  956. const GEOSGeometry* g);
  957. /* Return -1 on exception */
  958. extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
  959. const GEOSGeometry* g);
  960. /*
  961. * Return NULL on exception.
  962. * Geometry must be a LineString, LinearRing or Point.
  963. */
  964. extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
  965. GEOSContextHandle_t handle,
  966. const GEOSGeometry* g);
  967. /*
  968. * Return 0 on exception (or empty geometry)
  969. */
  970. extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
  971. const GEOSGeometry* g);
  972. /*
  973. * Return 2 or 3.
  974. */
  975. extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
  976. const GEOSGeometry* g);
  977. /*
  978. * Return 0 on exception
  979. */
  980. extern int GEOS_DLL GEOSGeom_getXMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
  981. extern int GEOS_DLL GEOSGeom_getYMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
  982. extern int GEOS_DLL GEOSGeom_getXMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
  983. extern int GEOS_DLL GEOSGeom_getYMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
  984. /*
  985. * Return NULL on exception.
  986. * Must be LineString and must be freed by called.
  987. */
  988. extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n);
  989. extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
  990. extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
  991. /************************************************************************
  992. *
  993. * Misc functions
  994. *
  995. ***********************************************************************/
  996. /* Return 0 on exception, 1 otherwise */
  997. extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
  998. const GEOSGeometry* g, double *area);
  999. extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
  1000. const GEOSGeometry* g, double *length);
  1001. extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
  1002. const GEOSGeometry* g1,
  1003. const GEOSGeometry* g2, double *dist);
  1004. extern int GEOS_DLL GEOSDistanceIndexed_r(GEOSContextHandle_t handle,
  1005. const GEOSGeometry* g1,
  1006. const GEOSGeometry* g2, double *dist);
  1007. extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
  1008. const GEOSGeometry *g1,
  1009. const GEOSGeometry *g2,
  1010. double *dist);
  1011. extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
  1012. const GEOSGeometry *g1,
  1013. const GEOSGeometry *g2,
  1014. double densifyFrac, double *dist);
  1015. extern int GEOS_DLL GEOSFrechetDistance_r(GEOSContextHandle_t handle,
  1016. const GEOSGeometry *g1,
  1017. const GEOSGeometry *g2,
  1018. double *dist);
  1019. extern int GEOS_DLL GEOSFrechetDistanceDensify_r(GEOSContextHandle_t handle,
  1020. const GEOSGeometry *g1,
  1021. const GEOSGeometry *g2,
  1022. double densifyFrac, double *dist);
  1023. extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
  1024. const GEOSGeometry *g, double *length);
  1025. /* Return 0 on exception, the closest points of the two geometries otherwise.
  1026. * The first point comes from g1 geometry and the second point comes from g2.
  1027. */
  1028. extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r(
  1029. GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2);
  1030. /************************************************************************
  1031. *
  1032. * Algorithms
  1033. *
  1034. ***********************************************************************/
  1035. /* Walking from A to B:
  1036. * return -1 if reaching P takes a counter-clockwise (left) turn
  1037. * return 1 if reaching P takes a clockwise (right) turn
  1038. * return 0 if P is collinear with A-B
  1039. *
  1040. * On exceptions, return 2.
  1041. *
  1042. */
  1043. extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
  1044. double Ax, double Ay, double Bx, double By, double Px, double Py);
  1045. /************************************************************************
  1046. *
  1047. * Reader and Writer APIs
  1048. *
  1049. ***********************************************************************/
  1050. typedef struct GEOSWKTReader_t GEOSWKTReader;
  1051. typedef struct GEOSWKTWriter_t GEOSWKTWriter;
  1052. typedef struct GEOSWKBReader_t GEOSWKBReader;
  1053. typedef struct GEOSWKBWriter_t GEOSWKBWriter;
  1054. /* WKT Reader */
  1055. extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
  1056. GEOSContextHandle_t handle);
  1057. extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
  1058. GEOSWKTReader* reader);
  1059. extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
  1060. GEOSWKTReader* reader,
  1061. const char *wkt);
  1062. /* WKT Writer */
  1063. extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
  1064. GEOSContextHandle_t handle);
  1065. extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
  1066. GEOSWKTWriter* writer);
  1067. extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
  1068. GEOSWKTWriter* writer,
  1069. const GEOSGeometry* g);
  1070. extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
  1071. GEOSWKTWriter *writer,
  1072. char trim);
  1073. extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
  1074. GEOSWKTWriter *writer,
  1075. int precision);
  1076. extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
  1077. GEOSWKTWriter *writer,
  1078. int dim);
  1079. extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
  1080. GEOSWKTWriter *writer);
  1081. extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
  1082. GEOSWKTWriter *writer,
  1083. int useOld3D);
  1084. /* WKB Reader */
  1085. extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
  1086. GEOSContextHandle_t handle);
  1087. extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
  1088. GEOSWKBReader* reader);
  1089. extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
  1090. GEOSWKBReader* reader,
  1091. const unsigned char *wkb,
  1092. size_t size);
  1093. extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
  1094. GEOSContextHandle_t handle,
  1095. GEOSWKBReader* reader,
  1096. const unsigned char *hex,
  1097. size_t size);
  1098. /* WKB Writer */
  1099. extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
  1100. GEOSContextHandle_t handle);
  1101. extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
  1102. GEOSWKBWriter* writer);
  1103. /* The caller owns the results for these two methods! */
  1104. extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
  1105. GEOSContextHandle_t handle,
  1106. GEOSWKBWriter* writer,
  1107. const GEOSGeometry* g,
  1108. size_t *size);
  1109. extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
  1110. GEOSContextHandle_t handle,
  1111. GEOSWKBWriter* writer,
  1112. const GEOSGeometry* g,
  1113. size_t *size);
  1114. /*
  1115. * Specify whether output WKB should be 2d or 3d.
  1116. * Return previously set number of dimensions.
  1117. */
  1118. extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
  1119. GEOSContextHandle_t handle,
  1120. const GEOSWKBWriter* writer);
  1121. extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
  1122. GEOSContextHandle_t handle,
  1123. GEOSWKBWriter* writer, int newDimension);
  1124. /*
  1125. * Specify whether the WKB byte order is big or little endian.
  1126. * The return value is the previous byte order.
  1127. */
  1128. extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
  1129. const GEOSWKBWriter* writer);
  1130. extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
  1131. GEOSWKBWriter* writer,
  1132. int byteOrder);
  1133. /*
  1134. * Specify whether SRID values should be output.
  1135. */
  1136. extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
  1137. const GEOSWKBWriter* writer);
  1138. extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
  1139. GEOSWKBWriter* writer, const char writeSRID);
  1140. /*
  1141. * Free buffers returned by stuff like GEOSWKBWriter_write(),
  1142. * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
  1143. */
  1144. extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer);
  1145. /* External code to GEOS can define GEOS_USE_ONLY_R_API to avoid the */
  1146. /* non _r API to be available */
  1147. #ifndef GEOS_USE_ONLY_R_API
  1148. /************************************************************************
  1149. *
  1150. * Initialization, cleanup, version
  1151. *
  1152. ***********************************************************************/
  1153. extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
  1154. GEOSMessageHandler error_function);
  1155. extern void GEOS_DLL finishGEOS(void);
  1156. /************************************************************************
  1157. *
  1158. * NOTE - These functions are DEPRECATED. Please use the new Reader and
  1159. * writer APIS!
  1160. *
  1161. ***********************************************************************/
  1162. extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
  1163. extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
  1164. /*
  1165. * Specify whether output WKB should be 2d or 3d.
  1166. * Return previously set number of dimensions.
  1167. */
  1168. extern int GEOS_DLL GEOS_getWKBOutputDims();
  1169. extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
  1170. /*
  1171. * Specify whether the WKB byte order is big or little endian.
  1172. * The return value is the previous byte order.
  1173. */
  1174. extern int GEOS_DLL GEOS_getWKBByteOrder();
  1175. extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
  1176. extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
  1177. extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
  1178. extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
  1179. extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
  1180. /************************************************************************
  1181. *
  1182. * Coordinate Sequence functions
  1183. *
  1184. ***********************************************************************/
  1185. /*
  1186. * Create a Coordinate sequence with ``size'' coordinates
  1187. * of ``dims'' dimensions.
  1188. * Return NULL on exception.
  1189. */
  1190. extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
  1191. /*
  1192. * Clone a Coordinate Sequence.
  1193. * Return NULL on exception.
  1194. */
  1195. extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
  1196. /*
  1197. * Destroy a Coordinate Sequence.
  1198. */
  1199. extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
  1200. /*
  1201. * Set ordinate values in a Coordinate Sequence.
  1202. * Return 0 on exception.
  1203. */
  1204. extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
  1205. unsigned int idx, double val);
  1206. extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
  1207. unsigned int idx, double val);
  1208. extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
  1209. unsigned int idx, double val);
  1210. extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
  1211. unsigned int idx, unsigned int dim, double val);
  1212. /*
  1213. * Get ordinate values from a Coordinate Sequence.
  1214. * Return 0 on exception.
  1215. */
  1216. extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
  1217. unsigned int idx, double *val);
  1218. extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
  1219. unsigned int idx, double *val);
  1220. extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
  1221. unsigned int idx, double *val);
  1222. extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
  1223. unsigned int idx, unsigned int dim, double *val);
  1224. /*
  1225. * Get size and dimensions info from a Coordinate Sequence.
  1226. * Return 0 on exception.
  1227. */
  1228. extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
  1229. unsigned int *size);
  1230. extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
  1231. unsigned int *dims);
  1232. /*
  1233. * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
  1234. * if it has counter-clockwise orientation, 0 otherwise.
  1235. * Return 0 on exception, 1 on success.
  1236. */
  1237. extern int GEOS_DLL GEOSCoordSeq_isCCW(const GEOSCoordSequence* s, char* is_ccw);
  1238. /************************************************************************
  1239. *
  1240. * Linear referencing functions -- there are more, but these are
  1241. * probably sufficient for most purposes
  1242. *
  1243. ***********************************************************************/
  1244. /*
  1245. * GEOSGeometry ownership is retained by caller
  1246. */
  1247. /* Return distance of point 'p' projected on 'g' from origin
  1248. * of 'g'. Geometry 'g' must be a lineal geometry */
  1249. extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
  1250. const GEOSGeometry* p);
  1251. /* Return closest point to given distance within geometry
  1252. * Geometry must be a LineString */
  1253. extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
  1254. double d);
  1255. extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
  1256. const GEOSGeometry* p);
  1257. extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
  1258. double d);
  1259. /************************************************************************
  1260. *
  1261. * Buffer related functions
  1262. *
  1263. ***********************************************************************/
  1264. /* @return NULL on exception */
  1265. extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
  1266. double width, int quadsegs);
  1267. /* @return 0 on exception */
  1268. extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
  1269. extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
  1270. /* @return 0 on exception */
  1271. extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
  1272. GEOSBufferParams* p,
  1273. int style);
  1274. /* @return 0 on exception */
  1275. extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
  1276. GEOSBufferParams* p,
  1277. int joinStyle);
  1278. /* @return 0 on exception */
  1279. extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
  1280. GEOSBufferParams* p,
  1281. double mitreLimit);
  1282. /* @return 0 on exception */
  1283. extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
  1284. GEOSBufferParams* p,
  1285. int quadSegs);
  1286. /* @param singleSided: 1 for single sided, 0 otherwise */
  1287. /* @return 0 on exception */
  1288. extern int GEOS_DLL GEOSBufferParams_setSingleSided(
  1289. GEOSBufferParams* p,
  1290. int singleSided);
  1291. /* @return NULL on exception */
  1292. extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
  1293. const GEOSGeometry* g,
  1294. const GEOSBufferParams* p,
  1295. double width);
  1296. /* These functions return NULL on exception. */
  1297. extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
  1298. double width, int quadsegs, int endCapStyle, int joinStyle,
  1299. double mitreLimit);
  1300. /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
  1301. /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
  1302. extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
  1303. double width, int quadsegs, int joinStyle, double mitreLimit,
  1304. int leftSide);
  1305. /*
  1306. * Only LINESTRINGs are accepted.
  1307. * @param width : offset distance.
  1308. * negative for right side offset.
  1309. * positive for left side offset.
  1310. * @return NULL on exception
  1311. */
  1312. extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
  1313. double width, int quadsegs, int joinStyle, double mitreLimit);
  1314. /************************************************************************
  1315. *
  1316. * Geometry Constructors.
  1317. * GEOSCoordSequence* arguments will become ownership of the returned object.
  1318. * All functions return NULL on exception.
  1319. *
  1320. ***********************************************************************/
  1321. extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
  1322. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
  1323. extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
  1324. extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
  1325. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
  1326. /*
  1327. * Second argument is an array of GEOSGeometry* objects.
  1328. * The caller remains owner of the array, but pointed-to
  1329. * objects become ownership of the returned GEOSGeometry.
  1330. */
  1331. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
  1332. extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
  1333. GEOSGeometry** holes, unsigned int nholes);
  1334. extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
  1335. GEOSGeometry* *geoms, unsigned int ngeoms);
  1336. extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
  1337. extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
  1338. /************************************************************************
  1339. *
  1340. * Memory management
  1341. *
  1342. ***********************************************************************/
  1343. extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
  1344. /************************************************************************
  1345. *
  1346. * Topology operations - return NULL on exception.
  1347. *
  1348. ***********************************************************************/
  1349. extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
  1350. extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1351. extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
  1352. /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
  1353. * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
  1354. * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
  1355. * be used as an extremely generalized representation for the given geometry.
  1356. */
  1357. extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle(const GEOSGeometry* g);
  1358. /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
  1359. * The minimum diameter is defined to be the width of the smallest band that
  1360. * contains the geometry, where a band is a strip of the plane defined
  1361. * by two parallel lines. This can be thought of as the smallest hole that the geometry
  1362. * can be moved through, with a single rotation.
  1363. */
  1364. extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
  1365. /* Computes the minimum clearance of a geometry. The minimum clearance is the smallest amount by which
  1366. * a vertex could be move to produce an invalid polygon, a non-simple linestring, or a multipoint with
  1367. * repeated points. If a geometry has a minimum clearance of 'eps', it can be said that:
  1368. *
  1369. * - No two distinct vertices in the geometry are separated by less than 'eps'
  1370. * - No vertex is closer than 'eps' to a line segment of which it is not an endpoint.
  1371. *
  1372. * If the minimum clearance cannot be defined for a geometry (such as with a single point, or a multipoint
  1373. * whose points are identical, a value of Infinity will be calculated.
  1374. *
  1375. * @param g the input geometry
  1376. * @param d a double to which the result can be stored
  1377. *
  1378. * @return 0 if no exception occurred
  1379. * 2 if an exception occurred
  1380. */
  1381. extern int GEOS_DLL GEOSMinimumClearance(const GEOSGeometry* g, double* d);
  1382. /* Returns a LineString whose endpoints define the minimum clearance of a geometry.
  1383. * If the geometry has no minimum clearance, an empty LineString will be returned.
  1384. *
  1385. * @param g the input geometry
  1386. * @return a LineString, or NULL if an exception occurred.
  1387. */
  1388. extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine(const GEOSGeometry* g);
  1389. extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1390. extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1391. extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
  1392. extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1393. extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
  1394. /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
  1395. extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
  1396. extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
  1397. extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
  1398. extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
  1399. extern GEOSGeometry GEOS_DLL *GEOSClipByRect(const GEOSGeometry* g, double xmin, double ymin, double xmax, double ymax);
  1400. /*
  1401. * all arguments remain ownership of the caller
  1402. * (both Geometries and pointers)
  1403. */
  1404. extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
  1405. extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
  1406. /*
  1407. * Polygonizes a set of Geometries which contain linework that
  1408. * represents the edges of a planar graph.
  1409. *
  1410. * Any dimension of Geometry is handled - the constituent linework
  1411. * is extracted to form the edges.
  1412. *
  1413. * The edges must be correctly noded; that is, they must only meet
  1414. * at their endpoints.
  1415. * The Polygonizer will still run on incorrectly noded input
  1416. * but will not form polygons from incorrectly noded edges.
  1417. *
  1418. * The Polygonizer reports the follow kinds of errors:
  1419. *
  1420. * - Dangles - edges which have one or both ends which are
  1421. * not incident on another edge endpoint
  1422. * - Cut Edges - edges which are connected at both ends but
  1423. * which do not form part of polygon
  1424. * - Invalid Ring Lines - edges which form rings which are invalid
  1425. * (e.g. the component lines contain a self-intersection)
  1426. *
  1427. * Errors are reported to output parameters "cuts", "dangles" and
  1428. * "invalid" (if not-null). Formed polygons are returned as a
  1429. * collection. NULL is returned on exception. All returned
  1430. * geometries must be destroyed by caller.
  1431. *
  1432. */
  1433. extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
  1434. GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
  1435. extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
  1436. extern GEOSGeometry GEOS_DLL *GEOSReverse(const GEOSGeometry* g);
  1437. extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
  1438. extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
  1439. double tolerance);
  1440. /*
  1441. * Return all distinct vertices of input geometry as a MULTIPOINT.
  1442. * Note that only 2 dimensions of the vertices are considered when
  1443. * testing for equality.
  1444. */
  1445. extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
  1446. const GEOSGeometry* g);
  1447. /*
  1448. * Find paths shared between the two given lineal geometries.
  1449. *
  1450. * Returns a GEOMETRYCOLLECTION having two elements:
  1451. * - first element is a MULTILINESTRING containing shared paths
  1452. * having the _same_ direction on both inputs
  1453. * - second element is a MULTILINESTRING containing shared paths
  1454. * having the _opposite_ direction on the two inputs
  1455. *
  1456. * Returns NULL on exception
  1457. */
  1458. extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
  1459. const GEOSGeometry* g2);
  1460. /*
  1461. * Snap first geometry on to second with given tolerance
  1462. * Returns a newly allocated geometry, or NULL on exception
  1463. */
  1464. extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
  1465. const GEOSGeometry* g2, double tolerance);
  1466. /*
  1467. * Return a Delaunay triangulation of the vertex of the given geometry
  1468. *
  1469. * @param g the input geometry whose vertex will be used as "sites"
  1470. * @param tolerance optional snapping tolerance to use for improved robustness
  1471. * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
  1472. * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
  1473. *
  1474. * @return a newly allocated geometry, or NULL on exception
  1475. */
  1476. extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
  1477. const GEOSGeometry *g,
  1478. double tolerance,
  1479. int onlyEdges);
  1480. /*
  1481. * Returns the Voronoi polygons of a set of Vertices given as input
  1482. *
  1483. * @param g the input geometry whose vertex will be used as sites.
  1484. * @param tolerance snapping tolerance to use for improved robustness
  1485. * @param onlyEdges whether to return only edges of the voronoi cells
  1486. * @param env clipping envelope for the returned diagram, automatically
  1487. * determined if NULL.
  1488. * The diagram will be clipped to the larger
  1489. * of this envelope or an envelope surrounding the sites.
  1490. *
  1491. * @return a newly allocated geometry, or NULL on exception.
  1492. */
  1493. extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
  1494. const GEOSGeometry *g,
  1495. const GEOSGeometry *env,
  1496. double tolerance,
  1497. int onlyEdges);
  1498. /*
  1499. * Computes the coordinate where two line segments intersect, if any
  1500. *
  1501. * @param ax0 x-coordinate of first point in first segment
  1502. * @param ay0 y-coordinate of first point in first segment
  1503. * @param ax1 x-coordinate of second point in first segment
  1504. * @param ay1 y-coordinate of second point in first segment
  1505. * @param bx0 x-coordinate of first point in second segment
  1506. * @param by0 y-coordinate of first point in second segment
  1507. * @param bx1 x-coordinate of second point in second segment
  1508. * @param by1 y-coordinate of second point in second segment
  1509. * @param cx x-coordinate of intersection point
  1510. * @param cy y-coordinate of intersection point
  1511. *
  1512. * @return 0 on error, 1 on success, -1 if segments do not intersect
  1513. */
  1514. extern int GEOS_DLL GEOSSegmentIntersection(
  1515. double ax0, double ay0,
  1516. double ax1, double ay1,
  1517. double bx0, double by0,
  1518. double bx1, double by1,
  1519. double* cx, double* cy);
  1520. /************************************************************************
  1521. *
  1522. * Binary predicates - return 2 on exception, 1 on true, 0 on false
  1523. *
  1524. ***********************************************************************/
  1525. extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1526. extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1527. extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1528. extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1529. extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1530. extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1531. extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1532. extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1533. extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
  1534. extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1535. extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1536. /************************************************************************
  1537. *
  1538. * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
  1539. *
  1540. ***********************************************************************/
  1541. /*
  1542. * GEOSGeometry ownership is retained by caller
  1543. */
  1544. extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
  1545. extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
  1546. extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1547. extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1548. extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1549. extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1550. extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1551. extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1552. extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1553. extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1554. extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1555. extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
  1556. /************************************************************************
  1557. *
  1558. * STRtree functions
  1559. *
  1560. ***********************************************************************/
  1561. /*
  1562. * GEOSGeometry ownership is retained by caller
  1563. */
  1564. /*
  1565. * Create a new R-tree using the Sort-Tile-Recursive algorithm (STRtree) for two-dimensional
  1566. * spatial data.
  1567. *
  1568. * @param nodeCapacity the maximum number of child nodes that a node may have. The minimum
  1569. * recommended capacity value is 4. If unsure, use a default node capacity of 10.
  1570. * @return a pointer to the created tree
  1571. */
  1572. extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
  1573. /*
  1574. * Insert an item into an STRtree
  1575. *
  1576. * @param tree the STRtree in which the item should be inserted
  1577. * @param g a GEOSGeometry whose envelope corresponds to the extent of 'item'
  1578. * @param item the item to insert into the tree
  1579. */
  1580. extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
  1581. const GEOSGeometry *g,
  1582. void *item);
  1583. /*
  1584. * Query an STRtree for items intersecting a specified envelope
  1585. *
  1586. * @param tree the STRtree to search
  1587. * @param g a GEOSGeomety from which a query envelope will be extracted
  1588. * @param callback a function to be executed for each item in the tree whose envelope intersects
  1589. * the envelope of 'g'. The callback function should take two parameters: a void
  1590. * pointer representing the located item in the tree, and a void userdata pointer.
  1591. * @param userdata an optional pointer to pe passed to 'callback' as an argument
  1592. */
  1593. extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
  1594. const GEOSGeometry *g,
  1595. GEOSQueryCallback callback,
  1596. void *userdata);
  1597. /*
  1598. * Returns the nearest item in the STRtree to the supplied GEOSGeometry.
  1599. * All items in the tree MUST be of type GEOSGeometry. If this is not the case, use
  1600. * GEOSSTRtree_nearest_generic instead.
  1601. *
  1602. * @param tree the STRtree to search
  1603. * @param geom the geometry with which the tree should be queried
  1604. * @return a const pointer to the nearest GEOSGeometry in the tree to 'geom', or NULL in
  1605. * case of exception
  1606. */
  1607. extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest(GEOSSTRtree *tree, const GEOSGeometry* geom);
  1608. /*
  1609. * Returns the nearest item in the STRtree to the supplied item
  1610. *
  1611. * @param tree the STRtree to search
  1612. * @param item the item with which the tree should be queried
  1613. * @param itemEnvelope a GEOSGeometry having the bounding box of 'item'
  1614. * @param distancefn a function that can compute the distance between two items
  1615. * in the STRtree. The function should return zero in case of error,
  1616. * and should store the computed distance to the location pointed to by
  1617. * the 'distance' argument. The computed distance between two items
  1618. * must not exceed the Cartesian distance between their envelopes.
  1619. * @param userdata optional pointer to arbitrary data; will be passed to distancefn
  1620. * each time it is called.
  1621. * @return a const pointer to the nearest item in the tree to 'item', or NULL in
  1622. * case of exception
  1623. */
  1624. extern const void GEOS_DLL *GEOSSTRtree_nearest_generic(GEOSSTRtree *tree,
  1625. const void* item,
  1626. const GEOSGeometry* itemEnvelope,
  1627. GEOSDistanceCallback distancefn,
  1628. void* userdata);
  1629. /*
  1630. * Iterates over all items in the STRtree
  1631. *
  1632. * @param tree the STRtree over which to iterate
  1633. * @param callback a function to be executed for each item in the tree.
  1634. */
  1635. extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
  1636. GEOSQueryCallback callback,
  1637. void *userdata);
  1638. /*
  1639. * Removes an item from the STRtree
  1640. *
  1641. * @param tree the STRtree from which to remove an item
  1642. * @param g the envelope of the item to remove
  1643. * @param the item to remove
  1644. * @return 0 if the item was not removed;
  1645. * 1 if the item was removed;
  1646. * 2 if an exception occurred
  1647. */
  1648. extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
  1649. const GEOSGeometry *g,
  1650. void *item);
  1651. extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
  1652. /************************************************************************
  1653. *
  1654. * Unary predicate - return 2 on exception, 1 on true, 0 on false
  1655. *
  1656. ***********************************************************************/
  1657. extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
  1658. extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
  1659. extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
  1660. extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
  1661. extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
  1662. /************************************************************************
  1663. *
  1664. * Dimensionally Extended 9 Intersection Model related
  1665. *
  1666. ***********************************************************************/
  1667. /* return 2 on exception, 1 on true, 0 on false */
  1668. extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
  1669. /* return NULL on exception, a string to GEOSFree otherwise */
  1670. extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
  1671. /* return 2 on exception, 1 on true, 0 on false */
  1672. extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
  1673. /* return NULL on exception, a string to GEOSFree otherwise */
  1674. extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
  1675. const GEOSGeometry* g2,
  1676. int bnr);
  1677. /************************************************************************
  1678. *
  1679. * Validity checking
  1680. *
  1681. ***********************************************************************/
  1682. /* return 2 on exception, 1 on true, 0 on false */
  1683. extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g);
  1684. /* return NULL on exception, a string to GEOSFree otherwise */
  1685. extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g);
  1686. /*
  1687. * Caller has the responsibility to destroy 'reason' (GEOSFree)
  1688. * and 'location' (GEOSGeom_destroy) params
  1689. * return 2 on exception, 1 when valid, 0 when invalid
  1690. * Use enum GEOSValidFlags values for the flags param.
  1691. */
  1692. extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
  1693. int flags,
  1694. char** reason, GEOSGeometry** location);
  1695. /************************************************************************
  1696. *
  1697. * Geometry info
  1698. *
  1699. ***********************************************************************/
  1700. /* Return NULL on exception, result must be freed by caller. */
  1701. extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g);
  1702. /* Return -1 on exception */
  1703. extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g);
  1704. /* Return 0 on exception */
  1705. extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
  1706. extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
  1707. extern void GEOS_DLL *GEOSGeom_getUserData(const GEOSGeometry* g);
  1708. extern void GEOS_DLL GEOSGeom_setUserData(GEOSGeometry* g, void* userData);
  1709. /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
  1710. * for non-multi geometries. Older GEOS versions only accept
  1711. * GeometryCollections or Multi* geometries here, and are likely to crash
  1712. * when fed simple geometries, so beware if you need compatibility with
  1713. * old GEOS versions.
  1714. */
  1715. extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
  1716. /*
  1717. * Return NULL on exception.
  1718. * Returned object is a pointer to internal storage:
  1719. * it must NOT be destroyed directly.
  1720. * Up to GEOS 3.2.0 the input geometry must be a Collection, in
  1721. * later version it doesn't matter (getGeometryN(0) for a single will
  1722. * return the input).
  1723. */
  1724. extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
  1725. /* Return -1 on exception */
  1726. extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g);
  1727. /* Return NULL on exception */
  1728. extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision(
  1729. const GEOSGeometry *g, double gridSize, int flags);
  1730. /* Return -1 on exception */
  1731. extern double GEOS_DLL GEOSGeom_getPrecision(const GEOSGeometry *g);
  1732. /* Return -1 on exception */
  1733. extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g);
  1734. /* Return -1 on exception, Geometry must be a LineString. */
  1735. extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g);
  1736. /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
  1737. extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x);
  1738. extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
  1739. extern int GEOS_DLL GEOSGeomGetZ(const GEOSGeometry *g, double *z);
  1740. /*
  1741. * Return NULL on exception, Geometry must be a Polygon.
  1742. * Returned object is a pointer to internal storage:
  1743. * it must NOT be destroyed directly.
  1744. */
  1745. extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
  1746. /*
  1747. * Return NULL on exception, Geometry must be a Polygon.
  1748. * Returned object is a pointer to internal storage:
  1749. * it must NOT be destroyed directly.
  1750. */
  1751. extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
  1752. /* Return -1 on exception */
  1753. extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g);
  1754. /*
  1755. * Return NULL on exception.
  1756. * Geometry must be a LineString, LinearRing or Point.
  1757. */
  1758. extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
  1759. /*
  1760. * Return 0 on exception (or empty geometry)
  1761. */
  1762. extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
  1763. /*
  1764. * Return 2 or 3.
  1765. */
  1766. extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
  1767. /*
  1768. * Return 0 on exception
  1769. */
  1770. extern int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value);
  1771. extern int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value);
  1772. extern int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value);
  1773. extern int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value);
  1774. /*
  1775. * Return NULL on exception.
  1776. * Must be LineString and must be freed by called.
  1777. */
  1778. extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n);
  1779. extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g);
  1780. extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g);
  1781. /************************************************************************
  1782. *
  1783. * Misc functions
  1784. *
  1785. ***********************************************************************/
  1786. /* Return 0 on exception, 1 otherwise */
  1787. extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area);
  1788. extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length);
  1789. extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
  1790. double *dist);
  1791. extern int GEOS_DLL GEOSDistanceIndexed(const GEOSGeometry* g1, const GEOSGeometry* g2,
  1792. double *dist);
  1793. extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
  1794. const GEOSGeometry *g2, double *dist);
  1795. extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
  1796. const GEOSGeometry *g2, double densifyFrac, double *dist);
  1797. extern int GEOS_DLL GEOSFrechetDistance(const GEOSGeometry *g1,
  1798. const GEOSGeometry *g2, double *dist);
  1799. extern int GEOS_DLL GEOSFrechetDistanceDensify(const GEOSGeometry *g1,
  1800. const GEOSGeometry *g2, double densifyFrac, double *dist);
  1801. extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length);
  1802. /* Return 0 on exception, the closest points of the two geometries otherwise.
  1803. * The first point comes from g1 geometry and the second point comes from g2.
  1804. */
  1805. extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints(
  1806. const GEOSGeometry* g1, const GEOSGeometry* g2);
  1807. /************************************************************************
  1808. *
  1809. * Algorithms
  1810. *
  1811. ***********************************************************************/
  1812. /* Walking from A to B:
  1813. * return -1 if reaching P takes a counter-clockwise (left) turn
  1814. * return 1 if reaching P takes a clockwise (right) turn
  1815. * return 0 if P is collinear with A-B
  1816. *
  1817. * On exceptions, return 2.
  1818. *
  1819. */
  1820. extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
  1821. double Px, double Py);
  1822. /************************************************************************
  1823. *
  1824. * Reader and Writer APIs
  1825. *
  1826. ***********************************************************************/
  1827. /* WKT Reader */
  1828. extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
  1829. extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
  1830. extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
  1831. /* WKT Writer */
  1832. extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
  1833. extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
  1834. extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g);
  1835. extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
  1836. extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
  1837. extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
  1838. extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
  1839. extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
  1840. /* WKB Reader */
  1841. extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
  1842. extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
  1843. extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
  1844. extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
  1845. /* WKB Writer */
  1846. extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
  1847. extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
  1848. /* The caller owns the results for these two methods! */
  1849. extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
  1850. extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
  1851. /*
  1852. * Specify whether output WKB should be 2d or 3d.
  1853. * Return previously set number of dimensions.
  1854. */
  1855. extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
  1856. extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
  1857. /*
  1858. * Specify whether the WKB byte order is big or little endian.
  1859. * The return value is the previous byte order.
  1860. */
  1861. extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
  1862. extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
  1863. /*
  1864. * Specify whether SRID values should be output.
  1865. */
  1866. extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
  1867. extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
  1868. /*
  1869. * Free buffers returned by stuff like GEOSWKBWriter_write(),
  1870. * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
  1871. */
  1872. extern void GEOS_DLL GEOSFree(void *buffer);
  1873. #endif /* #ifndef GEOS_USE_ONLY_R_API */
  1874. #ifdef __cplusplus
  1875. } // extern "C"
  1876. #endif
  1877. #endif /* #ifndef GEOS_C_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1