[postgis-tickets] r17094 - Remove SFCGAL ST_Distance

Darafei komzpa at gmail.com
Sat Dec 1 01:22:42 PST 2018


Author: komzpa
Date: 2018-12-01 13:22:42 -0800 (Sat, 01 Dec 2018)
New Revision: 17094

Modified:
   trunk/NEWS
   trunk/doc/reference_measure.xml
   trunk/liblwgeom/measures.c
   trunk/postgis/legacy.sql.in
   trunk/postgis/lwgeom_backend_api.c
   trunk/postgis/lwgeom_functions_basic.c
   trunk/postgis/lwgeom_sfcgal.c
   trunk/postgis/postgis.sql.in
   trunk/postgis/postgis_legacy.c
   trunk/regress/sfcgal/empty_expected
   trunk/regress/sfcgal/tickets_expected
Log:
Remove SFCGAL ST_Distance

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


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/NEWS	2018-12-01 21:22:42 UTC (rev 17094)
@@ -46,7 +46,7 @@
   - #4139, Make mixed-dimension ND index build tree correctly (Darafei Praliaskouski,
            Arthur Lesuisse, Andrew Gierth, Raúl Marín)
   - #4262, Document MULTISURFACE compatibility of ST_LineToCurve (Steven Ottens)
-  - #4258, Remove SFCGAL support for ST_Area (Darafei Praliaskouski)
+  - #4258, Remove SFCGAL support for ST_Area, ST_Distance (Darafei Praliaskouski)
 
 PostGIS 2.5.0
 2018/09/23

Modified: trunk/doc/reference_measure.xml
===================================================================
--- trunk/doc/reference_measure.xml	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/doc/reference_measure.xml	2018-12-01 21:22:42 UTC (rev 17094)
@@ -2454,58 +2454,57 @@
 		<para>&sfs_compliant;</para>
 		<para>&sqlmm_compliant; SQL-MM 3: 5.1.23</para>
 		<para>&curve_support;</para>
-		<para>&sfcgal_enhanced;</para>
 
 		<para>Availability: 1.5.0 geography support was introduced in 1.5.  Speed improvements for planar to better handle large or many vertex geometries</para>
 		<para>Enhanced: 2.1.0 improved speed for geography. See <ulink url="http://boundlessgeo.com/2012/07/making-geography-faster/">Making Geography faster</ulink> for details.</para>
 		<para>Enhanced: 2.1.0 - support for curved geometries was introduced.</para>
 		<para>Enhanced: 2.2.0 - measurement on spheroid performed with GeographicLib for improved accuracy and robustness. Requires Proj >= 4.9.0 to take advantage of the new feature.</para>
+		<para>Changed: 3.0.0 - does not depend on SFCGAL anymore.</para>
 	  </refsection>
 
 	  <refsection>
 		<title>Basic Geometry Examples</title>
 
-		<programlisting>
---Geometry example - units in planar degrees 4326 is WGS 84 long lat unit=degrees
-SELECT ST_Distance(
+		<para>Geometry example - units in planar degrees 4326 is WGS 84 long lat, units are degrees.</para>
+		<programlisting>SELECT ST_Distance(
 		'SRID=4326;POINT(-72.1235 42.3521)'::geometry,
 		'SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry
 	);
 st_distance
 -----------------
-0.00150567726382282
+0.00150567726382282</programlisting>
 
--- Geometry example - units in meters (SRID: 3857, proportional to pixels on popular web maps)
--- although the value is off, nearby ones can be compared correctly,
--- which makes it a good choice for algorithms like KNN or KMeans.
-SELECT ST_Distance(
+<para>Geometry example - units in meters (SRID: 3857, proportional to pixels on popular web maps).
+Although the value is off, nearby ones can be compared correctly,
+which makes it a good choice for algorithms like KNN or KMeans.</para>
+<programlisting>SELECT ST_Distance(
 			ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 3857),
 			ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 3857)
 		);
 st_distance
 -----------------
-167.441410065196
+167.441410065196</programlisting>
 
