Commit 651e6bdd authored by Darafei Praliaskouski's avatar Darafei Praliaskouski

Remove postgis.backend switch and SFCGAL versions of functions that have both versions.

Causes #4328

References #4258
Closes https://github.com/postgis/postgis/pull/374


git-svn-id: http://svn.osgeo.org/postgis/trunk@17263 b70326c6-7e19-0410-871a-916f4a2858ee
parent a535f159
Pipeline #48320146 failed with stage
in 7 minutes and 19 seconds
......@@ -15,7 +15,8 @@ PostGIS 3.0.0
If your project depends on them available, please use
librttopo instead. (Darafei Praliaskouski)
- #4258, Remove SFCGAL support for ST_Area, ST_Distance, ST_Intersection,
ST_Difference, ST_Union (Darafei Praliaskouski)
ST_Difference, ST_Union, ST_Intersects, ST_3DIntersects, ST_3DDistance
and postgis.backend switch (Darafei Praliaskouski)
- #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
- #4268, Bump minimum SFCGAL version to 1.3.1 (Darafei Praliaskouski)
......@@ -69,10 +70,10 @@ PostGIS 3.0.0
- #4272, Improve notice message when unable to compute stats (Raúl Marín)
- #4314, ST_ClipByBox2D: Do not throw when the geometry is invalid (Raúl Marín)
- #4313, #4307, PostgreSQL 12 compatibility (Laurenz Albe, Raúl Marín)
- #4299, #4304, ST_GeneratePoints is now VOLATILE. IMMUTABLE version with
- #4299, #4304, ST_GeneratePoints is now VOLATILE. IMMUTABLE version with
seed parameter added. (Mike Taves)
- #4278, ST_3DDistance and ST_3DIntersects now support Solid TIN and Solid
POLYHEDRALSURFACE
POLYHEDRALSURFACE (Darafei Praliaskouski)
PostGIS 2.5.0
2018/09/23
......
......@@ -128,10 +128,10 @@ SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
<!-- Optionally mention supports Polyhedral Surface -->
<para>&P_support;</para>
<para>&sqlmm_compliant; SQL-MM ?</para>
<para>&sfcgal_enhanced;</para>
<para>Availability: 2.0.0</para>
<para>Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
<para>Changed: 3.0.0 - SFCGAL version removed</para>
</refsection>
<refsection>
......@@ -141,12 +141,12 @@ SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
SELECT ST_3DDistance(
ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 4)'),2163),
ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry,2163),
ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'::geometry,2163)
) As dist_3d,
ST_Distance(
ST_Transform(ST_GeomFromText('POINT(-72.1235 42.3521)',4326),2163),
ST_Transform(ST_GeomFromText('LINESTRING(-72.1260 42.45, -72.123 42.1546)', 4326),2163)
ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry,2163),
ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry,2163)
) As dist_2d;
dist_3d | dist_2d
......@@ -158,9 +158,8 @@ SELECT ST_3DDistance(
-- Same example as 3D closest point example
SELECT ST_3DDistance(poly, mline) As dist3d,
ST_Distance(poly, mline) As dist2d
FROM (SELECT ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
(1 10 2, 5 20 1))') As mline ) As foo;
FROM (SELECT 'POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))'::geometry as poly,
'MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1), (1 10 2, 5 20 1))'::geometry as mline) as foo;
dist3d | dist2d
-------------------+--------
0.716635696066337 | 0
......@@ -315,7 +314,7 @@ ST_DWithin(
<refname>ST_3DIntersects</refname>
<refpurpose>Returns TRUE if the Geometries "spatially
intersect" in 3d - only for points, linestrings, polygons, polyhedral surface (area). With SFCGAL backend enabled also supports TINS
intersect" in 3D - only for points, linestrings, polygons, polyhedral surface (area).
</refpurpose>
</refnamediv>
<refsynopsisdiv>
......@@ -339,8 +338,7 @@ ST_DWithin(
returns true, then the geometries also spatially intersect.
Disjoint implies false for spatial intersection.</para>
<para>Changed: 3.0.0 SFCGAL backend removed, GEOS backend supports TINs.</para>
<para>Availability: 2.0.0</para>
<note>
<para>This function call will automatically include a bounding box
......@@ -348,7 +346,6 @@ ST_DWithin(
geometries.</para>
</note>
<note><para>In order to take advantage of support for TINS, you need to enable the SFCGAL backend. This can be done at session time with: <code>set postgis.backend = sfcgal;</code> or at the database or system level. Database level can be done with <code>ALTER DATABASE gisdb SET postgis.backend = sfcgal;</code>.</para></note>
<para>&Z_support;</para>
<!-- Optionally mention supports Polyhedral Surface -->
<para>&P_support;</para>
......@@ -358,9 +355,8 @@ ST_DWithin(
</refsection>
<refsection>
<title>Geometry Examples</title>
<programlisting>SELECT ST_3DIntersects(pt, line), ST_Intersects(pt,line)
FROM (SELECT 'POINT(0 0 2)'::geometry As pt,
'LINESTRING (0 0 1, 0 2 3 )'::geometry As line) As foo;
<programlisting>SELECT ST_3DIntersects(pt, line), ST_Intersects(pt, line)
FROM (SELECT 'POINT(0 0 2)'::geometry As pt, 'LINESTRING (0 0 1, 0 2 3)'::geometry As line) As foo;
st_3dintersects | st_intersects
-----------------+---------------
f | t
......@@ -369,8 +365,7 @@ ST_DWithin(
</refsection>
<refsection><title>TIN Examples</title>
<programlisting>set postgis.backend = sfcgal;
SELECT ST_3DIntersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'POINT(.1 .1)'::geometry);
<programlisting>SELECT ST_3DIntersects('TIN(((0 0 0,1 0 0,0 1 0,0 0 0)))'::geometry, 'POINT(.1 .1 0)'::geometry);
st_3dintersects
-----------------
t</programlisting></refsection>
......@@ -3437,7 +3432,7 @@ FROM test;
<refpurpose>Returns TRUE if the Geometries/Geography "spatially
intersect in 2D" - (share any portion of space) and FALSE if they don't (they are Disjoint).
For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)
For geography tolerance is 0.00001 meters (so any points that close are considered to intersect)
</refpurpose>
</refnamediv>
<refsynopsisdiv>
......@@ -3470,10 +3465,12 @@ FROM test;
<title>Description</title>
<para>If a geometry or geography shares any portion of space then they intersect.
For geography -- tolerance is 0.00001 meters (so any points that are close are considered to intersect)</para>
<para>Overlaps, Touches, Within all imply spatial intersection. If any of the aforementioned
<para>ST_Overlaps, ST_Touches, ST_Within all imply spatial intersection.
If any of the aforementioned
returns true, then the geometries also spatially intersect.
Disjoint implies false for spatial intersection.</para>
<para>Changed: 3.0.0 SFCGAL version removed.</para>
<para>Enhanced: 2.5.0 Supports GEOMETRYCOLLECTION.</para>
<para>Enhanced: 2.3.0 Enhancement to PIP short-circuit extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
<para>Performed by the GEOS module (for geometry), geography is native</para>
......@@ -3514,8 +3511,8 @@ SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry
<refsection>
<title>Geography Examples</title>
<programlisting>SELECT ST_Intersects(
ST_GeographyFromText('SRID=4326;LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'),
ST_GeographyFromText('SRID=4326;POINT(-43.23456 72.4567772)')
'SRID=4326;LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'::geography,
'SRID=4326;POINT(-43.23456 72.4567772)'::geography
);
st_intersects
......
......@@ -10,13 +10,7 @@
Installation instructions of the library can be found on SFCGAL home page <ulink url="http://www.sfcgal.org">http://www.sfcgal.org</ulink>.
To load the functions create extension postgis_sfcgal.
</para>
<para>
Some SFCGAL functions replace standard ones (ST_Intersects, ST_Intersection, ST_Difference, ST_Union, ST_Area and ST_Distance), to switch between standard functions and SFCGAL function use:
<programlisting>SET postgis.backend = sfcgal;</programlisting>
and
<programlisting>SET postgis.backend = geos;</programlisting>
</para>
</abstract>
</sect1info>
<title>SFCGAL Functions</title>
......
......@@ -83,7 +83,6 @@ PG_OBJS= \
lwgeom_box.o \
lwgeom_box3d.o \
$(BACKEND_OBJ) \
lwgeom_backend_api.o \
lwgeom_geos_prepared.o \
lwgeom_geos_clean.o \
lwgeom_geos_relatematch.o \
......
......@@ -998,7 +998,7 @@ CREATE OR REPLACE FUNCTION getbbox(geometry)
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION intersects(geometry,geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
AS 'MODULE_PATHNAME','ST_Intersects'
LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
......
/**********************************************************************
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.net
*
* PostGIS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* PostGIS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************
*
* Copyright 2012-2013 Oslandia <infos@oslandia.com>
*
**********************************************************************/
#include "postgres.h"
#include "fmgr.h"
#include "utils/guc.h" /* for custom variables */
#include "../postgis_config.h"
#include "lwgeom_pg.h"
#include "liblwgeom.h"
#include "lwgeom_backend_api.h"
#include "lwgeom_geos.h"
#if HAVE_SFCGAL
#include "lwgeom_sfcgal.h"
#endif
Datum intersects(PG_FUNCTION_ARGS);
Datum intersects3d(PG_FUNCTION_ARGS);
Datum distance3d(PG_FUNCTION_ARGS);
Datum intersects3d_dwithin(PG_FUNCTION_ARGS);
struct lwgeom_backend_definition
{
const char *name;
Datum (*intersects_fn)(PG_FUNCTION_ARGS);
Datum (*intersects3d_fn)(PG_FUNCTION_ARGS);
Datum (*distance3d_fn)(PG_FUNCTION_ARGS);
};
#if HAVE_SFCGAL
#define LWGEOM_NUM_BACKENDS 2
#else
#define LWGEOM_NUM_BACKENDS 1
#endif
struct lwgeom_backend_definition lwgeom_backends[LWGEOM_NUM_BACKENDS] = {{.name = "geos",
.intersects_fn = geos_intersects,
.intersects3d_fn = intersects3d_dwithin,
.distance3d_fn = LWGEOM_mindistance3d},
#if HAVE_SFCGAL
{.name = "sfcgal",
.intersects_fn = sfcgal_intersects,
.intersects3d_fn = sfcgal_intersects3D,
.distance3d_fn = sfcgal_distance3D}
#endif
};
/* Geometry Backend */
char *lwgeom_backend_name;
struct lwgeom_backend_definition *lwgeom_backend = &lwgeom_backends[0];
static void
lwgeom_backend_switch(const char *newvalue, __attribute__((__unused__)) void *extra)
{
int i;
if (!newvalue)
return;
for (i = 0; i < LWGEOM_NUM_BACKENDS; ++i)
{
if (!strcmp(lwgeom_backends[i].name, newvalue))
{
lwgeom_backend = &lwgeom_backends[i];
return;
}
}
lwpgerror("Can't find %s geometry backend", newvalue);
}
void
lwgeom_init_backend()
{
/* #2382 Before trying to create a user GUC, make sure */
/* that the name is not already in use. Why would it be in use? */
/* During an upgrade, a prior copy of the PostGIS library will */
/* already be loaded in memory and the GUC already defined. We */
/* can skip GUC definition in this case, so we just return. */
static const char *guc_name = "postgis.backend";
// const char *guc_installed = GetConfigOption(guc_name, TRUE, FALSE);
/* Uh oh, this GUC name already exists. Ordinarily we could just go on */
/* our way, but the way the postgis.backend works is by using the "assign" */
/* callback to change which backend is in use by flipping a global variable */
/* over. This saves the overhead of looking up the engine every time, at */
/* the expense of the extra complexity. */
if (postgis_guc_find_option(guc_name))
{
/* In this narrow case the previously installed GUC is tied to the callback in */
/* the previously loaded library. Probably this is happening during an */
/* upgrade, so the old library is where the callback ties to. */
elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", guc_name);
return;
}
/* Good, the GUC name is not already in use, so this must be a fresh */
/* and clean new load of the library, and we can define the user GUC */
DefineCustomStringVariable(
guc_name, /* name */
"Sets the PostGIS Geometry Backend.", /* short_desc */
"Sets the PostGIS Geometry Backend (allowed values are 'geos' or 'sfcgal')", /* long_desc */
&lwgeom_backend_name, /* valueAddr */
(char *)lwgeom_backends[0].name, /* bootValue */
PGC_USERSET, /* GucContext context */
0, /* int flags */
NULL, /* GucStringCheckHook check_hook */
lwgeom_backend_switch, /* GucStringAssignHook assign_hook */
NULL /* GucShowHook show_hook */
);
}
PG_FUNCTION_INFO_V1(intersects);
Datum intersects(PG_FUNCTION_ARGS)
{
return (*lwgeom_backend->intersects_fn)(fcinfo);
}
PG_FUNCTION_INFO_V1(distance3d);
Datum distance3d(PG_FUNCTION_ARGS)
{
return (*lwgeom_backend->distance3d_fn)(fcinfo);
}
PG_FUNCTION_INFO_V1(intersects3d);
Datum intersects3d(PG_FUNCTION_ARGS)
{
return (*lwgeom_backend->intersects3d_fn)(fcinfo);
}
/* intersects3d through dwithin
* used by the 'geos' backend */
PG_FUNCTION_INFO_V1(intersects3d_dwithin);
Datum intersects3d_dwithin(PG_FUNCTION_ARGS)
{
double mindist;
GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
mindist = lwgeom_mindistance3d_tolerance(lwgeom1, lwgeom2, 0.0);
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
/*empty geometries cases should be right handled since return from underlying
functions should be FLT_MAX which causes false as answer*/
PG_RETURN_BOOL(0.0 == mindist);
}
/**********************************************************************
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.net
*
* PostGIS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* PostGIS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************
*
* Copyright 2012-2013 Oslandia <infos@oslandia.com>
*
**********************************************************************/
#ifndef LWGEOM_BACKEND_API_H_
#define LWGEOM_BACKEND_API_H_ 1
void lwgeom_init_backend(void);
#endif
......@@ -908,8 +908,8 @@ Datum LWGEOM_longestline3d(PG_FUNCTION_ARGS)
/**
Minimum 2d distance between objects in geom1 and geom2 in 3D
*/
PG_FUNCTION_INFO_V1(LWGEOM_mindistance3d);
Datum LWGEOM_mindistance3d(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(ST_3DDistance);
Datum ST_3DDistance(PG_FUNCTION_ARGS)
{
double mindist;
GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
......@@ -931,6 +931,28 @@ Datum LWGEOM_mindistance3d(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
/* intersects3d through dwithin */
PG_FUNCTION_INFO_V1(ST_3DIntersects);
Datum ST_3DIntersects(PG_FUNCTION_ARGS)
{
double mindist;
GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
mindist = lwgeom_mindistance3d_tolerance(lwgeom1, lwgeom2, 0.0);
PG_FREE_IF_COPY(geom1, 0);
PG_FREE_IF_COPY(geom2, 1);
/*empty geometries cases should be right handled since return from underlying
functions should be FLT_MAX which causes false as answer*/
PG_RETURN_BOOL(0.0 == mindist);
}
/**
Returns boolean describing if
mininimum 3d distance between objects in
......
......@@ -70,7 +70,7 @@ Datum relate_full(PG_FUNCTION_ARGS);
Datum relate_pattern(PG_FUNCTION_ARGS);
Datum disjoint(PG_FUNCTION_ARGS);
Datum touches(PG_FUNCTION_ARGS);
Datum geos_intersects(PG_FUNCTION_ARGS);
Datum ST_Intersects(PG_FUNCTION_ARGS);
Datum crosses(PG_FUNCTION_ARGS);
Datum contains(PG_FUNCTION_ARGS);
Datum containsproperly(PG_FUNCTION_ARGS);
......@@ -2126,8 +2126,8 @@ Datum crosses(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(result);
}
PG_FUNCTION_INFO_V1(geos_intersects);
Datum geos_intersects(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(ST_Intersects);
Datum ST_Intersects(PG_FUNCTION_ARGS)
{
GSERIALIZED *geom1;
GSERIALIZED *geom2;
......@@ -2152,9 +2152,7 @@ Datum geos_intersects(PG_FUNCTION_ARGS)
gserialized_get_gbox_p(geom2, &box2) )
{
if ( gbox_overlaps_2d(&box1, &box2) == LW_FALSE )
{
PG_RETURN_BOOL(false);
}
}
/*
......
......@@ -45,7 +45,7 @@ Datum geos_difference(PG_FUNCTION_ARGS);
Datum geos_geomunion(PG_FUNCTION_ARGS);
Datum LWGEOM_area_polygon(PG_FUNCTION_ARGS);
Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS);
Datum LWGEOM_mindistance3d(PG_FUNCTION_ARGS);
Datum ST_3DDistance(PG_FUNCTION_ARGS);
void errorIfGeometryCollection(GSERIALIZED *g1, GSERIALIZED *g2);
uint32_t array_nelems_not_null(ArrayType* array);
......
......@@ -34,10 +34,7 @@
Datum postgis_sfcgal_version(PG_FUNCTION_ARGS);
Datum sfcgal_from_ewkt(PG_FUNCTION_ARGS);
Datum sfcgal_distance3D(PG_FUNCTION_ARGS);
Datum sfcgal_area3D(PG_FUNCTION_ARGS);
Datum sfcgal_intersects(PG_FUNCTION_ARGS);
Datum sfcgal_intersects3D(PG_FUNCTION_ARGS);
Datum sfcgal_intersection3D(PG_FUNCTION_ARGS);
Datum sfcgal_difference3D(PG_FUNCTION_ARGS);
Datum sfcgal_union3D(PG_FUNCTION_ARGS);
......@@ -206,75 +203,6 @@ Datum sfcgal_orientation(PG_FUNCTION_ARGS)
PG_RETURN_INT32(result);
}
PG_FUNCTION_INFO_V1(sfcgal_intersects);
Datum sfcgal_intersects(PG_FUNCTION_ARGS)
{
GSERIALIZED *input0, *input1;
sfcgal_geometry_t *geom0, *geom1;
int result;
sfcgal_postgis_init();
input0 = PG_GETARG_GSERIALIZED_P(0);
input1 = PG_GETARG_GSERIALIZED_P(1);
geom0 = POSTGIS2SFCGALGeometry(input0);
PG_FREE_IF_COPY(input0, 0);
geom1 = POSTGIS2SFCGALGeometry(input1);
PG_FREE_IF_COPY(input1, 1);
result = sfcgal_geometry_intersects(geom0, geom1);
sfcgal_geometry_delete(geom0);
sfcgal_geometry_delete(geom1);
PG_RETURN_BOOL(result);
}
PG_FUNCTION_INFO_V1(sfcgal_intersects3D);
Datum sfcgal_intersects3D(PG_FUNCTION_ARGS)
{
GSERIALIZED *input0, *input1;
sfcgal_geometry_t *geom0, *geom1;
int result;
sfcgal_postgis_init();
input0 = PG_GETARG_GSERIALIZED_P(0);
input1 = PG_GETARG_GSERIALIZED_P(1);
geom0 = POSTGIS2SFCGALGeometry(input0);
PG_FREE_IF_COPY(input0, 0);
geom1 = POSTGIS2SFCGALGeometry(input1);
PG_FREE_IF_COPY(input1, 1);
result = sfcgal_geometry_intersects_3d(geom0, geom1);
sfcgal_geometry_delete(geom0);
sfcgal_geometry_delete(geom1);
PG_RETURN_BOOL(result);
}
PG_FUNCTION_INFO_V1(sfcgal_distance3D);
Datum sfcgal_distance3D(PG_FUNCTION_ARGS)
{
GSERIALIZED *input0, *input1;
sfcgal_geometry_t *geom0, *geom1;
double result;
sfcgal_postgis_init();
input0 = PG_GETARG_GSERIALIZED_P(0);
input1 = PG_GETARG_GSERIALIZED_P(1);
geom0 = POSTGIS2SFCGALGeometry(input0);
PG_FREE_IF_COPY(input0, 0);
geom1 = POSTGIS2SFCGALGeometry(input1);
PG_FREE_IF_COPY(input1, 1);
result = sfcgal_geometry_distance_3d(geom0, geom1);
sfcgal_geometry_delete(geom0);
sfcgal_geometry_delete(geom1);
PG_RETURN_FLOAT8(result);
}
PG_FUNCTION_INFO_V1(sfcgal_tesselate);
Datum sfcgal_tesselate(PG_FUNCTION_ARGS)
{
......
......@@ -4190,7 +4190,7 @@ CREATE OR REPLACE FUNCTION ST_DWithin(geom1 geometry, geom2 geometry, float8)
-- PostGIS equivalent function: intersects(geom1 geometry, geom2 geometry)
CREATE OR REPLACE FUNCTION _ST_Intersects(geom1 geometry, geom2 geometry)
RETURNS boolean
AS 'MODULE_PATHNAME','intersects'
AS 'MODULE_PATHNAME','ST_Intersects'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100; -- Guessed cost
......@@ -5785,7 +5785,7 @@ CREATE OR REPLACE RULE geometry_columns_delete AS
CREATE OR REPLACE FUNCTION ST_3DDistance(geom1 geometry, geom2 geometry)
RETURNS float8
AS 'MODULE_PATHNAME', 'distance3d'
AS 'MODULE_PATHNAME', 'ST_3DDistance'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
......@@ -5839,7 +5839,7 @@ CREATE OR REPLACE FUNCTION ST_3DDFullyWithin(geom1 geometry, geom2 geometry,floa
CREATE OR REPLACE FUNCTION _ST_3DIntersects(geom1 geometry, geom2 geometry)
RETURNS boolean
AS 'MODULE_PATHNAME','intersects3d'
AS 'MODULE_PATHNAME', 'ST_3DIntersects'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
......
......@@ -62,3 +62,11 @@ POSTGIS_DEPRECATE("3.0.0", intersection);
POSTGIS_DEPRECATE("3.0.0", geos_intersection);
POSTGIS_DEPRECATE("3.0.0", difference);
POSTGIS_DEPRECATE("3.0.0", geos_difference);
POSTGIS_DEPRECATE("3.0.0", geos_intersects);
POSTGIS_DEPRECATE("3.0.0", sfcgal_intersects);
POSTGIS_DEPRECATE("3.0.0", intersects3d);
POSTGIS_DEPRECATE("3.0.0", intersects3d_dwithin);
POSTGIS_DEPRECATE("3.0.0", sfcgal_intersects3d);
POSTGIS_DEPRECATE("3.0.0", distance3d);
POSTGIS_DEPRECATE("3.0.0", sfcgal_distance3d);
POSTGIS_DEPRECATE("3.0.0", LWGEOM_mindistance3d);
......@@ -34,7 +34,6 @@
#include "lwgeom_log.h"
#include "lwgeom_pg.h"
#include "geos_c.h"
#include "lwgeom_backend_api.h"
#ifdef HAVE_WAGYU
#include "lwgeom_wagyu.h"
......@@ -72,9 +71,6 @@ _PG_init(void)
/* install PostgreSQL handlers */
pg_install_lwgeom_handlers();
/* initialize geometry backend */
lwgeom_init_backend();
}
/*
......
......@@ -33,14 +33,6 @@ export PATH
TESTS = \
regress_sfcgal \
empty.sql \
geography.sql \
legacy.sql \
measures.sql \
regress_ogc_prep.sql \
regress_ogc.sql \
regress.sql \
wmsservers.sql \
approximatemedialaxis.sql
test check:
......
SET postgis.backend = 'sfcgal';
-- ST_SnapToGrid
SELECT 'T1.1', ST_AsEWKT(ST_SnapToGrid('POINT EMPTY', 1));
SELECT 'T1.2', ST_AsEWKT(ST_SnapToGrid('LINESTRING EMPTY', 1));
SELECT 'T1.3', ST_AsEWKT(ST_SnapToGrid('SRID=4326;POLYGON EMPTY', 1));
-- ST_Buffer
SELECT 'T2.1', ST_AsEWKT(ST_Buffer('SRID=4326;POINT EMPTY', 0));
SELECT 'T2.2', ST_AsEWKT(ST_Buffer('SRID=4326;LINESTRING EMPTY', 0));
SELECT 'T2.3', ST_AsEWKT(ST_Buffer('SRID=4326;MULTIPOLYGON EMPTY', 0));
WITH b as ( SELECT ST_Buffer('SRID=4326;MULTIPOINT EMPTY', 1) as g )
SELECT 'T2.4', ST_Srid(g), GeometryType(g) from b;
-- ST_AsGML (output may need some tweaking)
SELECT 'T3.1', ST_AsGML('POINT EMPTY');
SELECT 'T3.2', ST_AsGML('LINESTRING EMPTY');
SELECT 'T3.3', ST_AsGML('POLYGON EMPTY');
SELECT 'T3.4', ST_AsGML('MULTIPOLYGON EMPTY');
SELECT 'T3.5', ST_AsGML('MULTILINESTRING EMPTY');
SELECT 'T3.6', ST_AsGML('GEOMETRYCOLLECTION EMPTY');
SELECT 'T3.7', ST_AsGML(3,'POINT EMPTY'::geometry);
SELECT 'T3.8', ST_AsGML(3,'LINESTRING EMPTY'::geometry);
SELECT 'T3.9', ST_AsGML(3,'POLYGON EMPTY'::geometry);
SELECT 'T3.10', ST_AsGML(3,'MULTIPOLYGON EMPTY'::geometry);
SELECT 'T3.11', ST_AsGML(3,'MULTILINESTRING EMPTY'::geometry);
SELECT 'T3.12', ST_AsGML(3,'GEOMETRYCOLLECTION EMPTY'::geometry);
SELECT 'T3.13', ST_AsGML(3,'POINT EMPTY'::geometry);
SELECT 'T3.14', ST_AsGML(3,'LINESTRING EMPTY'::geometry);
SELECT 'T3.15', ST_AsGML(3,'POLYGON EMPTY'::geometry);
SELECT 'T3.16', ST_AsGML(3,'MULTIPOLYGON EMPTY'::geometry);
SELECT 'T3.17', ST_AsGML(3,'MULTILINESTRING EMPTY'::geometry);
SELECT 'T3.18', ST_AsGML(3,'GEOMETRYCOLLECTION EMPTY'::geometry);
-- See http://trac.osgeo.org/postgis/wiki/DevWikiEmptyGeometry
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry,
120 as tolerance
) SELECT 'ST_Buffer(empty, tolerance) == empty', ST_IsEmpty(ST_Buffer(empty, tolerance)) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Union(geometry, empty) == geometry', ST_Equals(ST_ExteriorRing(ST_Union(geometry, empty)), 'LINESTRING(0 0, 10 0, 5 5, 0 0)'::geometry) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty
) SELECT 'ST_Union(empty, empty) == empty', ST_IsEmpty(ST_Union(empty, empty)) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Intersection(geometry, empty) == geometry', ST_IsEmpty(ST_Intersection(geometry, empty)) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty
) SELECT 'ST_Intersection(empty, empty) == empty', ST_IsEmpty(ST_Intersection(empty, empty)) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Difference(geometry, empty) == geometry', ST_Equals(ST_ExteriorRing(ST_Difference(geometry, empty)), 'LINESTRING(0 0, 10 0, 5 5, 0 0)'::geometry) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Difference(empty, geometry) == empty', ST_IsEmpty(ST_Difference(empty, geometry)) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Distance(geometry, empty) == NULL', ST_Distance(geometry, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry,
120 as tolerance
) SELECT 'ST_DWithin(geometry, empty, tolerance) == FALSE', ST_DWithin(geometry, empty, tolerance) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Within(geometry, empty) == FALSE', ST_Within(geometry, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Contains(empty, geometry) == FALSE', ST_Contains(empty, geometry) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Within(empty, geometry) == FALSE', ST_Within(empty, geometry) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty
) SELECT 'ST_Contains(empty, empty) == FALSE', ST_Contains(empty, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Intersects(geometry, empty) == FALSE', ST_Intersects(geometry, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty
) SELECT 'ST_Intersects(empty, empty) == FALSE', ST_Intersects(empty, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Disjoint(empty, empty) == TRUE', ST_Disjoint(empty, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty,
'POLYGON((0 0, 10 0, 5 5, 0 0))'::geometry as geometry
) SELECT 'ST_Disjoint(geometry, empty) == TRUE', ST_Disjoint(geometry, empty) FROM inp;
WITH inp AS (SELECT
'POLYGON EMPTY'::geometry as empty1,
'POINT Z EMPTY'::geometry as empty2
) SELECT 'ST_Equals(empty1, empty2) == TRUE', ST_Equals(empty1, empty2) FROM inp;
WITH inp AS (SELECT