28 #include "utils/array.h"
29 #include "utils/builtins.h"
30 #include "utils/elog.h"
31 #include "utils/geo_decls.h"
33 #include "../postgis_config.h"
36 #include "lwgeom_pg.h"
43 #define xstr(s) str(s)
50 Datum
ST_Area(PG_FUNCTION_ARGS);
129 size_t size = VARSIZE(geom);
130 PG_FREE_IF_COPY(geom, 0);
131 PG_RETURN_INT32(size);
143 size_t result_sz = strlen(lwresult) + 8;
148 snprintf(
result, result_sz,
"0:%s", lwresult);
153 snprintf(
result, result_sz,
"%s", lwresult);
159 summary = cstring_to_text(
result);
162 PG_FREE_IF_COPY(g, 0);
163 PG_RETURN_TEXT_P(summary);
169 char *ver = POSTGIS_VERSION;
170 text *
result = cstring_to_text(ver);
178 text *
result = cstring_to_text(ver);
186 text *
result = cstring_to_text(ver);
193 static char *rev =
xstr(POSTGIS_REVISION);
195 if (rev && rev[0] !=
'\0')
197 snprintf(ver, 32,
"%s", rev);
199 PG_RETURN_TEXT_P(cstring_to_text(ver));
201 else PG_RETURN_NULL();
207 char *ver = POSTGIS_BUILD_DATE;
208 text *
result = cstring_to_text(ver);
221 result = cstring_to_text(ver);
229 text *
result = cstring_to_text(ver);
244 PG_FREE_IF_COPY(geom, 0);
245 PG_RETURN_INT32(npoints);
259 PG_FREE_IF_COPY(geom, 0);
260 PG_RETURN_INT32(nrings);
279 PG_FREE_IF_COPY(geom, 0);
281 PG_RETURN_FLOAT8(area);
298 PG_FREE_IF_COPY(geom, 0);
299 PG_RETURN_FLOAT8(dist);
316 PG_FREE_IF_COPY(geom, 0);
317 PG_RETURN_FLOAT8(dist);
332 double perimeter = 0.0;
335 PG_FREE_IF_COPY(geom, 0);
336 PG_RETURN_FLOAT8(perimeter);
351 double perimeter = 0.0;
354 PG_FREE_IF_COPY(geom, 0);
355 PG_RETURN_FLOAT8(perimeter);
362 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
368 PG_RETURN_POINTER(pg_geom_in);
372 pg_geom_out = geometry_serialize(lwg_out);
376 PG_FREE_IF_COPY(pg_geom_in, 0);
377 PG_RETURN_POINTER(pg_geom_out);
384 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
387 double z = PG_NARGS() < 2 ? 0 : PG_GETARG_FLOAT8(1);
391 PG_RETURN_POINTER(pg_geom_in);
395 pg_geom_out = geometry_serialize(lwg_out);
399 PG_FREE_IF_COPY(pg_geom_in, 0);
400 PG_RETURN_POINTER(pg_geom_out);
407 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
410 double m = PG_NARGS() < 2 ? 0 : PG_GETARG_FLOAT8(1);
414 PG_RETURN_POINTER(pg_geom_in);
418 pg_geom_out = geometry_serialize(lwg_out);
422 PG_FREE_IF_COPY(pg_geom_in, 0);
423 PG_RETURN_POINTER(pg_geom_out);
430 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
433 double z = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(1);
434 double m = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(2);
438 PG_RETURN_POINTER(pg_geom_in);
442 pg_geom_out = geometry_serialize(lwg_out);
446 PG_FREE_IF_COPY(pg_geom_in, 0);
447 PG_RETURN_POINTER(pg_geom_out);
461 POSTGIS_DEBUG(2,
"LWGEOM_force_collection called");
470 PG_RETURN_POINTER(geom);
490 lwgeoms = palloc(
sizeof(
LWGEOM *));
495 result = geometry_serialize(lwgeom);
498 PG_FREE_IF_COPY(geom, 0);
499 PG_RETURN_POINTER(
result);
511 POSTGIS_DEBUG(2,
"LWGEOM_force_multi called");
529 PG_RETURN_POINTER(geom);
539 result = geometry_serialize(ogeom);
541 PG_FREE_IF_COPY(geom, 0);
543 PG_RETURN_POINTER(
result);
555 POSTGIS_DEBUG(2,
"LWGEOM_force_curve called");
562 result = geometry_serialize(ogeom);
564 PG_FREE_IF_COPY(geom, 0);
566 PG_RETURN_POINTER(
result);
580 POSTGIS_DEBUG(2,
"LWGEOM_force_sfs called");
583 if ((PG_NARGS() > 1) && (!PG_ARGISNULL(1)))
585 ver = PG_GETARG_TEXT_P(1);
587 if (!strncmp(VARDATA(ver),
"1.2", 3))
596 result = geometry_serialize(ogeom);
598 PG_FREE_IF_COPY(geom, 0);
600 PG_RETURN_POINTER(
result);
623 result = geometry_serialize(point);
628 PG_FREE_IF_COPY(geom1, 0);
629 PG_FREE_IF_COPY(geom2, 1);
630 PG_RETURN_POINTER(
result);
652 result = geometry_serialize(theline);
657 PG_FREE_IF_COPY(geom1, 0);
658 PG_FREE_IF_COPY(geom2, 1);
659 PG_RETURN_POINTER(
result);
681 result = geometry_serialize(theline);
686 PG_FREE_IF_COPY(geom1, 0);
687 PG_FREE_IF_COPY(geom2, 1);
688 PG_RETURN_POINTER(
result);
708 PG_FREE_IF_COPY(geom1, 0);
709 PG_FREE_IF_COPY(geom2, 1);
712 if (mindist < FLT_MAX)
713 PG_RETURN_FLOAT8(mindist);
729 double tolerance = PG_GETARG_FLOAT8(2);
735 elog(ERROR,
"Tolerance cannot be less than zero\n");
743 PG_FREE_IF_COPY(geom1, 0);
744 PG_FREE_IF_COPY(geom2, 1);
747 PG_RETURN_BOOL(tolerance >= mindist);
761 double tolerance = PG_GETARG_FLOAT8(2);
767 elog(ERROR,
"Tolerance cannot be less than zero\n");
775 PG_FREE_IF_COPY(geom1, 0);
776 PG_FREE_IF_COPY(geom2, 1);
780 PG_RETURN_BOOL(tolerance >= maxdist);
800 PG_FREE_IF_COPY(geom1, 0);
801 PG_FREE_IF_COPY(geom2, 1);
805 PG_RETURN_FLOAT8(maxdist);
831 result = geometry_serialize(point);
837 PG_FREE_IF_COPY(geom1, 0);
838 PG_FREE_IF_COPY(geom2, 1);
839 PG_RETURN_POINTER(
result);
862 result = geometry_serialize(theline);
868 PG_FREE_IF_COPY(geom1, 0);
869 PG_FREE_IF_COPY(geom2, 1);
870 PG_RETURN_POINTER(
result);
893 result = geometry_serialize(theline);
899 PG_FREE_IF_COPY(geom1, 0);
900 PG_FREE_IF_COPY(geom2, 1);
901 PG_RETURN_POINTER(
result);
918 PG_FREE_IF_COPY(geom1, 0);
919 PG_FREE_IF_COPY(geom2, 1);
922 if (mindist < FLT_MAX)
923 PG_RETURN_FLOAT8(mindist);
941 PG_FREE_IF_COPY(geom1, 0);
942 PG_FREE_IF_COPY(geom2, 1);
945 PG_RETURN_BOOL(0.0 == mindist);
960 double tolerance = PG_GETARG_FLOAT8(2);
966 elog(ERROR,
"Tolerance cannot be less than zero\n");
974 PG_FREE_IF_COPY(geom1, 0);
975 PG_FREE_IF_COPY(geom2, 1);
979 PG_RETURN_BOOL(tolerance >= mindist);
993 double tolerance = PG_GETARG_FLOAT8(2);
999 elog(ERROR,
"Tolerance cannot be less than zero\n");
1006 PG_FREE_IF_COPY(geom1, 0);
1007 PG_FREE_IF_COPY(geom2, 1);
1011 PG_RETURN_BOOL(tolerance >= maxdist);
1032 PG_FREE_IF_COPY(geom1, 0);
1033 PG_FREE_IF_COPY(geom2, 1);
1037 PG_RETURN_FLOAT8(maxdist);
1049 POSTGIS_DEBUG(2,
"LWGEOM_longitude_shift called.");
1051 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
1061 ret = geometry_serialize(lwgeom);
1069 PG_RETURN_POINTER(ret);
1077 LWGEOM *lwgeom_in, *lwgeom_out;
1082 POSTGIS_DEBUG(2,
"ST_WrapX called.");
1084 gdatum = PG_GETARG_DATUM(0);
1085 cutx = PG_GETARG_FLOAT8(1);
1086 amount = PG_GETARG_FLOAT8(2);
1090 geom_in = ((
GSERIALIZED *)PG_DETOAST_DATUM(gdatum));
1094 geom_out = geometry_serialize(lwgeom_out);
1098 PG_FREE_IF_COPY(geom_in, 0);
1100 PG_RETURN_POINTER(geom_out);
1107 double cx = PG_GETARG_FLOAT8(1);
1108 double cy = PG_GETARG_FLOAT8(2);
1109 double rr = PG_GETARG_FLOAT8(3);
1114 geom = PG_GETARG_GSERIALIZED_P(0);
1119 PG_FREE_IF_COPY(geom, 0);
1126 PG_FREE_IF_COPY(geom, 0);
1127 PG_RETURN_BOOL(inside);
1141 LWGEOM *lwgeoms[2], *outlwg;
1142 uint32 type1, type2;
1146 POSTGIS_DEBUG(2,
"LWGEOM_collect called.");
1149 if (PG_ARGISNULL(0) && PG_ARGISNULL(1))
1153 if (PG_ARGISNULL(0))
1154 PG_RETURN_DATUM(PG_GETARG_DATUM(1));
1157 if (PG_ARGISNULL(1))
1158 PG_RETURN_DATUM(PG_GETARG_DATUM(0));
1160 gser1 = PG_GETARG_GSERIALIZED_P(0);
1161 gser2 = PG_GETARG_GSERIALIZED_P(1);
1165 "LWGEOM_collect(%s, %s): call",
1172 elog(ERROR,
"Cannot ST_Collect geometries with differing dimensionality.");
1181 type1 = lwgeoms[0]->
type;
1182 type2 = lwgeoms[1]->
type;
1189 POSTGIS_DEBUGF(3,
" outtype = %d", outtype);
1198 result = geometry_serialize(outlwg);
1203 PG_FREE_IF_COPY(gser1, 0);
1204 PG_FREE_IF_COPY(gser2, 1);
1206 PG_RETURN_POINTER(
result);
1225 LWGEOM **lwgeoms, *outlwg;
1231 ArrayIterator iterator;
1235 POSTGIS_DEBUG(2,
"LWGEOM_collect_garray called.");
1237 if (PG_ARGISNULL(0))
1241 array = PG_GETARG_ARRAYTYPE_P(0);
1242 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1245 " array is %d-bytes in size, %ld w/out header",
1247 ARR_SIZE(array) - ARR_OVERHEAD_NONULLS(ARR_NDIM(array)));
1249 POSTGIS_DEBUGF(3,
"LWGEOM_collect_garray: array has %d elements", nelems);
1259 lwgeoms = palloc(
sizeof(
LWGEOM *) * nelems);
1263 iterator = array_create_iterator(array, 0, NULL);
1265 while (array_iterate(iterator, &
value, &isnull))
1279 POSTGIS_DEBUGF(3,
"%s: geom %d deserialized", __func__,
count);
1287 if (lwgeoms[
count]->bbox)
1298 if (lwgeoms[
count]->bbox)
1325 array_free_iterator(iterator);
1327 POSTGIS_DEBUGF(3,
"LWGEOM_collect_garray: outtype = %d", outtype);
1338 result = geometry_serialize(outlwg);
1340 PG_RETURN_POINTER(
result);
1355 POSTGIS_DEBUG(2,
"LWGEOM_line_from_mpoint called");
1358 ingeom = PG_GETARG_GSERIALIZED_P(0);
1362 elog(ERROR,
"makeline: input must be a multipoint");
1370 PG_FREE_IF_COPY(ingeom, 0);
1371 elog(ERROR,
"makeline: lwline_from_lwmpoint returned NULL");
1377 PG_FREE_IF_COPY(ingeom, 0);
1380 PG_RETURN_POINTER(
result);
1399 ArrayIterator iterator;
1403 POSTGIS_DEBUGF(2,
"%s called", __func__);
1406 if (PG_ARGISNULL(0))
1410 array = PG_GETARG_ARRAYTYPE_P(0);
1413 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1415 POSTGIS_DEBUGF(3,
"%s: array has %d elements", __func__, nelems);
1428 geoms = palloc(
sizeof(
LWGEOM *) * nelems);
1431 iterator = array_create_iterator(array, 0, NULL);
1433 while (array_iterate(iterator, &
value, &isnull))
1454 srid = geoms[ngeoms - 1]->
srid;
1460 POSTGIS_DEBUGF(3,
"%s: element %d deserialized", __func__, ngeoms);
1462 array_free_iterator(iterator);
1468 elog(NOTICE,
"No points or linestrings in input array");
1472 POSTGIS_DEBUGF(3,
"LWGEOM_makeline_garray: elements: %d", ngeoms);
1476 result = geometry_serialize(outlwg);
1478 PG_RETURN_POINTER(
result);
1493 POSTGIS_DEBUG(2,
"LWGEOM_makeline called.");
1496 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1497 pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1502 elog(ERROR,
"Input geometries must be points or lines");
1515 PG_FREE_IF_COPY(pglwg1, 0);
1516 PG_FREE_IF_COPY(pglwg2, 1);
1520 PG_RETURN_POINTER(
result);
1531 ArrayType *array = NULL;
1533 const LWLINE *shell = NULL;
1534 const LWLINE **holes = NULL;
1540 POSTGIS_DEBUG(2,
"LWGEOM_makepoly called.");
1543 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1546 lwpgerror(
"Shell is not a line");
1553 array = PG_GETARG_ARRAYTYPE_P(1);
1554 nholes = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1556 for (i = 0; i < nholes; i++)
1558 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
1559 #pragma GCC diagnostic push
1560 #pragma GCC diagnostic ignored "-Wsign-compare"
1563 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
1564 #pragma GCC diagnostic pop
1567 offset += INTALIGN(VARSIZE(g));
1570 lwpgerror(
"Hole %d is not a line", i);
1582 PG_FREE_IF_COPY(pglwg1, 0);
1584 for (i = 0; i < nholes; i++)
1589 PG_RETURN_POINTER(
result);
1607 POSTGIS_DEBUG(2,
"LWGEOM_expand called.");
1613 PG_RETURN_POINTER(geom);
1620 PG_RETURN_POINTER(geom);
1623 if (PG_NARGS() == 2)
1626 double d = PG_GETARG_FLOAT8(1);
1631 double dx = PG_GETARG_FLOAT8(1);
1632 double dy = PG_GETARG_FLOAT8(2);
1633 double dz = PG_GETARG_FLOAT8(3);
1634 double dm = PG_GETARG_FLOAT8(4);
1656 PG_FREE_IF_COPY(geom, 0);
1658 PG_RETURN_POINTER(
result);
1665 GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
1679 PG_FREE_IF_COPY(pg_lwgeom, 0);
1686 out->low.x = gbox.
xmin;
1687 out->low.y = gbox.
ymin;
1688 out->high.x = gbox.
xmax;
1689 out->high.y = gbox.
ymax;
1690 PG_RETURN_POINTER(out);
1703 int32_t srid = lwgeom->
srid;
1712 PG_RETURN_POINTER(geom);
1718 PG_RETURN_POINTER(geom);
1788 PG_FREE_IF_COPY(geom, 0);
1790 PG_RETURN_POINTER(
result);
1811 LWGEOM *inlwgeom, *outlwgeom;
1814 POSTGIS_DEBUG(2,
"LWGEOM_segmentize2d called");
1816 ingeom = PG_GETARG_GSERIALIZED_P(0);
1817 dist = PG_GETARG_FLOAT8(1);
1824 PG_RETURN_POINTER(ingeom);
1831 elog(ERROR,
"ST_Segmentize: invalid max_distance %g (must be >= 0)", dist);
1842 PG_RETURN_POINTER(ingeom);
1849 PG_FREE_IF_COPY(ingeom, 0);
1857 outgeom = geometry_serialize(outlwgeom);
1862 PG_FREE_IF_COPY(ingeom, 0);
1864 PG_RETURN_POINTER(outgeom);
1874 POSTGIS_DEBUG(2,
"LWGEOM_reverse called");
1876 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
1881 geom = geometry_serialize(lwgeom);
1883 PG_RETURN_POINTER(geom);
1893 POSTGIS_DEBUG(2,
"LWGEOM_force_clockwise_poly called");
1895 ingeom = PG_GETARG_GSERIALIZED_P_COPY(0);
1900 outgeom = geometry_serialize(lwgeom);
1903 PG_FREE_IF_COPY(ingeom, 0);
1904 PG_RETURN_POINTER(outgeom);
1914 PG_RETURN_POINTER(out);
1922 LWGEOM *lwgeom_in, *lwgeom_out;
1924 POSTGIS_DEBUG(2,
"ST_Normalize called");
1926 in = PG_GETARG_GSERIALIZED_P_COPY(0);
1929 POSTGIS_DEBUGF(3,
"Deserialized: %s",
lwgeom_summary(lwgeom_in, 0));
1932 POSTGIS_DEBUGF(3,
"Normalized: %s",
lwgeom_summary(lwgeom_out, 0));
1934 out = geometry_serialize(lwgeom_out);
1938 PG_FREE_IF_COPY(in, 0);
1940 PG_RETURN_POINTER(out);
1953 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
1960 PG_FREE_IF_COPY(in, 0);
1961 PG_RETURN_INT16(ret);
1967 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
1974 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
1981 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
1983 PG_FREE_IF_COPY(in, 0);
1984 PG_RETURN_BOOL(
res);
1991 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
1993 PG_FREE_IF_COPY(in, 0);
1994 PG_RETURN_INT16(ret);
2012 double x1, y1, x2, y2;
2015 POSTGIS_DEBUG(2,
"ST_MakeEnvelope called");
2017 x1 = PG_GETARG_FLOAT8(0);
2018 y1 = PG_GETARG_FLOAT8(1);
2019 x2 = PG_GETARG_FLOAT8(2);
2020 y2 = PG_GETARG_FLOAT8(3);
2023 srid = PG_GETARG_INT32(4);
2031 PG_RETURN_POINTER(
result);
2041 uint32_t worldTileSize;
2042 double tileGeoSizeX, tileGeoSizeY;
2043 double boundsWidth, boundsHeight;
2044 double x1, y1, x2, y2;
2055 POSTGIS_DEBUG(2,
"ST_TileEnvelope called");
2057 zoom = PG_GETARG_INT32(0);
2058 x = PG_GETARG_INT32(1);
2059 y = PG_GETARG_INT32(2);
2061 bounds = PG_GETARG_GSERIALIZED_P(3);
2070 elog(ERROR,
"%s: Unable to compute bbox", __func__);
2075 margin = PG_NARGS() < 4 ? 0 : PG_GETARG_FLOAT8(4);
2078 elog(ERROR,
"%s: Margin must not be less than -50%%, margin=%f", __func__, margin);
2080 boundsWidth = bbox.
xmax - bbox.
xmin;
2081 boundsHeight = bbox.
ymax - bbox.
ymin;
2082 if (boundsWidth <= 0 || boundsHeight <= 0)
2083 elog(ERROR,
"%s: Geometric bounds are too small", __func__);
2085 if (zoom < 0 || zoom >= 32)
2086 elog(ERROR,
"%s: Invalid tile zoom value, %d", __func__, zoom);
2088 zoomu = (uint32_t)zoom;
2089 worldTileSize = 0x01u << (zoomu > 31 ? 31 : zoomu);
2091 if (
x < 0 || (uint32_t)
x >= worldTileSize)
2092 elog(ERROR,
"%s: Invalid tile x value, %d", __func__,
x);
2093 if (
y < 0 || (uint32_t)
y >= worldTileSize)
2094 elog(ERROR,
"%s: Invalid tile y value, %d", __func__,
y);
2096 tileGeoSizeX = boundsWidth / worldTileSize;
2097 tileGeoSizeY = boundsHeight / worldTileSize;
2104 if ((1 + margin * 2) > worldTileSize)
2111 x1 = bbox.
xmin + tileGeoSizeX * (
x - margin);
2112 x2 = bbox.
xmin + tileGeoSizeX * (
x + 1 + margin);
2115 y1 = bbox.
ymax - tileGeoSizeY * (
y + 1 + margin);
2116 y2 = bbox.
ymax - tileGeoSizeY * (
y - margin);
2119 if (y1 < bbox.
ymin) y1 = bbox.
ymin;
2120 if (y2 > bbox.
ymax) y2 = bbox.
ymax;
2126 srid, x1, y1, x2, y2))));
2133 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_HEADER(0);
2145 POSTGIS_DEBUG(2,
"LWGEOM_makepoint called");
2147 x = PG_GETARG_FLOAT8(0);
2148 y = PG_GETARG_FLOAT8(1);
2150 if (PG_NARGS() == 2)
2152 else if (PG_NARGS() == 3)
2154 z = PG_GETARG_FLOAT8(2);
2157 else if (PG_NARGS() == 4)
2159 z = PG_GETARG_FLOAT8(2);
2160 m = PG_GETARG_FLOAT8(3);
2165 elog(ERROR,
"LWGEOM_makepoint: unsupported number of args: %d", PG_NARGS());
2171 PG_RETURN_POINTER(
result);
2181 POSTGIS_DEBUG(2,
"LWGEOM_makepoint3dm called.");
2183 x = PG_GETARG_FLOAT8(0);
2184 y = PG_GETARG_FLOAT8(1);
2185 m = PG_GETARG_FLOAT8(2);
2190 PG_RETURN_POINTER(
result);
2199 uint32_t uwhere = 0;
2201 POSTGIS_DEBUGF(2,
"%s called.", __func__);
2203 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
2204 pglwg2 = PG_GETARG_GSERIALIZED_P(1);
2208 elog(ERROR,
"First argument must be a LINESTRING");
2214 elog(ERROR,
"Second argument must be a POINT");
2220 PG_RETURN_POINTER(pglwg1);
2225 if (PG_NARGS() <= 2)
2231 int32 where = PG_GETARG_INT32(2);
2238 elog(ERROR,
"%s: Invalid offset", __func__);
2253 elog(ERROR,
"Point insert failed");
2260 PG_FREE_IF_COPY(pglwg1, 0);
2261 PG_FREE_IF_COPY(pglwg2, 1);
2264 PG_RETURN_POINTER(
result);
2274 POSTGIS_DEBUG(2,
"LWGEOM_removepoint called.");
2276 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
2277 which = PG_GETARG_INT32(1);
2281 elog(ERROR,
"First argument must be a LINESTRING");
2287 if (which < 0 || (uint32_t)which > line->
points->
npoints - 1)
2289 elog(ERROR,
"Point index out of range (%u..%u)", 0, line->
points->
npoints - 1);
2295 elog(ERROR,
"Can't remove points from a single segment line");
2306 PG_FREE_IF_COPY(pglwg1, 0);
2307 PG_RETURN_POINTER(
result);
2320 POSTGIS_DEBUG(2,
"LWGEOM_setpoint_linestring called.");
2323 pglwg1 = PG_GETARG_GSERIALIZED_P_COPY(0);
2325 which = PG_GETARG_INT32(1);
2326 pglwg2 = PG_GETARG_GSERIALIZED_P(2);
2333 elog(ERROR,
"Third argument must be a POINT");
2338 PG_FREE_IF_COPY(pglwg2, 2);
2345 elog(ERROR,
"First argument must be a LINESTRING");
2350 elog(ERROR,
"Line has no points");
2361 elog(ERROR,
"abs(Point index) out of range (-)(%u..%u)", 0, line->
points->
npoints - 1);
2375 PG_RETURN_POINTER(
result);
2408 geom = PG_GETARG_GSERIALIZED_P(0);
2412 PG_FREE_IF_COPY(geom, 0);
2413 lwpgerror(
"Argument must be POINT geometries");
2416 srid = lwpoint->
srid;
2419 PG_FREE_IF_COPY(geom, 0);
2420 lwpgerror(
"Error extracting point");
2424 PG_FREE_IF_COPY(geom, 0);
2427 geom = PG_GETARG_GSERIALIZED_P(1);
2431 PG_FREE_IF_COPY(geom, 1);
2432 lwpgerror(
"Argument must be POINT geometries");
2435 if (lwpoint->
srid != srid)
2437 PG_FREE_IF_COPY(geom, 1);
2438 lwpgerror(
"Operation on mixed SRID geometries");
2443 PG_FREE_IF_COPY(geom, 1);
2444 lwpgerror(
"Error extracting point");
2448 PG_FREE_IF_COPY(geom, 1);
2451 if ((p1.
x == p2.
x) && (p1.
y == p2.
y))
2462 PG_RETURN_FLOAT8(
result);
2485 int n_args = PG_NARGS();
2488 for (i = 0; i < n_args; i++)
2490 seri_geoms[i] = PG_GETARG_GSERIALIZED_P(i);
2513 if (srids[0] != srids[i])
2525 for (j = 0; j <= i; j++)
2526 PG_FREE_IF_COPY(seri_geoms[j], j);
2529 lwpgerror(
"Empty geometry");
2534 lwpgerror(
"Argument must be POINT geometries");
2539 lwpgerror(
"Operation on mixed SRID geometries");
2544 for (i = 0; i < n_args; i++)
2550 for (j = 0; j < n_args; j++)
2551 PG_FREE_IF_COPY(seri_geoms[j], j);
2552 lwpgerror(
"Error unserializing geometry");
2561 lwpgerror(
"Error extracting point");
2589 PG_RETURN_FLOAT8(
result);
2602 GSERIALIZED *pg_geom1 = PG_GETARG_GSERIALIZED_P(0);
2603 GSERIALIZED *pg_geom2 = PG_GETARG_GSERIALIZED_P(1);
2604 double dist = PG_GETARG_FLOAT8(2);
2613 elog(ERROR,
"optimistic_overlap: first arg isn't a polygon\n");
2619 elog(ERROR,
"optimistic_overlap: 2nd arg isn't a [multi-]polygon\n");
2626 g1_bvol.
xmin = g1_bvol.
xmin - dist;
2627 g1_bvol.
ymin = g1_bvol.
ymin - dist;
2628 g1_bvol.
xmax = g1_bvol.
xmax + dist;
2629 g1_bvol.
ymax = g1_bvol.
ymax + dist;
2634 PG_RETURN_BOOL(
false);
2642 DatumGetFloat8(DirectFunctionCall2(
ST_Distance, PointerGetDatum(pg_geom1), PointerGetDatum(pg_geom2)));
2644 PG_RETURN_BOOL(calc_dist < dist);
2651 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P_COPY(0);
2656 affine.
afac = PG_GETARG_FLOAT8(1);
2657 affine.
bfac = PG_GETARG_FLOAT8(2);
2658 affine.
cfac = PG_GETARG_FLOAT8(3);
2659 affine.
dfac = PG_GETARG_FLOAT8(4);
2660 affine.
efac = PG_GETARG_FLOAT8(5);
2661 affine.
ffac = PG_GETARG_FLOAT8(6);
2662 affine.
gfac = PG_GETARG_FLOAT8(7);
2663 affine.
hfac = PG_GETARG_FLOAT8(8);
2664 affine.
ifac = PG_GETARG_FLOAT8(9);
2665 affine.
xoff = PG_GETARG_FLOAT8(10);
2666 affine.
yoff = PG_GETARG_FLOAT8(11);
2667 affine.
zoff = PG_GETARG_FLOAT8(12);
2669 POSTGIS_DEBUG(2,
"LWGEOM_affine called.");
2678 ret = geometry_serialize(lwgeom);
2682 PG_FREE_IF_COPY(geom, 0);
2684 PG_RETURN_POINTER(ret);
2695 if (PG_ARGISNULL(0))
2700 geom = PG_GETARG_GSERIALIZED_P(0);
2702 if (!PG_ARGISNULL(1))
2709 PG_RETURN_TEXT_P(geohash);
2716 if (PG_ARGISNULL(0))
2730 extype = PG_GETARG_INT32(1);
2735 elog(ERROR,
"ST_CollectionExtract: only point, linestring and polygon may be extracted");
2739 gser_in = PG_GETARG_GSERIALIZED_P(0);
2746 if (lwg_in->
type == extype || !extype)
2749 PG_RETURN_POINTER(gser_in);
2755 PG_RETURN_POINTER(geometry_serialize(lwg_out));
2761 gser_out = geometry_serialize(lwg_out);
2764 PG_RETURN_POINTER(gser_out);
2780 PG_FREE_IF_COPY(input, 0);
2784 output = geometry_serialize(lwoutput);
2787 PG_FREE_IF_COPY(input, 0);
2788 PG_RETURN_POINTER(output);
2795 GSERIALIZED *g_in = PG_GETARG_GSERIALIZED_P_COPY(0);
2798 LWGEOM *lwgeom_in = NULL;
2799 double tolerance = 0.0;
2804 PG_RETURN_POINTER(g_in);
2806 if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
2807 tolerance = PG_GETARG_FLOAT8(1);
2814 PG_RETURN_POINTER(g_in);
2817 g_out = geometry_serialize(lwgeom_in);
2820 PG_RETURN_POINTER(g_out);
2827 GSERIALIZED *in = PG_GETARG_GSERIALIZED_P_COPY(0);
2832 out = geometry_serialize(lwgeom);
2835 PG_FREE_IF_COPY(in, 0);
2837 PG_RETURN_POINTER(out);
2843 if (n ==
'x' || n ==
'X')
2845 if (n ==
'y' || n ==
'Y')
2847 if (n ==
'z' || n ==
'Z')
2849 if (n ==
'm' || n ==
'M')
2851 lwpgerror(
"Invalid ordinate name '%c'. Expected x,y,z or m", n);
2865 ospec = PG_GETARG_CSTRING(1);
2866 if (strlen(ospec) != 2)
2869 "Invalid ordinate specification. "
2870 "Need two letters from the set (x,y,z,m). "
2878 in = PG_GETARG_GSERIALIZED_P_COPY(0);
2883 lwpgerror(
"Geometry does not have an M ordinate");
2888 lwpgerror(
"Geometry does not have a Z ordinate");
2894 PG_RETURN_POINTER(in);
2898 out = geometry_serialize(lwgeom);
2900 PG_FREE_IF_COPY(in, 0);
2901 PG_RETURN_POINTER(out);
2912 bool fits = PG_GETARG_BOOL(1);
2913 LWGEOM *lwgeom_out = NULL;
2925 GSERIALIZED *geom_in = PG_GETARG_GSERIALIZED_P(0);
2930 srid = lwgeom_in->
srid;
2961 geom_out = geometry_serialize(lwgeom_out);
2964 PG_RETURN_POINTER(geom_out);
2972 GSERIALIZED *geom_scale = PG_GETARG_GSERIALIZED_P(1);
2974 LWGEOM *lwg, *lwg_scale, *lwg_origin;
2975 LWPOINT *lwpt_scale, *lwpt_origin;
2978 bool translate =
false;
2988 PG_FREE_IF_COPY(geom_scale, 1);
2989 lwpgerror(
"Scale factor geometry parameter must be a point");
2994 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
3002 PG_FREE_IF_COPY(geom_scale, 1);
3003 PG_RETURN_POINTER(geom);
3016 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3018 geom_origin = PG_GETARG_GSERIALIZED_P(2);
3028 PG_FREE_IF_COPY(geom_origin, 2);
3035 memset(&aff, 0,
sizeof(
AFFINE));
3039 aff.
xoff = -1 * origin.
x;
3040 aff.
yoff = -1 * origin.
y;
3041 aff.
zoff = -1 * origin.
z;
3057 ret = geometry_serialize(lwg);
3059 PG_FREE_IF_COPY(geom, 0);
3060 PG_FREE_IF_COPY(geom_scale, 1);
3061 PG_RETURN_POINTER(ret);
3068 if (PG_ARGISNULL(0))
3083 PG_RETURN_POINTER(ret);
3098 if (PG_ARGISNULL(0))
3100 if (PG_ARGISNULL(1))
3102 lwpgerror(
"Must specify precision");
3107 prec_x = PG_GETARG_INT32(1);
3109 prec_y = PG_ARGISNULL(2) ? prec_x : PG_GETARG_INT32(2);
3110 prec_z = PG_ARGISNULL(3) ? prec_x : PG_GETARG_INT32(3);
3111 prec_m = PG_ARGISNULL(4) ? prec_x : PG_GETARG_INT32(4);
3113 input = PG_GETARG_GSERIALIZED_P_COPY(0);
3119 result = geometry_serialize(g);
3121 PG_FREE_IF_COPY(input, 0);
3122 PG_RETURN_POINTER(
result);
3139 if (PG_NARGS() > 0 && !PG_ARGISNULL(0))
3141 geom_in = PG_GETARG_GSERIALIZED_P(0);
3148 if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
3149 min = PG_GETARG_FLOAT8(1);
3154 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3155 max = PG_GETARG_FLOAT8(2);
3160 if (PG_NARGS() > 3 && !PG_ARGISNULL(3) && PG_GETARG_BOOL(3))
3169 elog(ERROR,
"Min-value cannot be larger than Max value\n");
3179 elog(NOTICE,
"No M-value, No vertex removed\n");
3180 PG_RETURN_POINTER(geom_in);
3185 geom_out = geometry_serialize(lwgeom_out);
3187 PG_RETURN_POINTER(geom_out);
char result[OUT_DOUBLE_BUFFER_SIZE]
int gbox_merge(const GBOX *new_box, GBOX *merge_box)
Update the merged GBOX to be large enough to include itself and the new box.
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
void gbox_expand_xyzm(GBOX *g, double dx, double dy, double dz, double dm)
Move the box minimums down and the maximums up by the distances provided.
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
int gserialized_has_bbox(const GSERIALIZED *g)
Check if a GSERIALIZED has a bounding box without deserializing first.
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
int gserialized_ndims(const GSERIALIZED *g)
Return the number of dimensions (2, 3, 4) in a geometry.
uint32_t gserialized_get_version(const GSERIALIZED *g)
Return the serialization version.
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or calculate it if necessary.
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
uint64_t gserialized_get_sortable_hash(const GSERIALIZED *g)
Return a sortable key based on gserialized.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
int gserialized_cmp(const GSERIALIZED *g1, const GSERIALIZED *g2)
Return -1 if g1 is "less than" g2, 1 if g1 is "greater than" g2 and 0 if g1 and g2 are the "same".
int gserialized_datum_get_internals_p(Datum gsdatum, GBOX *gbox, lwflags_t *flags, uint8_t *type, int32_t *srid)
Peak into a GSERIALIZED datum to find its bounding box and some other metadata.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
uint32_t lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
LWPOINT * lwpoint_make4d(int32_t srid, double x, double y, double z, double m)
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing max distance calculation.
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
void lwmpoint_free(LWMPOINT *mpt)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
void lwgeom_trim_bits_in_place(LWGEOM *geom, int32_t prec_x, int32_t prec_y, int32_t prec_z, int32_t prec_m)
Trim the bits of an LWGEOM in place, to optimize it for compression.
void lwpoint_free(LWPOINT *pt)
void lwgeom_longitude_shift(LWGEOM *lwgeom)
void lwgeom_free(LWGEOM *geom)
double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d max distance calculations and dfullywithin calculations.
LWGEOM * lwgeom_filter_m(LWGEOM *geom, double min, double max, int returnm)
LWPOINT * lwpoint_make3dm(int32_t srid, double x, double y, double m)
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
double lwgeom_perimeter_2d(const LWGEOM *geom)
lwvarlena_t * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
LWGEOM * lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2)
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom, double mval)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
LWGEOM * lwgeom_force_4d(const LWGEOM *geom, double zval, double mval)
double lwgeom_length(const LWGEOM *geom)
const char * lwgeom_version(void)
Return lwgeom version string (not to be freed)
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom, double zval)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
#define FLAGS_GET_Z(flags)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
char * lwgeom_summary(const LWGEOM *lwgeom, int offset)
LWPOLY * lwpoly_construct_rectangle(char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4)
double lwgeom_area(const LWGEOM *geom)
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
LWCOLLECTION * lwcollection_extract(const LWCOLLECTION *col, uint32_t type)
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
LWPOINT * lwpoint_make3dz(int32_t srid, double x, double y, double z)
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
#define POLYHEDRALSURFACETYPE
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
double lwgeom_length_2d(const LWGEOM *geom)
uint32_t lwgeom_count_rings(const LWGEOM *geom)
Count the total number of rings in any LWGEOM.
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define FLAGS_GET_M(flags)
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
LWLINE * lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfullywithin calculations.
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
void lwpoly_free(LWPOLY *poly)
#define LW_TRUE
Return types for functions with status returns.
double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d max distance calculation.
#define SRID_UNKNOWN
Unknown SRID value.
double lwgeom_perimeter(const LWGEOM *geom)
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
LWGEOM * lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
void lwline_free(LWLINE *line)
LWLINE * lwline_from_lwgeom_array(int32_t srid, uint32_t ngeoms, LWGEOM **geoms)
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where)
Add a LWPOINT to an LWLINE.
void lwgeom_drop_srid(LWGEOM *lwgeom)
void lwgeom_reverse_in_place(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d min distance calculation.
lwvarlena_t * lwgeom_to_wkt_varlena(const LWGEOM *geom, uint8_t variant, int precision)
enum LWORD_T LWORD
Ordinate names.
This library is the generic geometry handling section of PostGIS.
#define OUT_DEFAULT_DECIMAL_DIGITS
Datum LWGEOM_FilterByM(PG_FUNCTION_ARGS)
Datum LWGEOM_isempty(PG_FUNCTION_ARGS)
Datum LWGEOM_perimeter2d_poly(PG_FUNCTION_ARGS)
Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS)
Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
Datum LWGEOM_makepoint(PG_FUNCTION_ARGS)
Datum ST_3DIntersects(PG_FUNCTION_ARGS)
Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS)
Datum LWGEOM_force_multi(PG_FUNCTION_ARGS)
Datum LWGEOM_segmentize2d(PG_FUNCTION_ARGS)
Datum LWGEOM_dfullywithin3d(PG_FUNCTION_ARGS)
Datum ST_Area(PG_FUNCTION_ARGS)
Datum ST_CollectionHomogenize(PG_FUNCTION_ARGS)
Datum LWGEOM_shortestline3d(PG_FUNCTION_ARGS)
Datum postgis_lib_revision(PG_FUNCTION_ARGS)
Datum LWGEOM_maxdistance2d_linestring(PG_FUNCTION_ARGS)
Datum LWGEOM_dfullywithin(PG_FUNCTION_ARGS)
Datum LWGEOM_removepoint(PG_FUNCTION_ARGS)
Datum LWGEOM_noop(PG_FUNCTION_ARGS)
Datum postgis_scripts_released(PG_FUNCTION_ARGS)
Datum LWGEOM_affine(PG_FUNCTION_ARGS)
Datum ST_RemoveRepeatedPoints(PG_FUNCTION_ARGS)
Datum ST_BoundingDiagonal(PG_FUNCTION_ARGS)
Datum LWGEOM_longitude_shift(PG_FUNCTION_ARGS)
Datum ST_QuantizeCoordinates(PG_FUNCTION_ARGS)
Datum postgis_version(PG_FUNCTION_ARGS)
Datum postgis_liblwgeom_version(PG_FUNCTION_ARGS)
Datum LWGEOM_force_4d(PG_FUNCTION_ARGS)
Datum LWGEOM_nrings(PG_FUNCTION_ARGS)
Datum ST_Points(PG_FUNCTION_ARGS)
Datum LWGEOM_zmflag(PG_FUNCTION_ARGS)
Datum ST_GeoHash(PG_FUNCTION_ARGS)
Datum ST_TileEnvelope(PG_FUNCTION_ARGS)
Datum ST_IsCollection(PG_FUNCTION_ARGS)
Datum ST_3DDistance(PG_FUNCTION_ARGS)
Datum LWGEOM_mem_size(PG_FUNCTION_ARGS)
Datum postgis_svn_version(PG_FUNCTION_ARGS)
Datum LWGEOM_makeline(PG_FUNCTION_ARGS)
Datum LWGEOM_ndims(PG_FUNCTION_ARGS)
Datum ST_Scale(PG_FUNCTION_ARGS)
Datum LWGEOM_force_curve(PG_FUNCTION_ARGS)
Datum LWGEOM_setpoint_linestring(PG_FUNCTION_ARGS)
Datum LWGEOM_dwithin3d(PG_FUNCTION_ARGS)
Datum _ST_SortableHash(PG_FUNCTION_ARGS)
Datum LWGEOM_shortestline2d(PG_FUNCTION_ARGS)
Datum LWGEOM_perimeter_poly(PG_FUNCTION_ARGS)
Datum LWGEOM_envelope(PG_FUNCTION_ARGS)
Datum LWGEOM_force_collection(PG_FUNCTION_ARGS)
Datum ST_MakeEnvelope(PG_FUNCTION_ARGS)
Datum LWGEOM_force_clockwise_poly(PG_FUNCTION_ARGS)
Datum LWGEOM_hasm(PG_FUNCTION_ARGS)
Datum LWGEOM_to_BOX(PG_FUNCTION_ARGS)
Datum LWGEOM_azimuth(PG_FUNCTION_ARGS)
Datum ST_Normalize(PG_FUNCTION_ARGS)
Datum optimistic_overlap(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(LWGEOM_mem_size)
find the size of geometry
Datum ST_CollectionExtract(PG_FUNCTION_ARGS)
Datum LWGEOM_asEWKT(PG_FUNCTION_ARGS)
Datum LWGEOM_angle(PG_FUNCTION_ARGS)
Datum LWGEOM_inside_circle_point(PG_FUNCTION_ARGS)
Datum postgis_lib_build_date(PG_FUNCTION_ARGS)
Datum LWGEOM_line_from_mpoint(PG_FUNCTION_ARGS)
Datum LWGEOM_collect(PG_FUNCTION_ARGS)
Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
Datum LWGEOM_hasBBOX(PG_FUNCTION_ARGS)
Datum LWGEOM_same(PG_FUNCTION_ARGS)
Datum ST_SwapOrdinates(PG_FUNCTION_ARGS)
Datum LWGEOM_reverse(PG_FUNCTION_ARGS)
Datum LWGEOM_hasz(PG_FUNCTION_ARGS)
Datum postgis_lib_version(PG_FUNCTION_ARGS)
Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
Datum LWGEOM_longestline2d(PG_FUNCTION_ARGS)
Datum LWGEOM_makeline_garray(PG_FUNCTION_ARGS)
Datum LWGEOM_force_sfs(PG_FUNCTION_ARGS)
Datum LWGEOM_length2d_linestring(PG_FUNCTION_ARGS)
Datum ST_FlipCoordinates(PG_FUNCTION_ARGS)
Datum LWGEOM_closestpoint(PG_FUNCTION_ARGS)
Datum LWGEOM_expand(PG_FUNCTION_ARGS)
Datum ST_Distance(PG_FUNCTION_ARGS)
Datum LWGEOM_longestline3d(PG_FUNCTION_ARGS)
Datum LWGEOM_length_linestring(PG_FUNCTION_ARGS)
static LWORD ordname2ordval(char n)
Datum LWGEOM_npoints(PG_FUNCTION_ARGS)
Datum ST_WrapX(PG_FUNCTION_ARGS)
Datum LWGEOM_makepoint3dm(PG_FUNCTION_ARGS)
Datum LWGEOM_dwithin(PG_FUNCTION_ARGS)
Datum LWGEOM_mindistance3d(PG_FUNCTION_ARGS)
Datum postgis_libxml_version(PG_FUNCTION_ARGS)
Datum LWGEOM_maxdistance3d(PG_FUNCTION_ARGS)
Datum LWGEOM_closestpoint3d(PG_FUNCTION_ARGS)
Datum LWGEOM_summary(PG_FUNCTION_ARGS)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
#define POSTGIS_LIB_VERSION
#define POSTGIS_LIBXML2_VERSION