39 #include <liblwgeom.h> 40 #if POSTGIS_VERSION_NUMBER >= 30000 41 #include <lwgeodetic_tree.h> 48 #if POSTGIS_VERSION_NUMBER < 30000 55 #define deg2rad(d) (M_PI * (d) / 180.0) 56 #define rad2deg(r) (180.0 * (r) / M_PI) 89 const POINT3D *B1,
const POINT3D *B2);
97 #define POSTGIS_FREE_IF_COPY_P(ptrsrc, ptrori) \ 99 if ((Pointer) (ptrsrc) != (Pointer) (ptrori)) \ 141 #define DOT(u,v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z) 142 #define VECTORLENGTH(v) sqrt(((v).x * (v).x) + ((v).y * (v).y) + ((v).z * (v).z)) 156 #define PIR_NO_INTERACT 0x00 157 #define PIR_INTERSECTS 0x01 158 #define PIR_COLINEAR 0x02 159 #define PIR_A_TOUCH_RIGHT 0x04 160 #define PIR_A_TOUCH_LEFT 0x08 161 #define PIR_B_TOUCH_RIGHT 0x10 162 #define PIR_B_TOUCH_LEFT 0x20 191 #define FP_TOLERANCE 1e-12 192 #define FP_IS_ZERO(A) (fabs(A) <= FP_TOLERANCE) 193 #define FP_MAX(A, B) (((A) > (B)) ? (A) : (B)) 194 #define FP_MIN(A, B) (((A) < (B)) ? (A) : (B)) 195 #define FP_ABS(a) ((a) < (0) ? -(a) : (a)) 196 #define FP_EQUALS(A, B) (fabs((A)-(B)) <= FP_TOLERANCE) 197 #define FP_NEQUALS(A, B) (fabs((A)-(B)) > FP_TOLERANCE) 198 #define FP_LT(A, B) (((A) + FP_TOLERANCE) < (B)) 199 #define FP_LTEQ(A, B) (((A) - FP_TOLERANCE) <= (B)) 200 #define FP_GT(A, B) (((A) - FP_TOLERANCE) > (B)) 201 #define FP_GTEQ(A, B) (((A) + FP_TOLERANCE) >= (B)) 202 #define FP_CONTAINS_TOP(A, X, B) (FP_LT(A, X) && FP_LTEQ(X, B)) 203 #define FP_CONTAINS_BOTTOM(A, X, B) (FP_LTEQ(A, X) && FP_LT(X, B)) 204 #define FP_CONTAINS_INCL(A, X, B) (FP_LTEQ(A, X) && FP_LTEQ(X, B)) 205 #define FP_CONTAINS_EXCL(A, X, B) (FP_LT(A, X) && FP_LT(X, B)) 206 #define FP_CONTAINS(A, X, B) FP_CONTAINS_EXCL(A, X, B) 224 extern int p4d_same(
const POINT4D *
p1,
const POINT4D *
p2);
225 extern int p3d_same(
const POINT3D *
p1,
const POINT3D *
p2);
226 extern int p2d_same(
const POINT2D *
p1,
const POINT2D *
p2);
232 extern int getSRIDbySRS(FunctionCallInfo fcinfo,
const char *srs);
234 extern char *
getSRSbySRID(FunctionCallInfo fcinfo, int32_t srid,
bool short_crs);
236 extern int lwprint_double(
double d,
int maxdd,
char *buf,
size_t bufsize);
246 #if POSTGIS_VERSION_NUMBER >= 30000 247 int32_t
getSRIDbySRS(FunctionCallInfo fcinfo,
const char *srs);
248 char *
getSRSbySRID(FunctionCallInfo fcinfo, int32_t srid,
bool short_crs);
253 extern Datum
transform(PG_FUNCTION_ARGS);
254 extern Datum
buffer(PG_FUNCTION_ARGS);
255 extern Datum
centroid(PG_FUNCTION_ARGS);
260 extern Datum
boundary(PG_FUNCTION_ARGS);
261 extern Datum
contains(PG_FUNCTION_ARGS);
263 extern Datum
covers(PG_FUNCTION_ARGS);
264 extern Datum
coveredby(PG_FUNCTION_ARGS);
265 extern Datum
crosses(PG_FUNCTION_ARGS);
266 extern Datum
disjoint(PG_FUNCTION_ARGS);
267 extern Datum
issimple(PG_FUNCTION_ARGS);
268 extern Datum
overlaps(PG_FUNCTION_ARGS);
272 extern Datum
touches(PG_FUNCTION_ARGS);
273 extern Datum
within(PG_FUNCTION_ARGS);
275 extern Datum
ST_Equals(PG_FUNCTION_ARGS);
276 #if POSTGIS_VERSION_NUMBER < 30000 277 extern Datum
distance(PG_FUNCTION_ARGS);
283 extern Datum ST_Distance(PG_FUNCTION_ARGS);
284 extern Datum ST_3DDistance(PG_FUNCTION_ARGS);
285 extern Datum ST_Intersection(PG_FUNCTION_ARGS);
286 extern Datum ST_Intersects(PG_FUNCTION_ARGS);
287 extern Datum ST_3DIntersects(PG_FUNCTION_ARGS);
317 extern Datum
lwgeom_eq(PG_FUNCTION_ARGS);
318 extern Datum
lwgeom_lt(PG_FUNCTION_ARGS);
331 #define PG_GETARG_GSERIALIZED_P(varno) ((GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(varno))) 332 #define PG_GETARG_GSERIALIZED_P_COPY(varno) ((GSERIALIZED *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(varno))) 335 #include <liblwgeom.h> double d
Definition: postgis.h:177
Datum buffer(PG_FUNCTION_ARGS)
Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
Datum centroid(PG_FUNCTION_ARGS)
Definition: postgis.h:169
double distance
Definition: postgis.h:127
Datum overlaps(PG_FUNCTION_ARGS)
Datum intersects3d(PG_FUNCTION_ARGS)
double lon
Definition: postgis.h:63
Definition: postgis.h:135
Two-point great circle segment from a to b.
Definition: postgis.h:70
double ipx
Definition: postgis.h:213
int lw_dist3d_pt_seg(POINT3DZ *p, POINT3DZ *A, POINT3DZ *B, DISTPTS3D *dl)
GEOGRAPHIC_POINT center
Definition: postgis.h:171
uint32_t num_nodes
Definition: postgis.h:173
uint32_t geom_type
Definition: postgis.h:176
double z
Definition: postgis.h:137
POINT3DZ p2
Definition: postgis.h:129
Datum intersects(PG_FUNCTION_ARGS)
POINT2D * p2
Definition: postgis.h:180
int mode
Definition: postgis.h:113
Datum transform(PG_FUNCTION_ARGS)
Datum LWGEOM_set_srid(PG_FUNCTION_ARGS)
double lat
Definition: postgis.h:64
POINT2D * p1
Definition: postgis.h:179
Datum ST_Equals(PG_FUNCTION_ARGS)
Datum LWGEOM_numgeometries_collection(PG_FUNCTION_ARGS)
void normalize(POINT3D *p)
uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Datum LWGEOM_shortestline3d(PG_FUNCTION_ARGS)
char * getSRSbySRID(FunctionCallInfo fcinfo, int32_t srid, bool short_crs)
Datum lwgeom_lt(PG_FUNCTION_ARGS)
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
int edge_num
Definition: postgis.h:175
Datum BOX3D_to_LWGEOM(PG_FUNCTION_ARGS)
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Datum covers(PG_FUNCTION_ARGS)
double ipy
Definition: postgis.h:214
Datum LWGEOM_makepoint(PG_FUNCTION_ARGS)
Point in spherical coordinates on the world.
Definition: postgis.h:61
Definition: postgis.h:125
Datum containsproperly(PG_FUNCTION_ARGS)
Datum crosses(PG_FUNCTION_ARGS)
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
int lw_dist2d_recursive(const LWGEOM *lw1, const LWGEOM *lw2, DISTPTS *dl)
int lw_dist3d_pt_pt(POINT3DZ *p1, POINT3DZ *p2, DISTPTS3D *dl)
POINT3DZ p1
Definition: postgis.h:128
Datum distance(PG_FUNCTION_ARGS)
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Basic functions for temporal types of any subtype.
Datum LWGEOM_closestpoint(PG_FUNCTION_ARGS)
POINT2D p1
Definition: postgis.h:111
Datum LWGEOM_line_interpolate_point(PG_FUNCTION_ARGS)
Datum LWGEOM_azimuth(PG_FUNCTION_ARGS)
double zsize
Definition: postgis.h:219
double tolerance
Definition: postgis.h:115
int lwline_is_empty(const LWLINE *line)
Datum touches(PG_FUNCTION_ARGS)
Datum geography_dwithin(PG_FUNCTION_ARGS)
Datum LWGEOM_dwithin3d(PG_FUNCTION_ARGS)
Datum LWGEOM_get_srid(PG_FUNCTION_ARGS)
Datum issimple(PG_FUNCTION_ARGS)
int lw_dist2d_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
Datum lwgeom_eq(PG_FUNCTION_ARGS)
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
void circ_tree_free(CIRC_NODE *node)
Datum disjoint(PG_FUNCTION_ARGS)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
GEOGRAPHIC_POINT start
Definition: postgis.h:72
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
Datum intersection(PG_FUNCTION_ARGS)
Datum within(PG_FUNCTION_ARGS)
int twisted
Definition: postgis.h:131
Datum geometry_from_geography(PG_FUNCTION_ARGS)
struct circ_node CIRC_NODE
Datum geography_bestsrid(PG_FUNCTION_ARGS)
Datum contains(PG_FUNCTION_ARGS)
int p3d_same(const POINT3D *p1, const POINT3D *p2)
POINT2D p2
Definition: postgis.h:112
int lw_dist3d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS3D *dl)
int mode
Definition: postgis.h:130
int p4d_same(const POINT4D *p1, const POINT4D *p2)
GEOGRAPHIC_POINT end
Definition: postgis.h:73
Datum geography_eq(PG_FUNCTION_ARGS)
Datum LWGEOM_isempty(PG_FUNCTION_ARGS)
Datum geography_lt(PG_FUNCTION_ARGS)
Datum LWGEOM_line_locate_point(PG_FUNCTION_ARGS)
Datum LWGEOM_reverse(PG_FUNCTION_ARGS)
int edge_contains_coplanar_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
Datum boundary(PG_FUNCTION_ARGS)
Datum LWGEOM_pointn_linestring(PG_FUNCTION_ARGS)
int twisted
Definition: postgis.h:114
Datum geography_distance(PG_FUNCTION_ARGS)
int lw_dist3d_seg_seg(POINT3DZ *s1p1, POINT3DZ *s1p2, POINT3DZ *s2p1, POINT3DZ *s2p2, DISTPTS3D *dl)
Datum LWGEOM_line_substring(PG_FUNCTION_ARGS)
CIRC_NODE * lwgeom_calculate_circ_tree(const LWGEOM *lwgeom)
double msize
Definition: postgis.h:220
int edge_intersection(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *g)
int getSRIDbySRS(FunctionCallInfo fcinfo, const char *srs)
Datum relate_pattern(PG_FUNCTION_ARGS)
Datum LWGEOM_geometryn_collection(PG_FUNCTION_ARGS)
double tolerance
Definition: postgis.h:132
Datum BOX2D_to_LWGEOM(PG_FUNCTION_ARGS)
double ysize
Definition: postgis.h:218
double distance
Definition: postgis.h:110
Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
int geographic_point_equals(const GEOGRAPHIC_POINT *g1, const GEOGRAPHIC_POINT *g2)
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Datum lwgeom_hash(PG_FUNCTION_ARGS)
POINT2D pt_outside
Definition: postgis.h:178
Datum LWGEOM_shortestline2d(PG_FUNCTION_ARGS)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Datum LWGEOM_closestpoint3d(PG_FUNCTION_ARGS)
void srid_is_latlong(FunctionCallInfo fcinfo, int srid)
Datum LWGEOM_setpoint_linestring(PG_FUNCTION_ARGS)
Datum geography_azimuth(PG_FUNCTION_ARGS)
double edge_distance_to_edge(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
double radius
Definition: postgis.h:172
Datum LWGEOM_numpoints_linestring(PG_FUNCTION_ARGS)
Datum geography_length(PG_FUNCTION_ARGS)
struct gridspec_t gridspec
Snap-to-grid Support.
Datum LWGEOM_dwithin(PG_FUNCTION_ARGS)
Datum distance3d(PG_FUNCTION_ARGS)
Datum coveredby(PG_FUNCTION_ARGS)
Definition: postgis.h:108
double xsize
Definition: postgis.h:217
Datum geography_from_geometry(PG_FUNCTION_ARGS)
Datum geography_covers(PG_FUNCTION_ARGS)
Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
Datum LWGEOM_length_linestring(PG_FUNCTION_ARGS)
char getMachineEndian(void)
double ptarray_length_spheroid(const POINTARRAY *pa, const SPHEROID *s)
double ipm
Definition: postgis.h:216
struct circ_node ** nodes
Definition: postgis.h:174
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Datum relate_full(PG_FUNCTION_ARGS)
int spheroid_init_from_srid(FunctionCallInfo fcinfo, int srid, SPHEROID *s)
double ipz
Definition: postgis.h:215
Snap-to-grid Support.
Definition: postgis.h:211