MobilityDB 1.3
Loading...
Searching...
No Matches
Macros | Functions | Variables
postgis_funcs.c File Reference

Functions for geometry/geography types corresponding to external PostGIS functions in order to bypass the function manager in fmgr.c. More...

#include "geo/postgis_funcs.h"
#include <assert.h>
#include <float.h>
#include <geos_c.h>
#include <liblwgeom.h>
#include <lwgeom_log.h>
#include <lwgeom_geos.h>
#include <meos.h>
#include <meos_internal.h>
#include "temporal/type_util.h"
#include "geo/meos_transform.h"
#include "geo/tgeo.h"
#include "geo/tgeo_spatialfuncs.h"

Macros

#define PG_PARSER_ERROR(lwg_parser_result)
 
#define PGIS_FP_TOLERANCE   1e-12
 

Functions

LWGEOMbox2d_to_lwgeom (GBOX *box, int32_t srid)
 Create a geometry from a BOX2D. More...
 
LWGEOMbox3d_to_lwgeom (BOX3D *box)
 Create a geometry from a BOX3D. More...
 
LWPOINTcart_to_lwpoint (const double_t x_sum, const double_t y_sum, const double_t z_sum, const double_t weight_sum, const int32_t srid)
 
uint8_t * geo_as_ewkb (const GSERIALIZED *gs, const char *endian, size_t *size)
 Return the Extended Well-Known Binary (EWKB) representation of a geometry/geography. More...
 
char * geo_as_ewkt (const GSERIALIZED *gs, int precision)
 Return the Extended Well-Known Text (EWKT) representation of a geometry/geography. More...
 
char * geo_as_geojson (const GSERIALIZED *gs, int option, int precision, const char *srs)
 Return the GeoJSON representation of a geometry/geography. More...
 
char * geo_as_hexewkb (const GSERIALIZED *gs, const char *endian)
 Return the ASCII hex-encoded Well-Known Binary (HexWKB) representation of a geometry/geography. More...
 
char * geo_as_text (const GSERIALIZED *gs, int precision)
 Return the Well-Known Text (WKT) representation of a geometry/geography. More...
 
char * geo_as_wkt (const GSERIALIZED *gs, int precision, bool extended)
 Return the (Extended) Well-Known Text (EWKT or WKT) representation of a geometry/geography. More...
 
GSERIALIZEDgeo_collect_garray (GSERIALIZED **gsarr, int nelems)
 Collect the array of geometries/geographies into a geo collection. More...
 
GSERIALIZEDgeo_copy (const GSERIALIZED *gs)
 Return a copy of a geometry. More...
 
