PostGIS  2.5.0dev-r@@SVN_REVISION@@
liblwgeom_internal.h File Reference
#include "../postgis_config.h"
#include "lwgeom_log.h"
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include "liblwgeom.h"
Include dependency graph for liblwgeom_internal.h:

Go to the source code of this file.

Data Structures

struct  gridspec_t
 Snap to grid. More...


#define FP_TOLERANCE   1e-12
 Floating point comparators. More...
#define FP_IS_ZERO(A)   (fabs(A) <= FP_TOLERANCE)
#define FP_MAX(A, B)   (((A) > (B)) ? (A) : (B))
#define FP_MIN(A, B)   (((A) < (B)) ? (A) : (B))
#define FP_ABS(a)   ((a) < (0) ? -(a) : (a))
#define FP_EQUALS(A, B)   (fabs((A)-(B)) <= FP_TOLERANCE)
#define FP_NEQUALS(A, B)   (fabs((A)-(B)) > FP_TOLERANCE)
#define FP_LT(A, B)   (((A) + FP_TOLERANCE) < (B))
#define FP_LTEQ(A, B)   (((A) - FP_TOLERANCE) <= (B))
#define FP_GT(A, B)   (((A) - FP_TOLERANCE) > (B))
#define FP_GTEQ(A, B)   (((A) + FP_TOLERANCE) >= (B))
#define FP_CONTAINS_TOP(A, X, B)   (FP_LT(A, X) && FP_LTEQ(X, B))
#define FP_CONTAINS_BOTTOM(A, X, B)   (FP_LTEQ(A, X) && FP_LT(X, B))
#define FP_CONTAINS_INCL(A, X, B)   (FP_LTEQ(A, X) && FP_LTEQ(X, B))
#define FP_CONTAINS_EXCL(A, X, B)   (FP_LT(A, X) && FP_LT(X, B))
#define NO_VALUE   0.0
#define WKT_NO_TYPE   0x08 /* Internal use only */
 Well-Known Text (WKT) Output Variant Types. More...
#define WKT_NO_PARENS   0x10 /* Internal use only */
#define WKT_IS_CHILD   0x20 /* Internal use only */
#define WKB_DOUBLE_SIZE   8 /* Internal use only */
 Well-Known Binary (WKB) Output Variant Types. More...
#define WKB_INT_SIZE   4 /* Internal use only */
#define WKB_BYTE_SIZE   1 /* Internal use only */
#define WKB_POINT_TYPE   1
 Well-Known Binary (WKB) Geometry Types. More...
#define WKB_POLYGON_TYPE   3
#define WKB_CURVE_TYPE   13 /* from ISO draft, not sure is real */
#define WKB_SURFACE_TYPE   14 /* from ISO draft, not sure is real */
#define WKB_TIN_TYPE   16
#define WKB_TRIANGLE_TYPE   17
#define SIZE_GET(varsize)   (((varsize) >> 2) & 0x3FFFFFFF)
 Macro for reading the size from the GSERIALIZED size attribute. More...
#define SIZE_SET(varsize, size)   (((varsize) & 0x00000003)|(((size) & 0x3FFFFFFF) << 2 ))
#define SIGNUM(n)   (((n) > 0) - ((n) < 0))
 Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0. More...
#define EPSILON_SQLMM   1e-8
 Tolerance used to determine equality. More...
#define OUT_MAX_DOUBLE   1E15
#define OUT_MAX_DIGS_DOUBLE   (OUT_SHOW_DIGS_DOUBLE + 2) /* +2 mean add dot and sign */
#define LW_INSIDE   1
 Constants for point-in-polygon return values. More...
#define LW_BOUNDARY   0
#define LW_OUTSIDE   -1
#define XDR   0 /* big endian */
#define NDR   1 /* little endian */
#define LW_ON_INTERRUPT(x)


typedef struct gridspec_t gridspec
 Snap to grid. More...




char getMachineEndian (void)
LWGEOMlwgeom_force_dims (const LWGEOM *lwgeom, int hasz, int hasm)
LWPOINTlwpoint_force_dims (const LWPOINT *lwpoint, int hasz, int hasm)
LWLINElwline_force_dims (const LWLINE *lwline, int hasz, int hasm)
LWPOLYlwpoly_force_dims (const LWPOLY *lwpoly, int hasz, int hasm)
LWCOLLECTIONlwcollection_force_dims (const LWCOLLECTION *lwcol, int hasz, int hasm)
POINTARRAYptarray_force_dims (const POINTARRAY *pa, int hasz, int hasm)
void ptarray_swap_ordinates (POINTARRAY *pa, LWORD o1, LWORD o2)
 Swap ordinate values o1 and o2 on a given POINTARRAY. More...
