]> granicus.if.org Git - postgis/commitdiff
Remove SFCGAL ST_Distance
authorDarafei Praliaskouski <me@komzpa.net>
Sat, 1 Dec 2018 21:22:42 +0000 (21:22 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Sat, 1 Dec 2018 21:22:42 +0000 (21:22 +0000)
References #4258
Closes https://github.com/postgis/postgis/pull/347

git-svn-id: http://svn.osgeo.org/postgis/trunk@17094 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_measure.xml
liblwgeom/measures.c
postgis/legacy.sql.in
postgis/lwgeom_backend_api.c
postgis/lwgeom_functions_basic.c
postgis/lwgeom_sfcgal.c
postgis/postgis.sql.in
postgis/postgis_legacy.c
regress/sfcgal/empty_expected
regress/sfcgal/tickets_expected

diff --git a/NEWS b/NEWS
index 8369c27f59ab57d678386957f57134fa1a62e7cc..d5d9b3894ad5ad2f8f8ce8964bfd47d1cf0bbf06 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,7 +46,7 @@ PostGIS 3.0.0
   - #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
index 1d08ac531d047fe454b3124cb7b4a08eea677741..277dde9027c507fb635be2033fcf6753a9fd882b 100644 (file)
@@ -2454,71 +2454,69 @@ SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
                <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 &gt;= 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)
                );
 
 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 @@ FROM (SELECT
 
   spheroid_dist   |   sphere_dist
 ------------------+------------------
- 123.802076746848 | 123.475736916397
-</programlisting>
+ 123.802076746848 | 123.475736916397</programlisting>
        </refsection>
-
-
-
          <refsection>
                <title>See Also</title>
 
index 1349d4ea76d7fca94ccecc71a780ebe098f73f90..4ab435d45460b5d70c08f7abf31674a2783c5f55 100644 (file)
@@ -201,7 +201,6 @@ lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tole
 double
 lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
 {
-       LWDEBUG(2, "lwgeom_mindistance2d is called");
        return lwgeom_mindistance2d_tolerance( lw1, lw2, 0.0 );
 }
 
index 900c18895db37b0b75d267bc988fbd2e729190c9..be54571208024c064412fac9edd9fb51b85733b0 100644 (file)
@@ -766,7 +766,7 @@ CREATE OR REPLACE FUNCTION crosses(geometry,geometry)
 -- 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;
 
index 716cd3a2fa5f02d5b96a515d4849eb7a340048a4..7f3844d2c52f272798b084282da4e60cd5f09b9b 100644 (file)
@@ -71,7 +71,6 @@ struct lwgeom_backend_definition lwgeom_backends[LWGEOM_NUM_BACKENDS] = {{.name
                                                                          .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 @@ struct lwgeom_backend_definition lwgeom_backends[LWGEOM_NUM_BACKENDS] = {{.name
                                                                          .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 @@ Datum geomunion(PG_FUNCTION_ARGS)
        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 @@ Datum intersects3d(PG_FUNCTION_ARGS)
 }
 
 /* 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)
 {
index 73341347e78b0b54ddf1ee707191e8600482152e..cf192beac928fa04c7aa684336da205ada4cda72 100644 (file)
@@ -59,7 +59,7 @@ Datum LWGEOM_perimeter2d_poly(PG_FUNCTION_ARGS);
 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 @@ Datum LWGEOM_longestline2d(PG_FUNCTION_ARGS)
 /**
  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 @@ Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS)
        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 @@ Datum optimistic_overlap(PG_FUNCTION_ARGS)
         * 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);
 }
index bb23dc0c56cb1844b565f4bbb410eb7498fda8f5..9b738806651ab6ac96314d45d6ff517771c11b15 100644 (file)
@@ -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 @@ Datum sfcgal_intersects3D(PG_FUNCTION_ARGS)
        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)
 {
index 2669ca03aa3b5fa2d9c7dcc9d7981d5b18f39e24..cca221989d820c63ebaf4e82980eb5c45a8dbf14 100644 (file)
@@ -579,16 +579,16 @@ CREATE OPERATOR ~= (
 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;
 
 -- 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 @@ CREATE OR REPLACE FUNCTION ST_distance_spheroid(geom1 geometry, geom2 geometry,s
   $$
        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
 
index 369f391ab61fa0f7e1c4bd66d66de3049b0c0b62..f13a38f91c997872ce1ff8443e2a33fad39da8d9 100644 (file)
@@ -53,3 +53,5 @@ POSTGIS_DEPRECATE("2.5.0", pgis_abs_in);
 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);
index 866824a2308dabca20f0f91094b24f7706f11ce0..9e67a2eacbe909c88bc97b299634d45d1919e090 100644 (file)
@@ -30,7 +30,7 @@ ST_Intersection(geometry, empty) == geometry|t
 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
index b3083bbe642054b94277d563ae59058b09bf0bcb..b373c2913cf2f5f4ea5422e0d5133b7515332d9f 100644 (file)
@@ -15,7 +15,7 @@ ERROR:  lwgeom_longitude_shift: unsupported geom type: CircularString
 #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