int geo_equals (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the geometries/geographies are equal, false otherwise. More...
 
GSERIALIZEDgeo_from_ewkb (const uint8_t *wkb, size_t wkb_size, int32 srid)
 Return a geometry/geography from its EWKB representation. More...
 
GSERIALIZEDgeo_from_geojson (const char *geojson)
 Return a geometry/geography from its GeoJSON representation. More...
 
GSERIALIZEDgeo_from_text (const char *wkt, int32_t srid)
 Return a geometry/geography from its WKT representation (and optionally a SRID) More...
 
bool geo_is_empty (const GSERIALIZED *gs)
 Get the SRID of a geometry/geography. More...
 
GSERIALIZEDgeo_makeline_garray (GSERIALIZED **gsarr, int count)
 Return a line from an array of geometries/geographies. More...
 
int geo_npoints (const GSERIALIZED *gs)
 Return the number of points of a geometry. More...
 
char * geo_out (const GSERIALIZED *gs)
 Return the ASCII hex-encoded Well-Known Binary (HexWKB) representation of a geometry/geography. More...
 
GSERIALIZEDgeo_reverse (const GSERIALIZED *gs)
 Reverse vertex order of a geometry. More...
 
bool geo_same (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the geometries/geographies are the same. More...
 
GSERIALIZEDgeo_serialize (const LWGEOM *geom)
 Serialize a geometry/geography. More...
 
GSERIALIZEDgeo_set_srid (const GSERIALIZED *gs, int32_t srid)
 Set the SRID of a geometry/geography. More...
 
int32_t geo_srid (const GSERIALIZED *gs)
 Get the SRID of a geometry/geography. More...
 
GSERIALIZEDgeo_transform (GSERIALIZED *gs, int32_t srid_to)
 Returns the geometry/geography transformed to an SRID. More...
 
GSERIALIZEDgeo_transform_pipeline (const GSERIALIZED *gs, char *pipeline, int32_t srid_to, bool is_forward)
 Return a geometry/geography transformed to another SRID using a pipeline. More...
 
const char * geo_typename (int type)
 Return a string representation of a geometry's type. More...
 
double geog_area (const GSERIALIZED *gs, bool use_spheroid)
 Returns the area of a geography in square meters. More...
 
GSERIALIZEDgeog_centroid (const GSERIALIZED *g, bool use_spheroid)
 Return the centroid of a geometry. More...
 
double geog_distance (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the distance between two geographies. More...
 
bool geog_dwithin (const GSERIALIZED *gs1, const GSERIALIZED *gs2, double tolerance, bool use_spheroid)
 Return true if two geographies are within a distance. More...
 
GSERIALIZEDgeog_from_binary (const char *wkb_bytea)
 Return a geography from its binary representation. More...
 
GSERIALIZEDgeog_from_hexewkb (const char *wkt)
 Return a geography from its ASCII hex-encoded Well-Known Binary (HexEWKB) representation. More...
 
GSERIALIZEDgeog_from_lwgeom (LWGEOM *lwgeom, int32 typmod)
 Return a geography from a LWGEOM. More...
 
GSERIALIZEDgeog_in (const char *str, int32 typmod)
 Return a geography from its Well-Known Text or Binary (WKT or Binary) representation. More...
 
bool geog_intersects (const GSERIALIZED *gs1, const GSERIALIZED *gs2, bool use_spheroid)
 Return true if the geographies intersect. More...
 
double geog_length (const GSERIALIZED *gs, bool use_spheroid)
 Return double length in meters. More...
 
double geog_perimeter (const GSERIALIZED *gs, bool use_spheroid)
 Returns the perimeter of a geography in meters. More...
 
GSERIALIZEDgeog_serialize (LWGEOM *lwgeom)
 Utility method to call the serialization and then set the PgSQL varsize header appropriately with the serialized size. More...
 
GSERIALIZEDgeog_to_geom (const GSERIALIZED *gs)
 Return a geometry from a geography. More...
 
GSERIALIZEDgeogpoint_make2d (int32_t srid, double x, double y)
 Return a 2D geography point constructed from the arguments. More...
 
GSERIALIZEDgeogpoint_make3dz (int32_t srid, double x, double y, double z)
 Return a 3DZ geography point constructed from the arguments. More...
 
LWPOINTgeography_centroid_from_mline (const LWMLINE *mline, SPHEROID *s)
 Split lines into segments and calculate with middle of segment as weighted point. More...
 
LWPOINTgeography_centroid_from_mpoly (const LWMPOLY *mpoly, bool use_spheroid, SPHEROID *s)
 Split polygons into triangles and use centroid of the triangle with the triangle area as weight to calculate the centroid of a (multi)polygon. More...
 
LWPOINTgeography_centroid_from_wpoints (const int32_t srid, const POINT3DM *points, const uint32_t size)
 Convert lat-lon-points to x-y-z-coordinates, calculate a weighted average point and return lat-lon-coordinated. More...
 
void geography_valid_type (uint8_t type)
 Ensure that the geography type is valid The geography type only support POINT, LINESTRING, POLYGON, MULTI* variants of same, and GEOMETRYCOLLECTION. More...
 
GSERIALIZEDgeom_array_union (GSERIALIZED **gsarr, int count)
 Return the union of an array of geometries. More...
 
bool geom_azimuth (const GSERIALIZED *gs1, const GSERIALIZED *gs2, double *result)
 Return in the last argument the azimuth of a segment defined by two points. More...
 
GSERIALIZEDgeom_boundary (const GSERIALIZED *gs)
 Return the boundary of a geometry. More...
 
GSERIALIZEDgeom_buffer (const GSERIALIZED *gs, double size, char *params)
 Return a POLYGON or a MULTIPOLYGON that represents all points whose distance from a geometry/geography is less than or equal to a given distance. More...
 
GSERIALIZEDgeom_centroid (const GSERIALIZED *gs)
 Return the centroid of a geometry. More...
 
bool geom_contains (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the first geometry contains the second one. More...
 
GSERIALIZEDgeom_convex_hull (const GSERIALIZED *gs)
 Return the convex hull of the geometry. More...
 
bool geom_covers (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the first geometry covers the second one. More...
 
GSERIALIZEDgeom_difference2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the difference of two geometries. More...
 
bool geom_disjoint2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if two geometries are disjoint in 2D. More...
 
double geom_distance2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the distance between two geometries. More...
 
double geom_distance3d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the 3D distance between two geometries. More...
 
bool geom_dwithin2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2, double tolerance)
 Return true if two geometries are within a distance. More...
 
bool geom_dwithin3d (const GSERIALIZED *gs1, const GSERIALIZED *gs2, double tolerance)
 Return true if two geometries are within a distance. More...
 
GSERIALIZEDgeom_from_hexewkb (const char *wkt)
 Return a geometry from its ASCII hex-encoded Well-Known Binary (HexEWKB) representation. More...
 
GSERIALIZEDgeom_in (const char *str, int32 typmod)
 Return a geometry from its Well-Known Text (WKT), Well-Known Binary (WKB) or GeoJSON representation. More...
 
GSERIALIZEDgeom_intersection2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the intersection of two geometries. More...
 
bool geom_intersects2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if two geometries intersects. More...
 
bool geom_intersects3d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the 3D geometries intersect. More...
 
double geom_length (const GSERIALIZED *gs)
 Return the length of a geometry. More...
 
double geom_perimeter (const GSERIALIZED *gs)
 Return the perimeter of a geometry. More...
 
bool geom_relate_pattern (const GSERIALIZED *gs1, const GSERIALIZED *gs2, char *p)
 Return true if two geometries satisfy a spatial relationship given by a pattern. More...
 
GSERIALIZEDgeom_serialize (LWGEOM *lwgeom)
 Utility method to call the serialization and then set the PgSQL varsize header appropriately with the serialized size. More...
 
GSERIALIZEDgeom_shortestline2d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the shortest 2D line between two geometries. More...
 
GSERIALIZEDgeom_shortestline3d (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return the shortest line between two 3D geometries. More...
 
bool geom_spatialrel (const GSERIALIZED *gs1, const GSERIALIZED *gs2, spatialRel rel)
 Return true if two geometries satisfy a given spatial relationship, where the function called depend on the third argument. More...
 
GSERIALIZEDgeom_to_geog (const GSERIALIZED *gs)
 Return a geography from a geometry. More...
 
bool geom_touches (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Return true if the two geometries intersect on a border. More...
 
GSERIALIZEDgeom_unary_union (GSERIALIZED *gs, double prec)
 Return the unary union of a geometry. More...
 
GSERIALIZEDgeompoint_make2d (int32_t srid, double x, double y)
 Return a 2D geometry point constructed from the arguments. More...
 
GSERIALIZEDgeompoint_make3dz (int32_t srid, double x, double y, double z)
 Return a 3DZ geometry point constructed from the arguments. More...
 
GSERIALIZEDGEOS2POSTGIS (GEOSGeom geom, char want3d)
 Tranform a GEOS geometry to a PostGIS one. More...
 
static char gserialized_is_point (const GSERIALIZED *gs)
 Return true if a geometry is a point. More...
 
static char gserialized_is_poly (const GSERIALIZED *gs)
 Return true if a geometry is a polygon. More...
 
GSERIALIZEDline_interpolate_point (GSERIALIZED *gs, double fraction, bool repeat)
 Interpolate one or several points from a line. More...
 
double line_locate_point (const GSERIALIZED *gs1, const GSERIALIZED *gs2)
 Locate a point into a line. More...
 
int line_numpoints (const GSERIALIZED *gs)
 Return the number of points of a line. More...
 
GSERIALIZEDline_point_n (const GSERIALIZED *gs, int n)
 Return the n-th point of a line. More...
 
GSERIALIZEDline_substring (const GSERIALIZED *gs, double from, double to)
 Return a subline from a line. More...
 
POINT3Dlonlat_to_cart (const double_t raw_lon, const double_t raw_lat)
 
LWGEOMlwgeom_line_interpolate_point (LWGEOM *lwgeom, double fraction, int32_t srid, char repeat)
 Interpolate a point from a line. More...
 
static char meos_call_geos2 (const GSERIALIZED *gs1, const GSERIALIZED *gs2, char(*func)(const GEOSGeometry *geos1, const GEOSGeometry *geos2))
 Transform two GSERIALIZED geometries into GEOSGeometry and call the GEOS function passed as argument. More...
 
static int meos_point_in_polygon (const GSERIALIZED *gs1, const GSERIALIZED *gs2, bool inter)
 Return -1, 0, or 1 depending on whether a (multi)point is completely outside, on the boundary, or completely inside a (multi)polygon. More...
 
int point_in_multipolygon (LWMPOLY *mpolygon, LWPOINT *point)
 
int point_in_polygon (LWPOLY *polygon, LWPOINT *point)
 
GEOSGeometry * POSTGIS2GEOS (const GSERIALIZED *gs)
 Tranform a PostGIS geometry to a GEOS one. More...
 
GSERIALIZEDpostgis_valid_typmod (GSERIALIZED *gs, int32_t typmod)
 Check the consistency of the metadata to enforce in the typmod: SRID, type, and dimensionality. More...
 
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. More...
 

Variables

static const char * _GEO_TYPENAME []
 Global constant array containing the geometry type strings. More...
 

Detailed Description

Functions for geometry/geography types corresponding to external PostGIS functions in order to bypass the function manager in fmgr.c.