int lwpoly_is_empty (const LWPOLY *poly)
int lwcollection_is_empty (const LWCOLLECTION *col)
int lwcircstring_is_empty (const LWCIRCSTRING *circ)
int lwtriangle_is_empty (const LWTRIANGLE *triangle)
int lwline_is_empty (const LWLINE *line)
int lwpoint_is_empty (const LWPOINT *point)
uint32_t lwline_count_vertices (LWLINE *line)
uint32_t lwpoly_count_vertices (LWPOLY *poly)
uint32_t lwcollection_count_vertices (LWCOLLECTION *col)
void ptarray_simplify_in_place (POINTARRAY *pa, double epsilon, uint32_t minpts)
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) and lineseg 2 (constructed from q1 and q2) More...
double lwpoint_get_ordinate (const POINT4D *p, char ordinate)
 Given a POINT4D and an ordinate number, return the value of the ordinate. More...
void lwpoint_set_ordinate (POINT4D *p, char ordinate, double value)
 Given a point, ordinate number and value, set that ordinate on the point. More...
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 is proportionally between the input points, using the values in the provided dimension as the scaling factors. More...
LWCOLLECTIONlwline_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. More...
LWCOLLECTIONlwmline_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. More...
LWCOLLECTIONlwmpoint_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. More...
LWCOLLECTIONlwpoint_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. More...
int lwgeom_geohash_precision (GBOX bbox, GBOX *bounds)
char * geohash_point (double longitude, double latitude, int precision)
void decode_geohash_bbox (char *geohash, double *lat, double *lon, int precision)
int p4d_same (const POINT4D *p1, const POINT4D *p2)
int p3d_same (const POINT3D *p1, const POINT3D *p2)
int p2d_same (const POINT2D *p1, const POINT2D *p2)
double lwpoly_area (const LWPOLY *poly)
 Find the area of the outer ring - sum (area of inner rings). More...
double lwcurvepoly_area (const LWCURVEPOLY *curvepoly)
 This should be rewritten to make use of the curve itself. More...
double lwtriangle_area (const LWTRIANGLE *triangle)
 Find the area of the outer ring. More...
int gserialized_read_gbox_p (const GSERIALIZED *g, GBOX *gbox)
 Pull a GBOX from the header of a GSERIALIZED, if one is available. More...
double lwcompound_length (const LWCOMPOUND *comp)
double lwcompound_length_2d (const LWCOMPOUND *comp)
double lwline_length (const LWLINE *line)
double lwline_length_2d (const LWLINE *line)
double lwcircstring_length (const LWCIRCSTRING *circ)
double lwcircstring_length_2d (const LWCIRCSTRING *circ)
double lwpoly_perimeter (const LWPOLY *poly)
 Compute the sum of polygon rings length. More...
double lwpoly_perimeter_2d (const LWPOLY *poly)
 Compute the sum of polygon rings length (forcing 2d computation). More...
double lwcurvepoly_perimeter (const LWCURVEPOLY *poly)
double lwcurvepoly_perimeter_2d (const LWCURVEPOLY *poly)
double lwtriangle_perimeter (const LWTRIANGLE *triangle)
double lwtriangle_perimeter_2d (const LWTRIANGLE *triangle)
LWLINElwcompound_stroke (const LWCOMPOUND *icompound, uint32_t perQuad)
LWPOLYlwcurvepoly_stroke (const LWCURVEPOLY *curvepoly, uint32_t perQuad)
void ptarray_affine (POINTARRAY *pa, const AFFINE *affine)
 Affine transform a pointarray. More...
void ptarray_scale (POINTARRAY *pa, const POINT4D *factor)
 Scale a pointarray. More...
int ptarray_has_z (const POINTARRAY *pa)
int ptarray_has_m (const POINTARRAY *pa)
double ptarray_signed_area (const POINTARRAY *pa)
 Returns the area in cartesian units. More...
double ptarray_length (const POINTARRAY *pts)
 Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality) More...
double ptarray_arc_length_2d (const POINTARRAY *pts)
 Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate triple. More...
LWPOINTlwpoint_clone (const LWPOINT *lwgeom)
LWLINElwline_clone (const LWLINE *lwgeom)
LWPOLYlwpoly_clone (const LWPOLY *lwgeom)
LWTRIANGLElwtriangle_clone (const LWTRIANGLE *lwgeom)
LWCOLLECTIONlwcollection_clone (const LWCOLLECTION *lwgeom)
 Clone LWCOLLECTION object. More...
LWCIRCSTRINGlwcircstring_clone (const LWCIRCSTRING *curve)
POINTARRAYptarray_clone (const POINTARRAY *ptarray)
 Clone a POINTARRAY object. More...
LWLINElwline_clone_deep (const LWLINE *lwgeom)
LWPOLYlwpoly_clone_deep (const LWPOLY *lwgeom)
LWCOLLECTIONlwcollection_clone_deep (const LWCOLLECTION *lwgeom)
 Deep clone LWCOLLECTION object. More...
