34#ifndef __TGEO_SPATIALFUNCS_H__
35#define __TGEO_SPATIALFUNCS_H__
43#include "temporal/temporal.h"
46#define TGEOMP_TO_TGEOGP true
47#define TGEOGP_TO_TGEOMP false
50#define TGEOM_TO_TGEOG true
51#define TGEOG_TO_TGEOM false
54#define TGEO_TO_TPOINT true
55#define TPOINT_TO_TGEO false
170 bool geodetic, int32_t srid);
189 double ratio,
bool hasz,
bool geodetic);
199 int npoints,
int nlines);
Temporal * tpoint_get_coord(const Temporal *temp, int coord)
Return one of the coordinates of a temporal point as a temporal float.
Definition: tpoint_spatialfuncs.c:164
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:55
Datum(* datum_func2)(Datum, Datum)
Definition: temporal.h:296
interpType
Enumeration that defines the interpolation types used in MEOS.
Definition: meos.h:161
External API of the Mobility Engine Open Source (MEOS) library.
int64 TimestampTz
Definition: postgres_ext_defs.in.h:22
signed short int16
Definition: postgres_ext_defs.in.h:10
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
long int int64
Definition: postgres_ext_defs.in.h:12
Definition: postgis_ext_defs.in.h:170
Definition: postgis_ext_defs.in.h:184
Definition: postgis_ext_defs.in.h:208
Definition: postgis_ext_defs.in.h:116
Definition: postgis_ext_defs.in.h:122
Definition: postgis_ext_defs.in.h:140
Definition: postgis_ext_defs.in.h:101
Structure to represent spatiotemporal boxes.
Definition: meos.h:134
Structure to represent temporal values of sequence subtype.
Definition: meos.h:202
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:173
long double closest_point_on_segment_sphere(const POINT4D *p, const POINT4D *A, const POINT4D *B, POINT4D *closest, double *dist)
Return a float between 0 and 1 representing the location of the closest point on the geography segmen...
Definition: tpoint_spatialfuncs.c:334
bool ensure_valid_tgeo_stbox(const Temporal *temp, const STBox *box)
Ensure the validity of a temporal geo and a spatiotemporal box.
Definition: tgeo_spatialfuncs.c:908
bool same_dimensionality_tspatial_geo(const Temporal *temp, const GSERIALIZED *gs)
Return true if a spatiotemporal value and a geometry/geography have thesame dimensionality.
Definition: tgeo_spatialfuncs.c:651
LWGEOM * lwcoll_from_points_lines(LWGEOM **points, LWGEOM **lines, int npoints, int nlines)
Return a geometry from an array of points and lines.
Definition: tpoint_spatialfuncs.c:748
Datum datum2_point_nsame(Datum point1, Datum point2)
Datum datum2_point_eq(Datum point1, Datum point2)
Return true if the points are equal.
Definition: tgeo_spatialfuncs.c:242
bool ensure_srid_is_latlong(int32_t srid)
Ensure that an SRID is geodetic.
Definition: tspatial_srid.c:373
bool ensure_has_M_geo(const GSERIALIZED *gs)
Ensure that the geometry/geography has M dimension.
Definition: tgeo_spatialfuncs.c:738
bool ensure_point_type(const GSERIALIZED *gs)
Ensure that the geometry/geography is a point.
Definition: tgeo_spatialfuncs.c:777
bool ensure_valid_tpoint_tpoint(const Temporal *temp1, const Temporal *temp2)
Ensure the validity of two temporal points.
Definition: tpoint_spatialfuncs.c:111
bool ensure_srid_known(int32_t srid)
Ensure that the SRID is known.
Definition: tgeo_spatialfuncs.c:566
Datum datum_pt_distance2d(Datum geom1, Datum geom2)
Return the 2D distance between the two geometry points.
Definition: tgeo_spatialfuncs.c:360
bool ensure_spatial_validity(const Temporal *temp1, const Temporal *temp2)
Ensure that the spatial constraints required for operating on two temporal geometries are satisfied.
Definition: tgeo_spatialfuncs.c:473
bool ensure_has_not_Z_geo(const GSERIALIZED *gs)
Ensure that the geometry/geography has not Z dimension.
Definition: tgeo_spatialfuncs.c:725
bool ensure_same_geodetic_tspatial_base(const Temporal *temp, Datum base)
Ensure that the spatiotemporal argument and the geometry/geography have the same type of coordinates,...
Definition: tgeo_spatialfuncs.c:547
bool ensure_same_srid(int32_t srid1, int32_t srid2)
Ensure that the two spatial objects have the same SRID.
Definition: tgeo_spatialfuncs.c:579
GSERIALIZED ** geo_extract_elements(const GSERIALIZED *gs, int *count)
datum_func2 pt_distance_fn(int16 flags)
Select the appropriate distance function.
Definition: tgeo_spatialfuncs.c:316
bool ensure_same_geodetic_geo(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Ensure that two geometries/geographies have the same dimensionality.
Definition: tgeo_spatialfuncs.c:516
int tgeompointsegm_intersection(Datum start1, Datum end1, Datum start2, Datum end2, TimestampTz lower, TimestampTz upper, TimestampTz *t1, TimestampTz *t2)
Return 1 or 2 if two temporal geometry point segments intersect during the period defined by the outp...
Definition: tpoint_spatialfuncs.c:559
bool ensure_valid_geo_geo(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Ensure the validity of two temporal points.
Definition: tpoint_spatialfuncs.c:83
Datum datum2_point_ne(Datum point1, Datum point2)
Datum datum_pt_distance3d(Datum geom1, Datum geom2)
Return the 3D distance between the two geometry points.
Definition: tgeo_spatialfuncs.c:371
int spheroid_init_from_srid(int32_t srid, SPHEROID *s)
Return 1 if the spheroid in the last argument was initialized from an SRID, return 0 otherwise.
Definition: tspatial_transform_meos.c:652
bool same_spatial_dimensionality(int16 flags1, int16 flags2)
Return true if the two temporal points have the same spatial dimensionality as given by their flags.
Definition: tgeo_spatialfuncs.c:609
LWGEOM * lwpointarr_make_trajectory(LWGEOM **points, int count, interpType interp)
Return a trajectory from a set of points.
Definition: tpoint_spatialfuncs.c:702
int geopoint_cmp(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Return -1, 0, or 1 depending on whether the first point is less than, equal to, or greater than the s...
Definition: tgeo_spatialfuncs.c:125
bool datum_point_eq(Datum point1, Datum point2)
Return true if the points are equal.
Definition: tgeo_spatialfuncs.c:183
bool ensure_has_not_M_geo(const GSERIALIZED *gs)
Ensure that the geometry/geography has not M dimension.
Definition: tgeo_spatialfuncs.c:751
long double closest_point2d_on_segment_ratio(const POINT2D *p, const POINT2D *A, const POINT2D *B, POINT2D *closest)
Return a long double between 0 and 1 representing the location of the closest point on the 2D segment...
Definition: tpoint_spatialfuncs.c:237
bool ensure_mline_type(const GSERIALIZED *gs)
Ensure that the geometry/geography is a (multi)line.
Definition: tgeo_spatialfuncs.c:802
bool ensure_same_geodetic_tspatial_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure that the spatiotemporal argument and the geometry/geography have the same type of coordinates,...
Definition: tgeo_spatialfuncs.c:530
bool ensure_not_geodetic(int16 flags)
Ensure that the spatiotemporal argument has planar coordinates.
Definition: tgeo_spatialfuncs.c:486
bool ensure_valid_tpoint_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure the validity of two temporal points.
Definition: tpoint_spatialfuncs.c:98
int eacomp_tgeo_geo(const Temporal *temp, const GSERIALIZED *gs, Datum(*func)(Datum, Datum, meosType), bool ever)
Return true if a temporal geo and a geo satisfy the ever/always comparison.
Definition: tgeo_compops.c:60
bool ensure_valid_tgeo_tgeo(const Temporal *temp1, const Temporal *temp2)
Ensure the validity of two temporal geos.
Definition: tgeo_spatialfuncs.c:922
LWGEOM ** lwpointarr_remove_duplicates(LWGEOM **points, int count, int *newcount)
Remove duplicates from an array of LWGEOM points.
Definition: tpoint_spatialfuncs.c:677
long double pointsegm_locate(Datum start, Datum end, Datum point, double *dist)
Return a float in (0,1) representing the location of the closest point on the line segment to the giv...
Definition: tpoint_spatialfuncs.c:478
GSERIALIZED * geocircle_make(double x, double y, double radius, int32_t srid)
Return a circle created from a central point and a radius.
Definition: tcbuffer_spatialfuncs.c:123
void datum_point4d(Datum value, POINT4D *p)
Return a 4D point from a datum.
Definition: tgeo_spatialfuncs.c:82
Datum datum2_geom_centroid(Datum geo)
Return the centroid of a geometry.
Definition: tgeo_spatialfuncs.c:280
bool circle_type(const GSERIALIZED *gs)
Return true if the geometry/geography is a circle.
Definition: tcbuffer_spatialfuncs.c:54
bool ensure_valid_stbox_geo(const STBox *box, const GSERIALIZED *gs)
Ensure the validity of a spatiotemporal box and a geometry.
Definition: tgeo_spatialfuncs.c:830
void interpolate_point4d_spheroid(const POINT4D *p1, const POINT4D *p2, POINT4D *p, const SPHEROID *s, double f)
Find the interpolation point p between geography points p1 and p2 so that len(p1,p) == len(p1,...
Definition: tpoint_spatialfuncs.c:382
GSERIALIZED * geo_serialize(const LWGEOM *geom)
Serialize a geometry/geography.
Definition: postgis_funcs.c:1987
int16 spatial_flags(Datum d, meosType basetype)
Get the MEOS flags from a spatial value.
Definition: tgeo_spatialfuncs.c:437
bool mline_type(const GSERIALIZED *gs)
Ensure that the geometry/geography is a (multi)line.
Definition: tgeo_spatialfuncs.c:790
bool ensure_has_Z_geo(const GSERIALIZED *gs)
Ensure that the geometry/geography has not Z dimension.
Definition: tgeo_spatialfuncs.c:712
bool ensure_same_geodetic_stbox_geo(const STBox *box, const GSERIALIZED *gs)
Ensure that a spatiotemporal box and a geometry/geography have both planar or geodetic coordinates.
Definition: tgeo_spatialfuncs.c:696
int tpointseq_stops_iter(const TSequence *seq, double maxdist, int64 mintunits, TSequence **result)
Return the subsequences where the temporal value stays within an area with a given maximum size for a...
Definition: tpoint_spatialfuncs.c:3370
Datum datum2_geog_centroid(Datum geo)
Return the centroid of a geography.
Definition: tgeo_spatialfuncs.c:289
bool ensure_not_geodetic_geo(const GSERIALIZED *gs)
Ensure that the geometry has planar coordinates.
Definition: tgeo_spatialfuncs.c:764
int tgeogpointsegm_intersection(Datum start1, Datum end1, Datum start2, Datum end2, TimestampTz lower, TimestampTz upper, TimestampTz *t1, TimestampTz *t2)
Return 1 or 2 if two temporal geography point segments intersect during the period defined by the out...
Definition: tpoint_spatialfuncs.c:575
LWLINE * lwline_make(Datum value1, Datum value2)
Return the line connecting two geometry points.
Definition: tpoint_spatialfuncs.c:723
GSERIALIZED * geopoint_make(double x, double y, double z, bool hasz, bool geodetic, int32_t srid)
Return a point created from the arguments.
Definition: tgeo_spatialfuncs.c:106
Datum pointsegm_interpolate(Datum start, Datum end, long double ratio)
Return a point interpolated from the geometry/geography segment with respect to the fraction of its t...
Definition: tpoint_spatialfuncs.c:436
bool ensure_same_spatial_dimensionality(int16 flags1, int16 flags2)
Ensure that two temporal points have the same spatial dimensionality as given by their flags.
Definition: tgeo_spatialfuncs.c:622
bool ensure_valid_tgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure the validity of a temporal geo and a spatiotemporal box.
Definition: tgeo_spatialfuncs.c:875
bool ensure_valid_tspatial_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure the validity of a spatiotemporal value and a geometry/geography.
Definition: tgeo_spatialfuncs.c:847
bool ensure_same_spatial_dimensionality_stbox_geo(const STBox *box, const GSERIALIZED *gs)
Ensure that a spatiotemporal box and a geometry/geography have the same spatial dimensionality.
Definition: tgeo_spatialfuncs.c:678
LWGEOM * lwcircle_make(double x, double y, double radius, int32_t srid)
Return a circle created from a central point and a radius.
Definition: tcbuffer_spatialfuncs.c:101
Datum datum_geom_distance2d(Datum geom1, Datum geom2)
Return the 2D distance between the two geometries.
Definition: tgeo_spatialfuncs.c:330
bool ensure_same_geodetic(int16 flags1, int16 flags2)
Ensure that the spatiotemporal argument have the same type of coordinates, either planar or geodetic.
Definition: tgeo_spatialfuncs.c:500
bool ensure_not_empty(const GSERIALIZED *gs)
Ensure that the geometry/geography is not empty.
Definition: tgeo_spatialfuncs.c:815
bool ensure_same_dimensionality_geo(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Ensure that two geometries/geographies have the same dimensionality.
Definition: tgeo_spatialfuncs.c:636
bool ensure_same_dimensionality_tspatial_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure that a spatiotemporal value and a geometry/geography have the same dimensionality.
Definition: tgeo_spatialfuncs.c:663
bool ensure_valid_tspatial_tspatial(const Temporal *temp1, const Temporal *temp2)
Ensure that two temporal numbers have the same span type.
Definition: tgeo_spatialfuncs.c:937
datum_func2 geo_distance_fn(int16 flags)
Select the appropriate distance function.
Definition: tgeo_spatialfuncs.c:303
bool geopoint_collinear(Datum value1, Datum value2, Datum value3, double ratio, bool hasz, bool geodetic)
Return true if the three values are collinear.
Definition: tpoint_spatialfuncs.c:596
bool ensure_same_dimensionality(int16 flags1, int16 flags2)
Ensure that two temporal points have the same dimensionality as given by their flags.
Definition: tgeo_spatialfuncs.c:593
bool geopoint_same(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Return true if the points are equal taking into account floating point imprecision.
Definition: tgeo_spatialfuncs.c:201
Datum datum_geog_distance(Datum geog1, Datum geog2)
Return the distance between the two geographies.
Definition: tgeo_spatialfuncs.c:350
bool ensure_valid_tspatial_base(const Temporal *temp, Datum base)
Ensure the validity of a spatiotemporal value and a geometry/geography.
Definition: tgeo_spatialfuncs.c:892
long double closest_point3dz_on_segment_ratio(const POINT3DZ *p, const POINT3DZ *A, const POINT3DZ *B, POINT3DZ *closest)
Return a long double between 0 and 1 representing the location of the closest point on the 3D segment...
Definition: tpoint_spatialfuncs.c:292
bool geopoint_eq(const GSERIALIZED *gs1, const GSERIALIZED *gs2)
Return true if the points are equal.
Definition: tgeo_spatialfuncs.c:159
bool ensure_valid_spatial_stbox_stbox(const STBox *box1, const STBox *box2)
Ensure the validity of a spatiotemporal boxes.
Definition: tgeo_spatialfuncs.c:860
bool ensure_circle_type(const GSERIALIZED *gs)
Ensure that the geometry/geography is a circle.
Definition: tcbuffer_spatialfuncs.c:78
bool datum_point_same(Datum point1, Datum point2)
Return true if the points are equal taking into account floating point imprecision.
Definition: tgeo_spatialfuncs.c:227
Datum datum_geom_distance3d(Datum geom1, Datum geom2)
Return the 3D distance between the two geometries.
Definition: tgeo_spatialfuncs.c:340
Datum datum2_point_same(Datum point1, Datum point2)
int const GSERIALIZED * gs
Definition: trgeo_spatialrels.h:52
int const GSERIALIZED bool ever
Definition: trgeo_spatialrels.h:53