PostGIS  2.1.10dev-r@@SVN_REVISION@@
liblwgeom_internal.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright (C) 2011-2012 Sandro Santilli <strk@keybit.net>
7  * Copyright (C) 2011 Paul Ramsey <pramsey@cleverelephant.ca>
8  * Copyright (C) 2007-2008 Mark Cave-Ayland
9  * Copyright (C) 2001-2006 Refractions Research Inc.
10  *
11  * This is free software; you can redistribute and/or modify it under
12  * the terms of the GNU General Public Licence. See the COPYING file.
13  *
14  **********************************************************************/
15 
16 #ifndef _LIBLWGEOM_INTERNAL_H
17 #define _LIBLWGEOM_INTERNAL_H 1
18 
19 #include "../postgis_config.h"
20 
21 #include <assert.h>
22 #include <stdarg.h>
23 #include <stdint.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #if HAVE_IEEEFP_H
28 #include <ieeefp.h>
29 #endif
30 
31 #include "liblwgeom.h"
32 
33 
37 #define PI 3.1415926535897932384626433832795
38 
39 
43 #define FP_TOLERANCE 1e-12
44 #define FP_IS_ZERO(A) (fabs(A) <= FP_TOLERANCE)
45 #define FP_MAX(A, B) (((A) > (B)) ? (A) : (B))
46 #define FP_MIN(A, B) (((A) < (B)) ? (A) : (B))
47 #define FP_ABS(a) ((a) < (0) ? -(a) : (a))
48 #define FP_EQUALS(A, B) (fabs((A)-(B)) <= FP_TOLERANCE)
49 #define FP_NEQUALS(A, B) (fabs((A)-(B)) > FP_TOLERANCE)
50 #define FP_LT(A, B) (((A) + FP_TOLERANCE) < (B))
51 #define FP_LTEQ(A, B) (((A) - FP_TOLERANCE) <= (B))
52 #define FP_GT(A, B) (((A) - FP_TOLERANCE) > (B))
53 #define FP_GTEQ(A, B) (((A) + FP_TOLERANCE) >= (B))
54 #define FP_CONTAINS_TOP(A, X, B) (FP_LT(A, X) && FP_LTEQ(X, B))
55 #define FP_CONTAINS_BOTTOM(A, X, B) (FP_LTEQ(A, X) && FP_LT(X, B))
56 #define FP_CONTAINS_INCL(A, X, B) (FP_LTEQ(A, X) && FP_LTEQ(X, B))
57 #define FP_CONTAINS_EXCL(A, X, B) (FP_LT(A, X) && FP_LT(X, B))
58 #define FP_CONTAINS(A, X, B) FP_CONTAINS_EXCL(A, X, B)
59 
63 #ifndef MAXFLOAT
64 #define MAXFLOAT 3.402823466e+38F
65 #endif
66 
67 /* for the measure functions*/
68 #define DIST_MAX -1
69 #define DIST_MIN 1
70 
71 /*
72 * this will change to NaN when I figure out how to
73 * get NaN in a platform-independent way
74 */
75 #define NO_VALUE 0.0
76 #define NO_Z_VALUE NO_VALUE
77 #define NO_M_VALUE NO_VALUE
78 
79 
83 #define WKT_NO_TYPE 0x08 /* Internal use only */
84 #define WKT_NO_PARENS 0x10 /* Internal use only */
85 #define WKT_IS_CHILD 0x20 /* Internal use only */
86 
91 #define WKB_DOUBLE_SIZE 8 /* Internal use only */
92 #define WKB_INT_SIZE 4 /* Internal use only */
93 #define WKB_BYTE_SIZE 1 /* Internal use only */
94 
98 #define WKB_POINT_TYPE 1
99 #define WKB_LINESTRING_TYPE 2
100 #define WKB_POLYGON_TYPE 3
101 #define WKB_MULTIPOINT_TYPE 4
102 #define WKB_MULTILINESTRING_TYPE 5
103 #define WKB_MULTIPOLYGON_TYPE 6
104 #define WKB_GEOMETRYCOLLECTION_TYPE 7
105 #define WKB_CIRCULARSTRING_TYPE 8
106 #define WKB_COMPOUNDCURVE_TYPE 9
107 #define WKB_CURVEPOLYGON_TYPE 10
108 #define WKB_MULTICURVE_TYPE 11
109 #define WKB_MULTISURFACE_TYPE 12
110 #define WKB_CURVE_TYPE 13 /* from ISO draft, not sure is real */
111 #define WKB_SURFACE_TYPE 14 /* from ISO draft, not sure is real */
112 #define WKB_POLYHEDRALSURFACE_TYPE 15
113 #define WKB_TIN_TYPE 16
114 #define WKB_TRIANGLE_TYPE 17
115 
121 #define SIZE_GET(varsize) (((varsize) >> 2) & 0x3FFFFFFF)
122 #define SIZE_SET(varsize, size) (((varsize) & 0x00000003)|(((size) & 0x3FFFFFFF) << 2 ))
123 
127 #define EPSILON_SQLMM 1e-8
128 
129 /*
130  * Export functions
131  */
132 #define OUT_MAX_DOUBLE 1E15
133 #define OUT_SHOW_DIGS_DOUBLE 20
134 #define OUT_MAX_DOUBLE_PRECISION 15
135 #define OUT_MAX_DIGS_DOUBLE (OUT_SHOW_DIGS_DOUBLE + 2) /* +2 mean add dot and sign */
136 
137 
141 #define LW_INSIDE 1
142 #define LW_BOUNDARY 0
143 #define LW_OUTSIDE -1
144 
145 /*
146 * Internal prototypes
147 */
148 
149 /* Machine endianness */
150 #define XDR 0 /* big endian */
151 #define NDR 1 /* little endian */
152 extern char getMachineEndian(void);
153 
154 /* Raise an lwerror if srids do not match */
155 void error_if_srid_mismatch(int srid1, int srid2);
156 
157 
158 /*
159 * Force dims
160 */
161 LWGEOM* lwgeom_force_dims(const LWGEOM *lwgeom, int hasz, int hasm);
162 LWPOINT* lwpoint_force_dims(const LWPOINT *lwpoint, int hasz, int hasm);
163 LWLINE* lwline_force_dims(const LWLINE *lwline, int hasz, int hasm);
164 LWPOLY* lwpoly_force_dims(const LWPOLY *lwpoly, int hasz, int hasm);
165 LWCOLLECTION* lwcollection_force_dims(const LWCOLLECTION *lwcol, int hasz, int hasm);
166 POINTARRAY* ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm);
167 
168 /*
169 * Is Empty?
170 */
171 int lwpoly_is_empty(const LWPOLY *poly);
172 int lwcollection_is_empty(const LWCOLLECTION *col);
173 int lwcircstring_is_empty(const LWCIRCSTRING *circ);
174 int lwtriangle_is_empty(const LWTRIANGLE *triangle);
175 int lwline_is_empty(const LWLINE *line);
176 int lwpoint_is_empty(const LWPOINT *point);
177 
178 /*
179 * Number of vertices?
180 */
181 int lwline_count_vertices(LWLINE *line);
182 int lwpoly_count_vertices(LWPOLY *poly);
184 
185 /*
186 * Read from byte buffer
187 */
188 extern uint32_t lw_get_uint32_t(const uint8_t *loc);
189 extern int32_t lw_get_int32_t(const uint8_t *loc);
190 
191 /*
192 * DP simplification
193 */
194 
198 POINTARRAY* ptarray_simplify(POINTARRAY *inpts, double epsilon, unsigned int minpts);
199 LWLINE* lwline_simplify(const LWLINE *iline, double dist);
200 LWPOLY* lwpoly_simplify(const LWPOLY *ipoly, double dist);
201 LWCOLLECTION* lwcollection_simplify(const LWCOLLECTION *igeom, double dist);
202 
203 /*
204 * Computational geometry
205 */
206 int signum(double n);
207 
208 /*
209 * The possible ways a pair of segments can interact. Returned by lw_segment_intersects
210 */
212  SEG_ERROR = -1,
219 };
220 
221 /*
222 * Do the segments intersect? How?
223 */
224 int lw_segment_intersects(const POINT2D *p1, const POINT2D *p2, const POINT2D *q1, const POINT2D *q2);
225 
226 /*
227 * Get/Set an enumeratoed ordinate. (x,y,z,m)
228 */
229 double lwpoint_get_ordinate(const POINT4D *p, char ordinate);
230 void lwpoint_set_ordinate(POINT4D *p, char ordinate, double value);
231 
232 /*
233 * Generate an interpolated coordinate p given an interpolation value and ordinate to apply it to
234 */
235 int point_interpolate(const POINT4D *p1, const POINT4D *p2, POINT4D *p, int hasz, int hasm, char ordinate, double interpolation_value);
236 
237 
241 LWCOLLECTION *lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, double to);
242 
246 LWCOLLECTION *lwmline_clip_to_ordinate_range(const LWMLINE *mline, char ordinate, double from, double to);
247 
251 LWCOLLECTION *lwmpoint_clip_to_ordinate_range(const LWMPOINT *mpoint, char ordinate, double from, double to);
252 
256 LWCOLLECTION *lwpoint_clip_to_ordinate_range(const LWPOINT *mpoint, char ordinate, double from, double to);
257 
258 /*
259 * Geohash
260 */
261 int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds);
262 char *geohash_point(double longitude, double latitude, int precision);
263 void decode_geohash_bbox(char *geohash, double *lat, double *lon, int precision);
264 
265 /*
266 * Point comparisons
267 */
268 int p4d_same(const POINT4D *p1, const POINT4D *p2);
269 int p3d_same(const POINT3D *p1, const POINT3D *p2);
270 int p2d_same(const POINT2D *p1, const POINT2D *p2);
271 
272 /*
273 * Area calculations
274 */
275 double lwpoly_area(const LWPOLY *poly);
276 double lwcurvepoly_area(const LWCURVEPOLY *curvepoly);
277 double lwtriangle_area(const LWTRIANGLE *triangle);
278 
283 extern int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox);
284 
285 /*
286 * Length calculations
287 */
288 double lwcompound_length(const LWCOMPOUND *comp);
289 double lwcompound_length_2d(const LWCOMPOUND *comp);
290 double lwline_length(const LWLINE *line);
291 double lwline_length_2d(const LWLINE *line);
292 double lwcircstring_length(const LWCIRCSTRING *circ);
293 double lwcircstring_length_2d(const LWCIRCSTRING *circ);
294 double lwpoly_perimeter(const LWPOLY *poly);
295 double lwpoly_perimeter_2d(const LWPOLY *poly);
296 double lwcurvepoly_perimeter(const LWCURVEPOLY *poly);
297 double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly);
298 double lwtriangle_perimeter(const LWTRIANGLE *triangle);
299 double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle);
300 
301 /*
302 * Segmentization
303 */
304 LWLINE *lwcircstring_segmentize(const LWCIRCSTRING *icurve, uint32_t perQuad);
305 LWLINE *lwcompound_segmentize(const LWCOMPOUND *icompound, uint32_t perQuad);
306 LWPOLY *lwcurvepoly_segmentize(const LWCURVEPOLY *curvepoly, uint32_t perQuad);
307 
308 /*
309 * Affine
310 */
311 void ptarray_affine(POINTARRAY *pa, const AFFINE *affine);
312 
313 /*
314 * PointArray
315 */
316 int ptarray_isccw(const POINTARRAY *pa);
317 int ptarray_has_z(const POINTARRAY *pa);
318 int ptarray_has_m(const POINTARRAY *pa);
319 double ptarray_signed_area(const POINTARRAY *pa);
320 
321 /*
322 * Clone support
323 */
324 LWLINE *lwline_clone(const LWLINE *lwgeom);
325 LWPOLY *lwpoly_clone(const LWPOLY *lwgeom);
326 LWTRIANGLE *lwtriangle_clone(const LWTRIANGLE *lwgeom);
329 POINTARRAY *ptarray_clone(const POINTARRAY *ptarray);
330 GBOX *box2d_clone(const GBOX *lwgeom);
331 LWLINE *lwline_clone_deep(const LWLINE *lwgeom);
332 LWPOLY *lwpoly_clone_deep(const LWPOLY *lwgeom);
334 GBOX *gbox_clone(const GBOX *gbox);
335 
336 /*
337 * Startpoint
338 */
339 int lwpoly_startpoint(const LWPOLY* lwpoly, POINT4D* pt);
340 int ptarray_startpoint(const POINTARRAY* pa, POINT4D* pt);
341 int lwcollection_startpoint(const LWCOLLECTION* col, POINT4D* pt);
342 
343 /*
344  * Write into *ret the coordinates of the closest point on
345  * segment A-B to the reference input point R
346  */
347 void closest_point_on_segment(const POINT4D *R, const POINT4D *A, const POINT4D *B, POINT4D *ret);
348 
349 /*
350 * Repeated points
351 */
357 
358 /*
359 * Closure test
360 */
361 int lwline_is_closed(const LWLINE *line);
362 int lwpoly_is_closed(const LWPOLY *poly);
363 int lwcircstring_is_closed(const LWCIRCSTRING *curve);
364 int lwcompound_is_closed(const LWCOMPOUND *curve);
365 int lwpsurface_is_closed(const LWPSURFACE *psurface);
366 int lwtin_is_closed(const LWTIN *tin);
367 
368 
369 
370 /*
371 * What side of the line formed by p1 and p2 does q fall?
372 * Returns -1 for left and 1 for right and 0 for co-linearity
373 */
374 int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q);
375 int lw_arc_side(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q);
376 int lw_arc_calculate_gbox_cartesian_2d(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, GBOX *gbox);
377 double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result);
378 int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2);
379 int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3);
380 int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3);
381 double lw_seg_length(const POINT2D *A1, const POINT2D *A2);
382 double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3);
383 int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring);
384 int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt);
385 int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt);
386 int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number);
387 int ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number);
388 int lwcompound_contains_point(const LWCOMPOUND *comp, const POINT2D *pt);
389 int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt);
390 
401 int lwline_split_by_point_to(const LWLINE* ln, const LWPOINT* pt, LWMLINE* to);
402 
404 void lwcollection_reserve(LWCOLLECTION *col, int ngeoms);
405 
407 extern int lwcollection_allows_subtype(int collectiontype, int subtype);
408 
410 double gbox_angular_height(const GBOX* gbox);
411 double gbox_angular_width(const GBOX* gbox);
412 int gbox_centroid(const GBOX* gbox, POINT2D* out);
413 
414 /* Utilities */
415 extern void trim_trailing_zeros(char *num);
416 
417 extern uint8_t MULTITYPE[NUMTYPES];
418 
419 #endif /* _LIBLWGEOM_INTERNAL_H */
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
Definition: lwalgorithm.c:228
LWPOINT * lwpoint_force_dims(const LWPOINT *lwpoint, int hasz, int hasm)
Definition: lwpoint.c:238
int lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:484
LWPOLY * lwpoly_clone_deep(const LWPOLY *lwgeom)
Definition: lwpoly.c:135
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
Definition: lwalgorithm.c:106
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:270
GBOX * box2d_clone(const GBOX *lwgeom)
Definition: box2d.c:17
POINTARRAY * ptarray_clone(const POINTARRAY *ptarray)
Clone a POINTARRAY object.
Definition: ptarray.c:643
int ptarray_isccw(const POINTARRAY *pa)
Definition: ptarray.c:990
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:472
int lw_arc_calculate_gbox_cartesian_2d(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, GBOX *gbox)
Definition: g_box.c:388
double lw_seg_length(const POINT2D *A1, const POINT2D *A2)
Returns the length of a linear segment.
Definition: lwalgorithm.c:75
CG_SEGMENT_INTERSECTION_TYPE
LWLINE * lwline_clone(const LWLINE *lwgeom)
Definition: lwline.c:89
int lwtin_is_closed(const LWTIN *tin)
Definition: lwtin.c:80
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:317
LWCOLLECTION * lwmpoint_clip_to_ordinate_range(const LWMPOINT *mpoint, char ordinate, double from, double to)
Clip a multi-point based on the from/to range of one of its ordinates.
void trim_trailing_zeros(char *num)
Definition: lwutil.c:200
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
Definition: ptarray.c:796
double lwpoint_get_ordinate(const POINT4D *p, char ordinate)
Given a POINT4D and an ordinate number, return the value of the ordinate.
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:205
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:275
LWTRIANGLE * lwtriangle_clone(const LWTRIANGLE *lwgeom)
Definition: lwtriangle.c:86
void decode_geohash_bbox(char *geohash, double *lat, double *lon, int precision)
Definition: lwalgorithm.c:704
int gbox_centroid(const GBOX *gbox, POINT2D *out)
Computes the average(ish) center of the box and returns success.
Definition: lwgeodetic.c:244
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:503
int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
Definition: lwalgorithm.c:281
LWPOLY * lwcurvepoly_segmentize(const LWCURVEPOLY *curvepoly, uint32_t perQuad)
Definition: lwsegmentize.c:290
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:22
LWCOLLECTION * lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, double to)
Clip a line based on the from/to range of one of its ordinates.
double lwtriangle_area(const LWTRIANGLE *triangle)
Find the area of the outer ring.
Definition: lwtriangle.c:173
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
Definition: ptarray.c:959
char ** result
Definition: liblwgeom.h:218
int signum(double n)
Returns -1 if n < 0.0 and 1 if n > 0.0.
Definition: lwalgorithm.c:21
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:196
int lwtriangle_is_empty(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:162
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition: lwalgorithm.c:47
uint32_t lw_get_uint32_t(const uint8_t *loc)
Definition: lwgeom_api.c:534
int lwcompound_contains_point(const LWCOMPOUND *comp, const POINT2D *pt)
Definition: lwcompound.c:132
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:119
double lwcompound_length_2d(const LWCOMPOUND *comp)
Definition: lwcompound.c:61
int lwcollection_is_empty(const LWCOLLECTION *col)
Definition: lwcollection.c:471
LWCOLLECTION * lwpoint_clip_to_ordinate_range(const LWPOINT *mpoint, char ordinate, double from, double to)
Clip a point based on the from/to range of one of its ordinates.
LWPOLY * lwpoly_force_dims(const LWPOLY *lwpoly, int hasz, int hasm)
Definition: lwpoly.c:303
int point_interpolate(const POINT4D *p1, const POINT4D *p2, POINT4D *p, int hasz, int hasm, char ordinate, double interpolation_value)
Given two points, a dimensionality, an ordinate, and an interpolation value generate a new point that...
int lwpoly_is_closed(const LWPOLY *poly)
Definition: lwpoly.c:455
double lwcompound_length(const LWCOMPOUND *comp)
Definition: lwcompound.c:56
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:255
LWPOLY * lwpoly_simplify(const LWPOLY *ipoly, double dist)
Definition: lwpoly.c:346
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:703
LWCOLLECTION * lwmline_clip_to_ordinate_range(const LWMLINE *mline, char ordinate, double from, double to)
Clip a multi-line based on the from/to range of one of its ordinates.
LWGEOM * lwline_remove_repeated_points(LWLINE *in)
Definition: lwline.c:423
int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
Definition: lwalgorithm.c:743
LWCIRCSTRING * lwcircstring_clone(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:112
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:39
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
Definition: lwpoly.c:390
int lwpoly_is_empty(const LWPOLY *poly)
Definition: lwpoly.c:327
double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:146
POINTARRAY * ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
Definition: ptarray.c:999
void lwpoint_set_ordinate(POINT4D *p, char ordinate, double value)
Given a point, ordinate number and value, set that ordinate on the point.
#define NUMTYPES
Definition: liblwgeom.h:76
int lwpsurface_is_closed(const LWPSURFACE *psurface)
Definition: lwpsurface.c:86
LWLINE * lwcircstring_segmentize(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwsegmentize.c:191
char * geohash_point(double longitude, double latitude, int precision)
Definition: lwalgorithm.c:582
char getMachineEndian(void)
Definition: lwutil.c:306
int lwcollection_startpoint(const LWCOLLECTION *col, POINT4D *pt)
Definition: lwcollection.c:550
LWGEOM * lwgeom_force_dims(const LWGEOM *lwgeom, int hasz, int hasm)
Definition: lwgeom.c:670
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *lwgeom)
Deep clone LWCOLLECTION object.
Definition: lwcollection.c:136
int lwpoly_startpoint(const LWPOLY *lwpoly, POINT4D *pt)
Definition: lwpoly.c:480
double lwpoly_perimeter_2d(const LWPOLY *poly)
Compute the sum of polygon rings length (forcing 2d computation).
Definition: lwpoly.c:441
int lwcircstring_is_empty(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:263
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
Definition: lwpoly.c:423
LWCOLLECTION * lwcollection_force_dims(const LWCOLLECTION *lwcol, int hasz, int hasm)
Definition: lwcollection.c:448
int ptarray_startpoint(const POINTARRAY *pa, POINT4D *pt)
Definition: ptarray.c:1740
int lwline_is_empty(const LWLINE *line)
Definition: lwline.c:464
POINTARRAY * ptarray_simplify(POINTARRAY *inpts, double epsilon, unsigned int minpts)
Definition: ptarray.c:1495
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:134
LWLINE * lwline_force_dims(const LWLINE *lwline, int hasz, int hasm)
Definition: lwline.c:445
int lw_arc_side(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q)
Definition: lwalgorithm.c:179
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
Definition: lwgeom.c:264
int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
Definition: g_serialized.c:159
int ptarray_has_m(const POINTARRAY *pa)
Definition: ptarray.c:30
LWLINE * lwline_simplify(const LWLINE *iline, double dist)
Definition: lwline.c:480
double lwline_length(const LWLINE *line)
Definition: lwline.c:496
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is...
Definition: lwalgorithm.c:86
LWGEOM * lwmpoint_remove_repeated_points(LWMPOINT *in)
Definition: lwmpoint.c:79
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:435
double gbox_angular_height(const GBOX *gbox)
GBOX utility functions to figure out coverage/location on the globe.
Definition: lwgeodetic.c:165
int lwpoint_is_empty(const LWPOINT *point)
Definition: lwpoint.c:258
int p3d_same(const POINT3D *p1, const POINT3D *p2)
Definition: lwalgorithm.c:38
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
Definition: lwalgorithm.c:96
LWGEOM * lwpoly_remove_repeated_points(LWPOLY *in)
Definition: lwpoly.c:284
LWLINE * lwcompound_segmentize(const LWCOMPOUND *icompound, uint32_t perQuad)
Definition: lwsegmentize.c:243
LWCOLLECTION * lwcollection_clone(const LWCOLLECTION *lwgeom)
Clone LWCOLLECTION object.
Definition: lwcollection.c:110
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return 1 if the point is inside the POINTARRAY, -1 if it is outside, and 0 if it is on the boundary...
Definition: ptarray.c:697
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
Definition: lwcollection.c:513
int ptarray_has_z(const POINTARRAY *pa)
Definition: ptarray.c:23
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
Definition: lwalgorithm.c:62
int lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:334
void closest_point_on_segment(const POINT4D *R, const POINT4D *A, const POINT4D *B, POINT4D *ret)
Definition: ptarray.c:1219
POINTARRAY * ptarray_remove_repeated_points(POINTARRAY *in)
Definition: ptarray.c:1401
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:116
int32_t lw_get_int32_t(const uint8_t *loc)
Definition: lwgeom_api.c:544
LWPOLY * lwpoly_clone(const LWPOLY *lwgeom)
Definition: lwpoly.c:120
LWLINE * lwline_clone_deep(const LWLINE *lwgeom)
Definition: lwline.c:105
int ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:802
double lwcurvepoly_area(const LWCURVEPOLY *curvepoly)
This should be rewritten to make use of the curve itself.
Definition: lwcurvepoly.c:120
LWCOLLECTION * lwcollection_simplify(const LWCOLLECTION *igeom, double dist)
Definition: lwcollection.c:496
int p4d_same(const POINT4D *p1, const POINT4D *p2)
Definition: lwalgorithm.c:29
This library is the generic geometry handling section of PostGIS.
void ptarray_affine(POINTARRAY *pa, const AFFINE *affine)
Affine transform a pointarray.
Definition: ptarray.c:1692
void lwcollection_reserve(LWCOLLECTION *col, int ngeoms)
Ensure the collection can hold at least up to ngeoms geometries.
Definition: lwcollection.c:161
int lwline_split_by_point_to(const LWLINE *ln, const LWPOINT *pt, LWMLINE *to)
Split a line by a point and push components to the provided multiline.
double gbox_angular_width(const GBOX *gbox)
Returns the angular width (longitudinal span) of the box in radians.
Definition: lwgeodetic.c:192
LWGEOM * lwcollection_remove_repeated_points(LWCOLLECTION *in)
Definition: lwcollection.c:430
int lw_segment_intersects(const POINT2D *p1, const POINT2D *p2, const POINT2D *q1, const POINT2D *q2)
returns the kind of CG_SEGMENT_INTERSECTION_TYPE behavior of lineseg 1 (constructed from p1 and p2) a...
Definition: lwalgorithm.c:372