GBOXgbox_clone (const GBOX *gbox)
void lwpoly_force_clockwise (LWPOLY *poly)
void lwtriangle_force_clockwise (LWTRIANGLE *triangle)
int lwpoly_is_clockwise (LWPOLY *poly)
int lwtriangle_is_clockwise (LWTRIANGLE *triangle)
int ptarray_isccw (const POINTARRAY *pa)
char ptarray_same (const POINTARRAY *pa1, const POINTARRAY *pa2)
char lwpoint_same (const LWPOINT *p1, const LWPOINT *p2)
char lwline_same (const LWLINE *p1, const LWLINE *p2)
char lwpoly_same (const LWPOLY *p1, const LWPOLY *p2)
char lwtriangle_same (const LWTRIANGLE *p1, const LWTRIANGLE *p2)
char lwcollection_same (const LWCOLLECTION *p1, const LWCOLLECTION *p2)
 check for same geometry composition More...
char lwcircstring_same (const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
int point4d_transform (POINT4D *pt, projPJ srcpj, projPJ dstpj)
void ptarray_longitude_shift (POINTARRAY *pa)
 Longitude shift for a pointarray. More...
void ptarray_copy_point (POINTARRAY *pa, uint32_t from, uint32_t to)
void ptarray_reverse_in_place (POINTARRAY *pa)
int lwpoly_startpoint (const LWPOLY *lwpoly, POINT4D *pt)
int ptarray_startpoint (const POINTARRAY *pa, POINT4D *pt)
int lwcollection_startpoint (const LWCOLLECTION *col, POINT4D *pt)
void closest_point_on_segment (const POINT4D *R, const POINT4D *A, const POINT4D *B, POINT4D *ret)
POINTARRAYptarray_remove_repeated_points (const POINTARRAY *in, double tolerance)
LWGEOMlwline_remove_repeated_points (const LWLINE *in, double tolerance)
void ptarray_remove_repeated_points_in_place (POINTARRAY *pa, double tolerance, uint32_t min_points)
int lwline_is_closed (const LWLINE *line)
int lwpoly_is_closed (const LWPOLY *poly)
int lwcircstring_is_closed (const LWCIRCSTRING *curve)
int lwcompound_is_closed (const LWCOMPOUND *curve)
int lwpsurface_is_closed (const LWPSURFACE *psurface)
int lwtin_is_closed (const LWTIN *tin)
LWGEOMlwgeom_grid (const LWGEOM *lwgeom, const gridspec *grid)
void lwgeom_grid_in_place (LWGEOM *lwgeom, const gridspec *grid)
void ptarray_grid_in_place (POINTARRAY *pa, const gridspec *grid)
int lw_segment_side (const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
 lw_segment_side() More...
int lw_arc_side (const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q)
int lw_arc_calculate_gbox_cartesian_2d (const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, GBOX *gbox)
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. More...
int lw_pt_in_seg (const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
 Returns true if P is between A1/A2. More...
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. More...
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) . More...
double lw_seg_length (const POINT2D *A1, const POINT2D *A2)
 Returns the length of a linear segment. More...
double lw_arc_length (const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
 Returns the length of a circular arc segment. More...
int pt_in_ring_2d (const POINT2D *p, const POINTARRAY *ring)
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. More...
int ptarrayarc_contains_point (const POINTARRAY *pa, const POINT2D *pt)
 For POINTARRAYs representing CIRCULARSTRINGS. More...
int ptarray_contains_point_partial (const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
int ptarrayarc_contains_point_partial (const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
int lwcompound_contains_point (const LWCOMPOUND *comp, const POINT2D *pt)
int lwgeom_contains_point (const LWGEOM *geom, const POINT2D *pt)
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. More...
void lwcollection_reserve (LWCOLLECTION *col, uint32_t ngeoms)
 Ensure the collection can hold at least up to ngeoms geometries. More...
int lwcollection_allows_subtype (int collectiontype, int subtype)
 Check if subtype is allowed in collectiontype. More...
double gbox_angular_height (const GBOX *gbox)
 GBOX utility functions to figure out coverage/location on the globe. More...
double gbox_angular_width (const GBOX *gbox)
 Returns the angular width (longitudinal span) of the box in radians. More...
int gbox_centroid (const GBOX *gbox, POINT2D *out)
 Computes the average(ish) center of the box and returns success. More...
int lwprint_double (double d, int maxdd, char *buf, size_t bufsize)
int ptarray_npoints_in_rect (const POINTARRAY *pa, const GBOX *gbox)
int gbox_contains_point2d (const GBOX *g, const POINT2D *p)
int lwpoly_contains_point (const LWPOLY *poly, const POINT2D *pt)


 Look-up for the correct MULTI* type promotion for singleton types. More...
int _lwgeom_interrupt_requested