--- Geometry example - units in meters (SRID: 3857 as above, but corrected by cos(lat) to account for distortion)
-SELECT ST_Distance(
+<para>Geometry example - units in meters (SRID: 3857 as above, but corrected by cos(lat) to account for distortion)</para>
+<programlisting>SELECT ST_Distance(
 			ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 3857),
 			ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 3857)
 		) * cosd(42.3521);
 st_distance
 -----------------
-123.742351254151
+123.742351254151</programlisting>
 
--- Geometry example - units in meters (SRID: 26986 Massachusetts state plane meters) (most accurate for Massachusetts)
-SELECT ST_Distance(
+<para>Geometry example - units in meters (SRID: 26986 Massachusetts state plane meters) (most accurate for Massachusetts)</para>
+<programlisting>SELECT ST_Distance(
 			ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 26986),
 			ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 26986)
 		);
 st_distance
 -----------------
-123.797937878454
+123.797937878454</programlisting>
 
--- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (least accurate)
-SELECT ST_Distance(
+<para>Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (least accurate) </para>
+<programlisting>SELECT ST_Distance(
 			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)
 		);
@@ -2512,13 +2511,12 @@
 
 st_distance
 ------------------
-126.664256056812
-</programlisting>
+126.664256056812</programlisting>
 	</refsection>
 	  <refsection>
 		<title>Geography Examples</title>
-<programlisting>-- same as geometry example but note units in meters - use sphere for slightly faster less accurate
-SELECT ST_Distance(gg1, gg2) As spheroid_dist, ST_Distance(gg1, gg2, false) As sphere_dist
+<para>Same as geometry example but note units in meters - use sphere for slightly faster and less accurate computation.</para>
+<programlisting>SELECT ST_Distance(gg1, gg2) As spheroid_dist, ST_Distance(gg1, gg2, false) As sphere_dist
 FROM (SELECT
 	'SRID=4326;POINT(-72.1235 42.3521)'::geography as gg1,
 	'SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geography as gg2
@@ -2526,12 +2524,8 @@
 
   spheroid_dist   |   sphere_dist
 ------------------+------------------
- 123.802076746848 | 123.475736916397
-</programlisting>
+ 123.802076746848 | 123.475736916397</programlisting>
 	</refsection>
-
-
-
 	  <refsection>
 		<title>See Also</title>
 

Modified: trunk/liblwgeom/measures.c
===================================================================
--- trunk/liblwgeom/measures.c	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/liblwgeom/measures.c	2018-12-01 21:22:42 UTC (rev 17094)
@@ -201,7 +201,6 @@
 double
 lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
 {
-	LWDEBUG(2, "lwgeom_mindistance2d is called");
 	return lwgeom_mindistance2d_tolerance( lw1, lw2, 0.0 );
 }
 

Modified: trunk/postgis/legacy.sql.in
===================================================================
--- trunk/postgis/legacy.sql.in	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/legacy.sql.in	2018-12-01 21:22:42 UTC (rev 17094)
@@ -766,7 +766,7 @@
 -- Deprecation in 1.2.3
 CREATE OR REPLACE FUNCTION distance(geometry,geometry)
 	RETURNS float8
-	AS 'MODULE_PATHNAME', 'LWGEOM_mindistance2d'
+	AS 'MODULE_PATHNAME', 'ST_Distance'
 	LANGUAGE 'c' IMMUTABLE STRICT
 	COST 100;
 

Modified: trunk/postgis/lwgeom_backend_api.c
===================================================================
--- trunk/postgis/lwgeom_backend_api.c	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/lwgeom_backend_api.c	2018-12-01 21:22:42 UTC (rev 17094)
@@ -71,7 +71,6 @@
 									  .intersection_fn = geos_intersection,
 									  .difference_fn = geos_difference,
 									  .union_fn = geos_geomunion,
-									  .distance_fn = LWGEOM_mindistance2d,
 									  .distance3d_fn = LWGEOM_mindistance3d},
 #if HAVE_SFCGAL
 									 {.name = "sfcgal",
@@ -80,7 +79,6 @@
 									  .intersection_fn = sfcgal_intersection,
 									  .difference_fn = sfcgal_difference,
 									  .union_fn = sfcgal_union,
-									  .distance_fn = sfcgal_distance,
 									  .distance3d_fn = sfcgal_distance3D}
 #endif
 };
