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);
134 size_t size = VARSIZE(geom);
135 PG_FREE_IF_COPY(geom, 0);
136 PG_RETURN_INT32(size);
148 size_t result_sz = strlen(lwresult) + 8;
153 snprintf(
result, result_sz,
"0:%s", lwresult);
158 snprintf(
result, result_sz,
"%s", lwresult);
164 summary = cstring_to_text(
result);
167 PG_FREE_IF_COPY(g, 0);
168 PG_RETURN_TEXT_P(summary);
174 char *ver = POSTGIS_VERSION;
175 text *
result = cstring_to_text(ver);
183 text *
result = cstring_to_text(ver);
191 text *
result = cstring_to_text(ver);
198 static char *rev =
xstr(POSTGIS_REVISION);
200 if (rev && rev[0] !=
'\0')
202 snprintf(ver, 32,
"%s", rev);
204 PG_RETURN_TEXT_P(cstring_to_text(ver));
206 else PG_RETURN_NULL();
212 char *ver = POSTGIS_BUILD_DATE;
213 text *
result = cstring_to_text(ver);
226 result = cstring_to_text(ver);
234 text *
result = cstring_to_text(ver);
249 PG_FREE_IF_COPY(geom, 0);
250 PG_RETURN_INT32(npoints);
264 PG_FREE_IF_COPY(geom, 0);
265 PG_RETURN_INT32(nrings);
284 PG_FREE_IF_COPY(geom, 0);
286 PG_RETURN_FLOAT8(area);
303 PG_FREE_IF_COPY(geom, 0);
304 PG_RETURN_FLOAT8(dist);
321 PG_FREE_IF_COPY(geom, 0);
322 PG_RETURN_FLOAT8(dist);
337 double perimeter = 0.0;
340 PG_FREE_IF_COPY(geom, 0);
341 PG_RETURN_FLOAT8(perimeter);
356 double perimeter = 0.0;
359 PG_FREE_IF_COPY(geom, 0);
360 PG_RETURN_FLOAT8(perimeter);
367 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
373 PG_RETURN_POINTER(pg_geom_in);
377 pg_geom_out = geometry_serialize(lwg_out);
381 PG_FREE_IF_COPY(pg_geom_in, 0);
382 PG_RETURN_POINTER(pg_geom_out);
389 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
392 double z = PG_NARGS() < 2 ? 0 : PG_GETARG_FLOAT8(1);
396 PG_RETURN_POINTER(pg_geom_in);
400 pg_geom_out = geometry_serialize(lwg_out);
404 PG_FREE_IF_COPY(pg_geom_in, 0);
405 PG_RETURN_POINTER(pg_geom_out);
412 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
415 double m = PG_NARGS() < 2 ? 0 : PG_GETARG_FLOAT8(1);
419 PG_RETURN_POINTER(pg_geom_in);
423 pg_geom_out = geometry_serialize(lwg_out);
427 PG_FREE_IF_COPY(pg_geom_in, 0);
428 PG_RETURN_POINTER(pg_geom_out);
435 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
438 double z = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(1);
439 double m = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(2);
443 PG_RETURN_POINTER(pg_geom_in);
447 pg_geom_out = geometry_serialize(lwg_out);
451 PG_FREE_IF_COPY(pg_geom_in, 0);
452 PG_RETURN_POINTER(pg_geom_out);
466 POSTGIS_DEBUG(2,
"LWGEOM_force_collection called");
475 PG_RETURN_POINTER(geom);
495 lwgeoms = palloc(
sizeof(
LWGEOM *));
500 result = geometry_serialize(lwgeom);
503 PG_FREE_IF_COPY(geom, 0);
504 PG_RETURN_POINTER(
result);
516 POSTGIS_DEBUG(2,
"LWGEOM_force_multi called");
534 PG_RETURN_POINTER(geom);
544 result = geometry_serialize(ogeom);
546 PG_FREE_IF_COPY(geom, 0);
548 PG_RETURN_POINTER(
result);
560 POSTGIS_DEBUG(2,
"LWGEOM_force_curve called");
567 result = geometry_serialize(ogeom);
569 PG_FREE_IF_COPY(geom, 0);
571 PG_RETURN_POINTER(
result);
585 POSTGIS_DEBUG(2,
"LWGEOM_force_sfs called");
588 if ((PG_NARGS() > 1) && (!PG_ARGISNULL(1)))
590 ver = PG_GETARG_TEXT_P(1);
592 if (!strncmp(VARDATA(ver),
"1.2", 3))
601 result = geometry_serialize(ogeom);
603 PG_FREE_IF_COPY(geom, 0);
605 PG_RETURN_POINTER(
result);
628 result = geometry_serialize(point);
633 PG_FREE_IF_COPY(geom1, 0);
634 PG_FREE_IF_COPY(geom2, 1);
635 PG_RETURN_POINTER(
result);
657 result = geometry_serialize(theline);
662 PG_FREE_IF_COPY(geom1, 0);
663 PG_FREE_IF_COPY(geom2, 1);
664 PG_RETURN_POINTER(
result);
686 result = geometry_serialize(theline);
691 PG_FREE_IF_COPY(geom1, 0);
692 PG_FREE_IF_COPY(geom2, 1);
693 PG_RETURN_POINTER(
result);
713 PG_FREE_IF_COPY(geom1, 0);
714 PG_FREE_IF_COPY(geom2, 1);
717 if (mindist < FLT_MAX)
718 PG_RETURN_FLOAT8(mindist);
734 double tolerance = PG_GETARG_FLOAT8(2);
740 elog(ERROR,
"Tolerance cannot be less than zero\n");
748 PG_RETURN_BOOL(
false);
753 PG_FREE_IF_COPY(geom1, 0);
754 PG_FREE_IF_COPY(geom2, 1);
757 PG_RETURN_BOOL(tolerance >= mindist);
771 double tolerance = PG_GETARG_FLOAT8(2);
777 elog(ERROR,
"Tolerance cannot be less than zero\n");
785 PG_FREE_IF_COPY(geom1, 0);
786 PG_FREE_IF_COPY(geom2, 1);
790 PG_RETURN_BOOL(tolerance >= maxdist);
810 PG_FREE_IF_COPY(geom1, 0);
811 PG_FREE_IF_COPY(geom2, 1);
815 PG_RETURN_FLOAT8(maxdist);
841 result = geometry_serialize(point);
847 PG_FREE_IF_COPY(geom1, 0);
848 PG_FREE_IF_COPY(geom2, 1);
849 PG_RETURN_POINTER(
result);
872 result = geometry_serialize(theline);
878 PG_FREE_IF_COPY(geom1, 0);
879 PG_FREE_IF_COPY(geom2, 1);
880 PG_RETURN_POINTER(
result);
903 result = geometry_serialize(theline);
909 PG_FREE_IF_COPY(geom1, 0);
910 PG_FREE_IF_COPY(geom2, 1);
911 PG_RETURN_POINTER(
result);
928 PG_FREE_IF_COPY(geom1, 0);
929 PG_FREE_IF_COPY(geom2, 1);
932 if (mindist < FLT_MAX)
933 PG_RETURN_FLOAT8(mindist);
951 PG_FREE_IF_COPY(geom1, 0);
952 PG_FREE_IF_COPY(geom2, 1);
955 PG_RETURN_BOOL(0.0 == mindist);
970 double tolerance = PG_GETARG_FLOAT8(2);
976 elog(ERROR,
"Tolerance cannot be less than zero\n");
984 PG_FREE_IF_COPY(geom1, 0);
985 PG_FREE_IF_COPY(geom2, 1);
989 PG_RETURN_BOOL(tolerance >= mindist);
1003 double tolerance = PG_GETARG_FLOAT8(2);
1009 elog(ERROR,
"Tolerance cannot be less than zero\n");
1016 PG_FREE_IF_COPY(geom1, 0);
1017 PG_FREE_IF_COPY(geom2, 1);
1021 PG_RETURN_BOOL(tolerance >= maxdist);
1042 PG_FREE_IF_COPY(geom1, 0);
1043 PG_FREE_IF_COPY(geom2, 1);
1047 PG_RETURN_FLOAT8(maxdist);
1059 POSTGIS_DEBUG(2,
"LWGEOM_longitude_shift called.");
1061 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
1071 ret = geometry_serialize(lwgeom);
1079 PG_RETURN_POINTER(ret);
1087 LWGEOM *lwgeom_in, *lwgeom_out;
1092 POSTGIS_DEBUG(2,
"ST_WrapX called.");
1094 gdatum = PG_GETARG_DATUM(0);
1095 cutx = PG_GETARG_FLOAT8(1);
1096 amount = PG_GETARG_FLOAT8(2);
1100 geom_in = ((
GSERIALIZED *)PG_DETOAST_DATUM(gdatum));
1104 geom_out = geometry_serialize(lwgeom_out);
1108 PG_FREE_IF_COPY(geom_in, 0);
1110 PG_RETURN_POINTER(geom_out);
1116 Datum datum_line, datum_point;
1118 LWGEOM *lwgeom_line, *lwgeom_point;
1125 POSTGIS_DEBUG(2,
"ST_Scroll called.");
1127 datum_line = PG_GETARG_DATUM(0);
1128 datum_point = PG_GETARG_DATUM(1);
1130 ser_line = ((
GSERIALIZED *)PG_DETOAST_DATUM(datum_line));
1134 lwpgerror(
"First argument must be a line");
1138 ser_point = ((
GSERIALIZED *)PG_DETOAST_DATUM(datum_point));
1142 lwpgerror(
"Second argument must be a point");
1146 lwpgerror(
"Second argument must be a non-empty point");
1155 ser_out = geometry_serialize(lwgeom_line);
1158 PG_FREE_IF_COPY(ser_line, 0);
1159 PG_FREE_IF_COPY(ser_point, 0);
1161 PG_RETURN_POINTER(ser_out);
1168 double cx = PG_GETARG_FLOAT8(1);
1169 double cy = PG_GETARG_FLOAT8(2);
1170 double rr = PG_GETARG_FLOAT8(3);
1175 geom = PG_GETARG_GSERIALIZED_P(0);
1180 PG_FREE_IF_COPY(geom, 0);
1187 PG_FREE_IF_COPY(geom, 0);
1188 PG_RETURN_BOOL(inside);
1202 LWGEOM *lwgeoms[2], *outlwg;
1203 uint32 type1, type2;
1207 POSTGIS_DEBUG(2,
"LWGEOM_collect called.");
1210 if (PG_ARGISNULL(0) && PG_ARGISNULL(1))
1214 if (PG_ARGISNULL(0))
1215 PG_RETURN_DATUM(PG_GETARG_DATUM(1));
1218 if (PG_ARGISNULL(1))
1219 PG_RETURN_DATUM(PG_GETARG_DATUM(0));
1221 gser1 = PG_GETARG_GSERIALIZED_P(0);
1222 gser2 = PG_GETARG_GSERIALIZED_P(1);
1226 "LWGEOM_collect(%s, %s): call",
1233 elog(ERROR,
"Cannot ST_Collect geometries with differing dimensionality.");
1242 type1 = lwgeoms[0]->
type;
1243 type2 = lwgeoms[1]->
type;
1250 POSTGIS_DEBUGF(3,
" outtype = %d", outtype);
1259 result = geometry_serialize(outlwg);
1264 PG_FREE_IF_COPY(gser1, 0);
1265 PG_FREE_IF_COPY(gser2, 1);
1267 PG_RETURN_POINTER(
result);
1286 LWGEOM **lwgeoms, *outlwg;
1292 ArrayIterator iterator;
1296 POSTGIS_DEBUG(2,
"LWGEOM_collect_garray called.");
1298 if (PG_ARGISNULL(0))
1302 array = PG_GETARG_ARRAYTYPE_P(0);
1303 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1306 " array is %d-bytes in size, %ld w/out header",
1308 ARR_SIZE(array) - ARR_OVERHEAD_NONULLS(ARR_NDIM(array)));
1310 POSTGIS_DEBUGF(3,
"LWGEOM_collect_garray: array has %d elements", nelems);
1320 lwgeoms = palloc(
sizeof(
LWGEOM *) * nelems);
1324 iterator = array_create_iterator(array, 0, NULL);
1326 while (array_iterate(iterator, &
value, &isnull))
1340 POSTGIS_DEBUGF(3,
"%s: geom %d deserialized", __func__,
count);
1348 if (lwgeoms[
count]->bbox)
1359 if (lwgeoms[
count]->bbox)
1386 array_free_iterator(iterator);
1388 POSTGIS_DEBUGF(3,
"LWGEOM_collect_garray: outtype = %d", outtype);
1399 result = geometry_serialize(outlwg);
1401 PG_RETURN_POINTER(
result);
1416 POSTGIS_DEBUG(2,
"LWGEOM_line_from_mpoint called");
1419 ingeom = PG_GETARG_GSERIALIZED_P(0);
1423 elog(ERROR,
"makeline: input must be a multipoint");
1431 PG_FREE_IF_COPY(ingeom, 0);
1432 elog(ERROR,
"makeline: lwline_from_lwmpoint returned NULL");
1438 PG_FREE_IF_COPY(ingeom, 0);
1441 PG_RETURN_POINTER(
result);
1460 ArrayIterator iterator;
1464 POSTGIS_DEBUGF(2,
"%s called", __func__);
1467 if (PG_ARGISNULL(0))
1471 array = PG_GETARG_ARRAYTYPE_P(0);
1474 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1476 POSTGIS_DEBUGF(3,
"%s: array has %d elements", __func__, nelems);
1489 geoms = palloc(
sizeof(
LWGEOM *) * nelems);
1492 iterator = array_create_iterator(array, 0, NULL);
1494 while (array_iterate(iterator, &
value, &isnull))
1515 srid = geoms[ngeoms - 1]->
srid;
1521 POSTGIS_DEBUGF(3,
"%s: element %d deserialized", __func__, ngeoms);
1523 array_free_iterator(iterator);
1529 elog(NOTICE,
"No points or linestrings in input array");
1533 POSTGIS_DEBUGF(3,
"LWGEOM_makeline_garray: elements: %d", ngeoms);
1537 result = geometry_serialize(outlwg);
1539 PG_RETURN_POINTER(
result);
1554 POSTGIS_DEBUG(2,
"LWGEOM_makeline called.");
1557 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1558 pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1563 elog(ERROR,
"Input geometries must be points or lines");
1576 PG_FREE_IF_COPY(pglwg1, 0);
1577 PG_FREE_IF_COPY(pglwg2, 1);
1581 PG_RETURN_POINTER(
result);
1592 ArrayType *array = NULL;
1594 const LWLINE *shell = NULL;
1595 const LWLINE **holes = NULL;
1601 POSTGIS_DEBUG(2,
"LWGEOM_makepoly called.");
1604 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1607 lwpgerror(
"Shell is not a line");
1614 array = PG_GETARG_ARRAYTYPE_P(1);
1615 nholes = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
1617 for (i = 0; i < nholes; i++)
1619 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
1620 #pragma GCC diagnostic push
1621 #pragma GCC diagnostic ignored "-Wsign-compare"
1624 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
1625 #pragma GCC diagnostic pop
1628 offset += INTALIGN(VARSIZE(g));
1631 lwpgerror(
"Hole %d is not a line", i);
1643 PG_FREE_IF_COPY(pglwg1, 0);
1645 for (i = 0; i < nholes; i++)
1650 PG_RETURN_POINTER(
result);
1668 POSTGIS_DEBUG(2,
"LWGEOM_expand called.");
1674 PG_RETURN_POINTER(geom);
1681 PG_RETURN_POINTER(geom);
1684 if (PG_NARGS() == 2)
1687 double d = PG_GETARG_FLOAT8(1);
1692 double dx = PG_GETARG_FLOAT8(1);
1693 double dy = PG_GETARG_FLOAT8(2);
1694 double dz = PG_GETARG_FLOAT8(3);
1695 double dm = PG_GETARG_FLOAT8(4);
1717 PG_FREE_IF_COPY(geom, 0);
1719 PG_RETURN_POINTER(
result);
1726 GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
1740 PG_FREE_IF_COPY(pg_lwgeom, 0);
1747 out->low.x = gbox.
xmin;
1748 out->low.y = gbox.
ymin;
1749 out->high.x = gbox.
xmax;
1750 out->high.y = gbox.
ymax;
1751 PG_RETURN_POINTER(out);
1764 int32_t srid = lwgeom->
srid;
1773 PG_RETURN_POINTER(geom);
1779 PG_RETURN_POINTER(geom);
1849 PG_FREE_IF_COPY(geom, 0);
1851 PG_RETURN_POINTER(
result);
1872 LWGEOM *inlwgeom, *outlwgeom;
1875 POSTGIS_DEBUG(2,
"LWGEOM_segmentize2d called");
1877 ingeom = PG_GETARG_GSERIALIZED_P(0);
1878 dist = PG_GETARG_FLOAT8(1);
1885 PG_RETURN_POINTER(ingeom);
1892 elog(ERROR,
"ST_Segmentize: invalid max_distance %g (must be >= 0)", dist);
1903 PG_RETURN_POINTER(ingeom);
1910 PG_FREE_IF_COPY(ingeom, 0);
1918 outgeom = geometry_serialize(outlwgeom);
1923 PG_FREE_IF_COPY(ingeom, 0);
1925 PG_RETURN_POINTER(outgeom);
1935 POSTGIS_DEBUG(2,
"LWGEOM_reverse called");
1937 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
1942 geom = geometry_serialize(lwgeom);
1944 PG_RETURN_POINTER(geom);
1954 POSTGIS_DEBUG(2,
"LWGEOM_force_clockwise_poly called");
1956 ingeom = PG_GETARG_GSERIALIZED_P_COPY(0);
1961 outgeom = geometry_serialize(lwgeom);
1964 PG_FREE_IF_COPY(ingeom, 0);
1965 PG_RETURN_POINTER(outgeom);
1975 PG_RETURN_POINTER(out);
1983 LWGEOM *lwgeom_in, *lwgeom_out;
1985 POSTGIS_DEBUG(2,
"ST_Normalize called");
1987 in = PG_GETARG_GSERIALIZED_P_COPY(0);
1990 POSTGIS_DEBUGF(3,
"Deserialized: %s",
lwgeom_summary(lwgeom_in, 0));
1993 POSTGIS_DEBUGF(3,
"Normalized: %s",
lwgeom_summary(lwgeom_out, 0));
1995 out = geometry_serialize(lwgeom_out);
1999 PG_FREE_IF_COPY(in, 0);
2001 PG_RETURN_POINTER(out);
2014 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
2021 PG_FREE_IF_COPY(in, 0);
2022 PG_RETURN_INT16(ret);
2028 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
2035 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
2042 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
2044 PG_FREE_IF_COPY(in, 0);
2045 PG_RETURN_BOOL(
res);
2052 GSERIALIZED *in = PG_GETARG_GSERIALIZED_HEADER(0);
2054 PG_FREE_IF_COPY(in, 0);
2055 PG_RETURN_INT16(ret);
2073 double x1, y1, x2, y2;
2076 POSTGIS_DEBUG(2,
"ST_MakeEnvelope called");
2078 x1 = PG_GETARG_FLOAT8(0);
2079 y1 = PG_GETARG_FLOAT8(1);
2080 x2 = PG_GETARG_FLOAT8(2);
2081 y2 = PG_GETARG_FLOAT8(3);
2084 srid = PG_GETARG_INT32(4);
2092 PG_RETURN_POINTER(
result);
2102 uint32_t worldTileSize;
2103 double tileGeoSizeX, tileGeoSizeY;
2104 double boundsWidth, boundsHeight;
2105 double x1, y1, x2, y2;
2116 POSTGIS_DEBUG(2,
"ST_TileEnvelope called");
2118 zoom = PG_GETARG_INT32(0);
2119 x = PG_GETARG_INT32(1);
2120 y = PG_GETARG_INT32(2);
2122 bounds = PG_GETARG_GSERIALIZED_P(3);
2131 elog(ERROR,
"%s: Unable to compute bbox", __func__);
2136 margin = PG_NARGS() < 4 ? 0 : PG_GETARG_FLOAT8(4);
2139 elog(ERROR,
"%s: Margin must not be less than -50%%, margin=%f", __func__, margin);
2141 boundsWidth = bbox.
xmax - bbox.
xmin;
2142 boundsHeight = bbox.
ymax - bbox.
ymin;
2143 if (boundsWidth <= 0 || boundsHeight <= 0)
2144 elog(ERROR,
"%s: Geometric bounds are too small", __func__);
2146 if (zoom < 0 || zoom >= 32)
2147 elog(ERROR,
"%s: Invalid tile zoom value, %d", __func__, zoom);
2149 zoomu = (uint32_t)zoom;
2150 worldTileSize = 0x01u << (zoomu > 31 ? 31 : zoomu);
2152 if (
x < 0 || (uint32_t)
x >= worldTileSize)
2153 elog(ERROR,
"%s: Invalid tile x value, %d", __func__,
x);
2154 if (
y < 0 || (uint32_t)
y >= worldTileSize)
2155 elog(ERROR,
"%s: Invalid tile y value, %d", __func__,
y);
2157 tileGeoSizeX = boundsWidth / worldTileSize;
2158 tileGeoSizeY = boundsHeight / worldTileSize;
2165 if ((1 + margin * 2) > worldTileSize)
2172 x1 = bbox.
xmin + tileGeoSizeX * (
x - margin);
2173 x2 = bbox.
xmin + tileGeoSizeX * (
x + 1 + margin);
2176 y1 = bbox.
ymax - tileGeoSizeY * (
y + 1 + margin);
2177 y2 = bbox.
ymax - tileGeoSizeY * (
y - margin);
2180 if (y1 < bbox.
ymin) y1 = bbox.
ymin;
2181 if (y2 > bbox.
ymax) y2 = bbox.
ymax;
2182 if (x1 < bbox.
xmin) x1 = bbox.
xmin;
2183 if (x2 > bbox.
xmax) x2 = bbox.
xmax;
2189 srid, x1, y1, x2, y2))));
2196 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_HEADER(0);
2208 POSTGIS_DEBUG(2,
"LWGEOM_makepoint called");
2210 x = PG_GETARG_FLOAT8(0);
2211 y = PG_GETARG_FLOAT8(1);
2213 if (PG_NARGS() == 2)
2215 else if (PG_NARGS() == 3)
2217 z = PG_GETARG_FLOAT8(2);
2220 else if (PG_NARGS() == 4)
2222 z = PG_GETARG_FLOAT8(2);
2223 m = PG_GETARG_FLOAT8(3);
2228 elog(ERROR,
"LWGEOM_makepoint: unsupported number of args: %d", PG_NARGS());
2234 PG_RETURN_POINTER(
result);
2240 double x = PG_GETARG_FLOAT8(0);
2241 double y = PG_GETARG_FLOAT8(1);
2242 int srid = PG_GETARG_INT32(2);
2245 PG_RETURN_POINTER(
result);
2251 double x = PG_GETARG_FLOAT8(0);
2252 double y = PG_GETARG_FLOAT8(1);
2253 double z = PG_GETARG_FLOAT8(2);
2254 int srid = PG_GETARG_INT32(3);
2257 PG_RETURN_POINTER(
result);
2263 double x = PG_GETARG_FLOAT8(0);
2264 double y = PG_GETARG_FLOAT8(1);
2265 double m = PG_GETARG_FLOAT8(2);
2266 int srid = PG_GETARG_INT32(3);
2269 PG_RETURN_POINTER(
result);
2275 double x = PG_GETARG_FLOAT8(0);
2276 double y = PG_GETARG_FLOAT8(1);
2277 double z = PG_GETARG_FLOAT8(2);
2278 double m = PG_GETARG_FLOAT8(3);
2279 int srid = PG_GETARG_INT32(4);
2282 PG_RETURN_POINTER(
result);
2293 POSTGIS_DEBUG(2,
"LWGEOM_makepoint3dm called.");
2295 x = PG_GETARG_FLOAT8(0);
2296 y = PG_GETARG_FLOAT8(1);
2297 m = PG_GETARG_FLOAT8(2);
2302 PG_RETURN_POINTER(
result);
2311 uint32_t uwhere = 0;
2313 POSTGIS_DEBUGF(2,
"%s called.", __func__);
2315 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
2316 pglwg2 = PG_GETARG_GSERIALIZED_P(1);
2320 elog(ERROR,
"First argument must be a LINESTRING");
2326 elog(ERROR,
"Second argument must be a POINT");
2332 PG_RETURN_POINTER(pglwg1);
2337 if (PG_NARGS() <= 2)
2343 int32 where = PG_GETARG_INT32(2);
2350 elog(ERROR,
"%s: Invalid offset", __func__);
2365 elog(ERROR,
"Point insert failed");
2372 PG_FREE_IF_COPY(pglwg1, 0);
2373 PG_FREE_IF_COPY(pglwg2, 1);
2376 PG_RETURN_POINTER(
result);
2386 POSTGIS_DEBUG(2,
"LWGEOM_removepoint called.");
2388 pglwg1 = PG_GETARG_GSERIALIZED_P(0);
2389 which = PG_GETARG_INT32(1);
2393 elog(ERROR,
"First argument must be a LINESTRING");
2399 if (which < 0 || (uint32_t)which > line->
points->
npoints - 1)
2401 elog(ERROR,
"Point index out of range (%u..%u)", 0, line->
points->
npoints - 1);
2407 elog(ERROR,
"Can't remove points from a single segment line");
2418 PG_FREE_IF_COPY(pglwg1, 0);
2419 PG_RETURN_POINTER(
result);
2432 POSTGIS_DEBUG(2,
"LWGEOM_setpoint_linestring called.");
2435 pglwg1 = PG_GETARG_GSERIALIZED_P_COPY(0);
2437 which = PG_GETARG_INT32(1);
2438 pglwg2 = PG_GETARG_GSERIALIZED_P(2);
2445 elog(ERROR,
"Third argument must be a POINT");
2450 PG_FREE_IF_COPY(pglwg2, 2);
2457 elog(ERROR,
"First argument must be a LINESTRING");
2462 elog(ERROR,
"Line has no points");
2473 elog(ERROR,
"abs(Point index) out of range (-)(%u..%u)", 0, line->
points->
npoints - 1);
2487 PG_RETURN_POINTER(
result);
2520 geom = PG_GETARG_GSERIALIZED_P(0);
2524 PG_FREE_IF_COPY(geom, 0);
2525 lwpgerror(
"Argument must be POINT geometries");
2528 srid = lwpoint->
srid;
2531 PG_FREE_IF_COPY(geom, 0);
2532 lwpgerror(
"Error extracting point");
2536 PG_FREE_IF_COPY(geom, 0);
2539 geom = PG_GETARG_GSERIALIZED_P(1);
2543 PG_FREE_IF_COPY(geom, 1);
2544 lwpgerror(
"Argument must be POINT geometries");
2547 if (lwpoint->
srid != srid)
2549 PG_FREE_IF_COPY(geom, 1);
2550 lwpgerror(
"Operation on mixed SRID geometries");
2555 PG_FREE_IF_COPY(geom, 1);
2556 lwpgerror(
"Error extracting point");
2560 PG_FREE_IF_COPY(geom, 1);
2563 if ((p1.
x == p2.
x) && (p1.
y == p2.
y))
2574 PG_RETURN_FLOAT8(
result);
2597 int n_args = PG_NARGS();
2600 for (i = 0; i < n_args; i++)
2602 seri_geoms[i] = PG_GETARG_GSERIALIZED_P(i);
2625 if (srids[0] != srids[i])
2637 for (j = 0; j <= i; j++)
2638 PG_FREE_IF_COPY(seri_geoms[j], j);
2641 lwpgerror(
"Empty geometry");
2646 lwpgerror(
"Argument must be POINT geometries");
2651 lwpgerror(
"Operation on mixed SRID geometries");
2656 for (i = 0; i < n_args; i++)
2662 for (j = 0; j < n_args; j++)
2663 PG_FREE_IF_COPY(seri_geoms[j], j);
2664 lwpgerror(
"Error unserializing geometry");
2673 lwpgerror(
"Error extracting point");
2701 PG_RETURN_FLOAT8(
result);
2714 GSERIALIZED *pg_geom1 = PG_GETARG_GSERIALIZED_P(0);
2715 GSERIALIZED *pg_geom2 = PG_GETARG_GSERIALIZED_P(1);
2716 double dist = PG_GETARG_FLOAT8(2);
2725 elog(ERROR,
"optimistic_overlap: first arg isn't a polygon\n");
2731 elog(ERROR,
"optimistic_overlap: 2nd arg isn't a [multi-]polygon\n");
2738 g1_bvol.
xmin = g1_bvol.
xmin - dist;
2739 g1_bvol.
ymin = g1_bvol.
ymin - dist;
2740 g1_bvol.
xmax = g1_bvol.
xmax + dist;
2741 g1_bvol.
ymax = g1_bvol.
ymax + dist;
2746 PG_RETURN_BOOL(
false);
2754 DatumGetFloat8(DirectFunctionCall2(
ST_Distance, PointerGetDatum(pg_geom1), PointerGetDatum(pg_geom2)));
2756 PG_RETURN_BOOL(calc_dist < dist);
2763 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P_COPY(0);
2768 affine.
afac = PG_GETARG_FLOAT8(1);
2769 affine.
bfac = PG_GETARG_FLOAT8(2);
2770 affine.
cfac = PG_GETARG_FLOAT8(3);
2771 affine.
dfac = PG_GETARG_FLOAT8(4);
2772 affine.
efac = PG_GETARG_FLOAT8(5);
2773 affine.
ffac = PG_GETARG_FLOAT8(6);
2774 affine.
gfac = PG_GETARG_FLOAT8(7);
2775 affine.
hfac = PG_GETARG_FLOAT8(8);
2776 affine.
ifac = PG_GETARG_FLOAT8(9);
2777 affine.
xoff = PG_GETARG_FLOAT8(10);
2778 affine.
yoff = PG_GETARG_FLOAT8(11);
2779 affine.
zoff = PG_GETARG_FLOAT8(12);
2781 POSTGIS_DEBUG(2,
"LWGEOM_affine called.");
2790 ret = geometry_serialize(lwgeom);
2794 PG_FREE_IF_COPY(geom, 0);
2796 PG_RETURN_POINTER(ret);
2807 if (PG_ARGISNULL(0))
2812 geom = PG_GETARG_GSERIALIZED_P(0);
2814 if (!PG_ARGISNULL(1))
2821 PG_RETURN_TEXT_P(geohash);
2828 if (PG_ARGISNULL(0))
2842 extype = PG_GETARG_INT32(1);
2847 elog(ERROR,
"ST_CollectionExtract: only point, linestring and polygon may be extracted");
2851 gser_in = PG_GETARG_GSERIALIZED_P(0);
2858 if (lwg_in->
type == extype || !extype)
2861 PG_RETURN_POINTER(gser_in);
2867 PG_RETURN_POINTER(geometry_serialize(lwg_out));
2873 gser_out = geometry_serialize(lwg_out);
2876 PG_RETURN_POINTER(gser_out);
2892 PG_FREE_IF_COPY(input, 0);
2896 output = geometry_serialize(lwoutput);
2899 PG_FREE_IF_COPY(input, 0);
2900 PG_RETURN_POINTER(output);
2907 GSERIALIZED *g_in = PG_GETARG_GSERIALIZED_P_COPY(0);
2910 LWGEOM *lwgeom_in = NULL;
2911 double tolerance = 0.0;
2916 PG_RETURN_POINTER(g_in);
2918 if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
2919 tolerance = PG_GETARG_FLOAT8(1);
2926 PG_RETURN_POINTER(g_in);
2929 g_out = geometry_serialize(lwgeom_in);
2932 PG_RETURN_POINTER(g_out);
2939 GSERIALIZED *in = PG_GETARG_GSERIALIZED_P_COPY(0);
2944 out = geometry_serialize(lwgeom);
2947 PG_FREE_IF_COPY(in, 0);
2949 PG_RETURN_POINTER(out);
2955 if (n ==
'x' || n ==
'X')
2957 if (n ==
'y' || n ==
'Y')
2959 if (n ==
'z' || n ==
'Z')
2961 if (n ==
'm' || n ==
'M')
2963 lwpgerror(
"Invalid ordinate name '%c'. Expected x,y,z or m", n);
2977 ospec = PG_GETARG_CSTRING(1);
2978 if (strlen(ospec) != 2)
2981 "Invalid ordinate specification. "
2982 "Need two letters from the set (x,y,z,m). "
2990 in = PG_GETARG_GSERIALIZED_P_COPY(0);
2995 lwpgerror(
"Geometry does not have an M ordinate");
3000 lwpgerror(
"Geometry does not have a Z ordinate");
3006 PG_RETURN_POINTER(in);
3010 out = geometry_serialize(lwgeom);
3012 PG_FREE_IF_COPY(in, 0);
3013 PG_RETURN_POINTER(out);
3024 bool fits = PG_GETARG_BOOL(1);
3025 LWGEOM *lwgeom_out = NULL;
3037 GSERIALIZED *geom_in = PG_GETARG_GSERIALIZED_P(0);
3042 srid = lwgeom_in->
srid;
3073 geom_out = geometry_serialize(lwgeom_out);
3076 PG_RETURN_POINTER(geom_out);
3084 GSERIALIZED *geom_scale = PG_GETARG_GSERIALIZED_P(1);
3086 LWGEOM *lwg, *lwg_scale, *lwg_origin;
3087 LWPOINT *lwpt_scale, *lwpt_origin;
3090 bool translate =
false;
3100 PG_FREE_IF_COPY(geom_scale, 1);
3101 lwpgerror(
"Scale factor geometry parameter must be a point");
3106 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
3114 PG_FREE_IF_COPY(geom_scale, 1);
3115 PG_RETURN_POINTER(geom);
3128 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3130 geom_origin = PG_GETARG_GSERIALIZED_P(2);
3140 PG_FREE_IF_COPY(geom_origin, 2);
3147 memset(&aff, 0,
sizeof(
AFFINE));
3151 aff.
xoff = -1 * origin.
x;
3152 aff.
yoff = -1 * origin.
y;
3153 aff.
zoff = -1 * origin.
z;
3169 ret = geometry_serialize(lwg);
3171 PG_FREE_IF_COPY(geom, 0);
3172 PG_FREE_IF_COPY(geom_scale, 1);
3173 PG_RETURN_POINTER(ret);
3180 if (PG_ARGISNULL(0))
3195 PG_RETURN_POINTER(ret);
3210 if (PG_ARGISNULL(0))
3212 if (PG_ARGISNULL(1))
3214 lwpgerror(
"Must specify precision");
3219 prec_x = PG_GETARG_INT32(1);
3221 prec_y = PG_ARGISNULL(2) ? prec_x : PG_GETARG_INT32(2);
3222 prec_z = PG_ARGISNULL(3) ? prec_x : PG_GETARG_INT32(3);
3223 prec_m = PG_ARGISNULL(4) ? prec_x : PG_GETARG_INT32(4);
3225 input = PG_GETARG_GSERIALIZED_P_COPY(0);
3231 result = geometry_serialize(g);
3233 PG_FREE_IF_COPY(input, 0);
3234 PG_RETURN_POINTER(
result);
3251 if (PG_NARGS() > 0 && !PG_ARGISNULL(0))
3253 geom_in = PG_GETARG_GSERIALIZED_P(0);
3260 if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
3261 min = PG_GETARG_FLOAT8(1);
3266 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3267 max = PG_GETARG_FLOAT8(2);
3272 if (PG_NARGS() > 3 && !PG_ARGISNULL(3) && PG_GETARG_BOOL(3))
3281 elog(ERROR,
"Min-value cannot be larger than Max value\n");
3291 elog(NOTICE,
"No M-value, No vertex removed\n");
3292 PG_RETURN_POINTER(geom_in);
3297 geom_out = geometry_serialize(lwgeom_out);
3299 PG_RETURN_POINTER(geom_out);
3307 LWGEOM *lwgeom, *lwresult;
3309 geom1 = PG_GETARG_GSERIALIZED_P(0);
3321 result = geometry_serialize(lwresult);
3326 PG_RETURN_POINTER(
result);
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)
LWGEOM * lwgeom_boundary(LWGEOM *lwgeom)
#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
int ptarray_scroll_in_place(POINTARRAY *pa, const POINT4D *newbase)
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 ST_PointZM(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 ST_Scroll(PG_FUNCTION_ARGS)
Datum LWGEOM_segmentize2d(PG_FUNCTION_ARGS)
Datum ST_PointM(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_PointZ(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 ST_Point(PG_FUNCTION_ARGS)
Datum boundary(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