@@ -185,12 +183,6 @@
 	return (*lwgeom_backend->union_fn)(fcinfo);
 }
 
-PG_FUNCTION_INFO_V1(distance);
-Datum distance(PG_FUNCTION_ARGS)
-{
-	return (*lwgeom_backend->distance_fn)(fcinfo);
-}
-
 PG_FUNCTION_INFO_V1(distance3d);
 Datum distance3d(PG_FUNCTION_ARGS)
 {
@@ -204,8 +196,7 @@
 }
 
 /* intersects3d through dwithin
- * used by the 'geos' backend
- */
+ * used by the 'geos' backend */
 PG_FUNCTION_INFO_V1(intersects3d_dwithin);
 Datum intersects3d_dwithin(PG_FUNCTION_ARGS)
 {

Modified: trunk/postgis/lwgeom_functions_basic.c
===================================================================
--- trunk/postgis/lwgeom_functions_basic.c	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/lwgeom_functions_basic.c	2018-12-01 21:22:42 UTC (rev 17094)
@@ -59,7 +59,7 @@
 Datum LWGEOM_perimeter_poly(PG_FUNCTION_ARGS);
 
 Datum LWGEOM_maxdistance2d_linestring(PG_FUNCTION_ARGS);
-Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS);
+Datum ST_Distance(PG_FUNCTION_ARGS);
 Datum LWGEOM_closestpoint(PG_FUNCTION_ARGS);
 Datum LWGEOM_shortestline2d(PG_FUNCTION_ARGS);
 Datum LWGEOM_longestline2d(PG_FUNCTION_ARGS);
@@ -690,8 +690,8 @@
 /**
  Minimum 2d distance between objects in geom1 and geom2.
  */
-PG_FUNCTION_INFO_V1(LWGEOM_mindistance2d);
-Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS)
+PG_FUNCTION_INFO_V1(ST_Distance);
+Datum ST_Distance(PG_FUNCTION_ARGS)
 {
 	double mindist;
 	GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
@@ -709,7 +709,7 @@
 	PG_FREE_IF_COPY(geom1, 0);
 	PG_FREE_IF_COPY(geom2, 1);
 
-	/*if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
+	/* if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
 	if (mindist < FLT_MAX)
 		PG_RETURN_FLOAT8(mindist);
 
@@ -2593,8 +2593,8 @@
 	 * compute distances
 	 * should be a fast calc if they actually do intersect
 	 */
-	calc_dist = DatumGetFloat8(
-	    DirectFunctionCall2(LWGEOM_mindistance2d, PointerGetDatum(pg_geom1), PointerGetDatum(pg_geom2)));
+	calc_dist =
+	    DatumGetFloat8(DirectFunctionCall2(ST_Distance, PointerGetDatum(pg_geom1), PointerGetDatum(pg_geom2)));
 
 	PG_RETURN_BOOL(calc_dist < dist);
 }

Modified: trunk/postgis/lwgeom_sfcgal.c
===================================================================
--- trunk/postgis/lwgeom_sfcgal.c	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/lwgeom_sfcgal.c	2018-12-01 21:22:42 UTC (rev 17094)
@@ -34,7 +34,6 @@
 Datum postgis_sfcgal_version(PG_FUNCTION_ARGS);
 
 Datum sfcgal_from_ewkt(PG_FUNCTION_ARGS);
-Datum sfcgal_distance(PG_FUNCTION_ARGS);
 Datum sfcgal_distance3D(PG_FUNCTION_ARGS);
 Datum sfcgal_area3D(PG_FUNCTION_ARGS);
 Datum sfcgal_intersects(PG_FUNCTION_ARGS);
@@ -258,29 +257,6 @@
 	PG_RETURN_BOOL(result);
 }
 
-PG_FUNCTION_INFO_V1(sfcgal_distance);
-Datum sfcgal_distance(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(geom0, geom1);
-	sfcgal_geometry_delete(geom0);
-	sfcgal_geometry_delete(geom1);
-
-	PG_RETURN_FLOAT8(result);
-}
-
 PG_FUNCTION_INFO_V1(sfcgal_distance3D);
 Datum sfcgal_distance3D(PG_FUNCTION_ARGS)
 {

Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/postgis.sql.in	2018-12-01 21:22:42 UTC (rev 17094)
@@ -579,9 +579,9 @@
 CREATE OR REPLACE FUNCTION geometry_distance_centroid(geom1 geometry, geom2 geometry)
 	RETURNS float8
 #if POSTGIS_PGSQL_VERSION >= 95
-  AS 'MODULE_PATHNAME' ,'distance'
+	AS 'MODULE_PATHNAME', 'ST_Distance'
 #else
-  AS 'MODULE_PATHNAME' ,'gserialized_distance_centroid_2d'
+	AS 'MODULE_PATHNAME', 'gserialized_distance_centroid_2d'
 #endif
 	LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
 
@@ -588,7 +588,7 @@
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION geometry_distance_box(geom1 geometry, geom2 geometry)
 	RETURNS float8
-  AS 'MODULE_PATHNAME' ,'gserialized_distance_box_2d'
+  AS 'MODULE_PATHNAME', 'gserialized_distance_box_2d'
 	LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.0
@@ -1321,12 +1321,10 @@
   $$
 	LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
--- Minimum distance. 2d only.
-
--- PostGIS equivalent function: distance(geom1 geometry, geom2 geometry)
+-- Minimum distance. 2D only.
 CREATE OR REPLACE FUNCTION ST_Distance(geom1 geometry, geom2 geometry)
 	RETURNS float8
-	AS 'MODULE_PATHNAME', 'distance'
+	AS 'MODULE_PATHNAME', 'ST_Distance'
 	LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
 	COST 25; --changed from 100 should be 1/5th to 1/10 spheroid
 

Modified: trunk/postgis/postgis_legacy.c
===================================================================
--- trunk/postgis/postgis_legacy.c	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/postgis/postgis_legacy.c	2018-12-01 21:22:42 UTC (rev 17094)
@@ -53,3 +53,5 @@
 POSTGIS_DEPRECATE("2.5.0", pgis_abs_out);
 POSTGIS_DEPRECATE("3.0.0", area);
 POSTGIS_DEPRECATE("3.0.0", LWGEOM_area_polygon);
+POSTGIS_DEPRECATE("3.0.0", distance);
+POSTGIS_DEPRECATE("3.0.0", LWGEOM_mindistance2d);

Modified: trunk/regress/sfcgal/empty_expected
===================================================================
--- trunk/regress/sfcgal/empty_expected	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/regress/sfcgal/empty_expected	2018-12-01 21:22:42 UTC (rev 17094)
@@ -30,7 +30,7 @@
 ST_Intersection(empty, empty) == empty|t
 ST_Difference(geometry, empty) == geometry|t
 ST_Difference(empty, geometry) == empty|t
-ST_Distance(geometry, empty) == NULL|inf
+ST_Distance(geometry, empty) == NULL|
 ST_DWithin(geometry, empty, tolerance) == FALSE|f
 ST_Within(geometry, empty) == FALSE|f
 ST_Contains(empty, geometry) == FALSE|f

Modified: trunk/regress/sfcgal/tickets_expected
===================================================================
--- trunk/regress/sfcgal/tickets_expected	2018-11-30 18:00:34 UTC (rev 17093)
+++ trunk/regress/sfcgal/tickets_expected	2018-12-01 21:22:42 UTC (rev 17094)
@@ -15,7 +15,7 @@
 #73|GEOMETRYCOLLECTION(CIRCULARSTRING(1 1,2 3,4 5,6 7,5 6))
 #80|MULTILINESTRING((0 0,1 1))
 #83|MULTICURVE(CIRCULARSTRING(220268 150415,220227 150505,220227 150406))
-ERROR:  LWGEOM2SFCGAL: Unknown geometry type !
+#85|0
 #112|GEOMETRYCOLLECTION(POINT(-10 50))
 WARNING:  ST_Locate_Between_Measures and ST_Locate_Along_Measure were deprecated in 2.2.0. Please use ST_LocateAlong and ST_LocateBetween
 ERROR:  Geometry argument does not have an 'M' ordinate



More information about the postgis-tickets mailing list