]> granicus.if.org Git - postgis/commitdiff
SFCGAL: remove ST_Area SFCGAL implementation
authorDarafei Praliaskouski <me@komzpa.net>
Fri, 30 Nov 2018 17:25:51 +0000 (17:25 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 30 Nov 2018 17:25:51 +0000 (17:25 +0000)
References #4258
Closes https://github.com/postgis/postgis/pull/345

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

NEWS
doc/reference_measure.xml
postgis/legacy.sql.in
postgis/lwgeom_backend_api.c
postgis/lwgeom_functions_basic.c
postgis/lwgeom_sfcgal.c
postgis/lwgeom_sfcgal.h
postgis/postgis.sql.in
postgis/postgis_legacy.c

diff --git a/NEWS b/NEWS
index 02e42e8ae8b0fe65381ad793488604c682cd6141..8369c27f59ab57d678386957f57134fa1a62e7cc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +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)
 
 PostGIS 2.5.0
 2018/09/23
index 7a1c9be8173971a64f23a82a083e8483c6f96f0d..1d08ac531d047fe454b3124cb7b4a08eea677741 100644 (file)
@@ -675,12 +675,12 @@ SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
                  </para>
                        <para>Enhanced: 2.0.0 - support for 2D polyhedral surfaces 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>
                        <para>&sfs_compliant;</para>
                        <para>&sqlmm_compliant; SQL-MM 3: 8.1.2, 9.5.3</para>
                        <para>&P_support;</para>
                        <note><para>For polyhedral surfaces, only supports 2D polyhedral surfaces (not 2.5D).  For 2.5D, may give a non-zero answer, but only for the faces that
                        sit completely in XY plane.</para></note>
-                        <para>&sfcgal_enhanced;</para>
                </refsection>
 
                  <refsection>
@@ -689,54 +689,65 @@ SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
                                Note this is in square feet because EPSG:2249 is
                                Massachusetts State Plane Feet </para>
                        <programlisting>
-SELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqm
-               FROM (SELECT
-               ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
-                       743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom);
-  sqft   |     sqm
----------+-------------
- 928.625 | 86.27208552
+select ST_Area(geom) sqft,
+    ST_Area(geom) * 0.3048 ^ 2 sqm
+from (
+         select 'SRID=2249;POLYGON((743238 2967416,743238 2967450,
+                                743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
+     ) subquery;
+┌─────────┬─────────────┐
+│  sqft   │     sqm     │
+├─────────┼─────────────┤
+│ 928.625 │ 86.27208552 │
+└─────────┴─────────────┘
 </programlisting>
 <para>Return area square feet and transform to Massachusetts state plane meters (EPSG:26986) to get square meters.
                                Note this is in square feet because 2249 is
                                Massachusetts State Plane Feet and transformed area is in square meters since EPSG:26986 is state plane Massachusetts meters </para>
-<programlisting>
-
-SELECT ST_Area(the_geom) As sqft, ST_Area(ST_Transform(the_geom,26986)) As sqm
-               FROM (SELECT
-               ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
-                       743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom);
-  sqft   |       sqm
----------+------------------
- 928.625 | 86.2724304199219
-                       </programlisting>
+<programlisting>select ST_Area(geom) sqft,
+    ST_Area(ST_Transform(geom, 26986)) As sqm
+from (
+         select
+             'SRID=2249;POLYGON((743238 2967416,743238 2967450,
+             743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
+     ) subquery;
+┌─────────┬─────────────────┐
+│  sqft   │       sqm       │
+├─────────┼─────────────────┤
+│ 928.625 │ 86.272430607008 │
+└─────────┴─────────────────┘
+</programlisting>
 
 <para>Return area square feet and square meters using geography data type.  Note that we transform to our geometry to geography
        (before you can do that make sure your geometry is in WGS 84 long lat 4326).  Geography always measures in meters.
        This is just for demonstration to compare.  Normally your table will be stored in geography data type already.</para>
 <programlisting>
 
-SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft_spheroid,  ST_Area(the_geog,false)/POWER(0.3048,2) As sqft_sphere, ST_Area(the_geog) As sqm_spheroid
-               FROM (SELECT
-               geography(
-               ST_Transform(
-                       ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))',
-                               2249
-                               ) ,4326
-                       )
-               )
-       ) As foo(the_geog);
-  sqft_spheroid   |   sqft_sphere    |   sqm_spheroid
-------------------+------------------+------------------
- 928.684403538925 | 927.049336105925 | 86.2776042893529
+select ST_Area(geog) / 0.3048 ^ 2 sqft_spheroid,
+    ST_Area(geog, false) / 0.3048 ^ 2 sqft_sphere,
+    ST_Area(geog) sqm_spheroid
+from (
+         select ST_Transform(
+                    'SRID=2249;POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))'::geometry,
+                    4326
+             ) :: geography geog
+     ) as subquery;
+┌──────────────────┬──────────────────┬──────────────────┐
+│  sqft_spheroid   │   sqft_sphere    │   sqm_spheroid   │
+├──────────────────┼──────────────────┼──────────────────┤
+│ 928.684405784452 │ 927.049336105925 │ 86.2776044979692 │
+└──────────────────┴──────────────────┴──────────────────┘
+</programlisting>
 
- --if your data is in geography already
- SELECT ST_Area(the_geog)/POWER(0.3048,2) As  sqft, ST_Area(the_geog) As sqm
-       FROM somegeogtable;</programlisting>
+ <para>If your data is in geography already:</para>
+ <programlisting>
+select ST_Area(geog) / 0.3048 ^ 2 sqft,
+    ST_Area(the_geog) sqm
+from somegeogtable;</programlisting>
                  </refsection>
                <refsection>
                        <title>See Also</title>
-                       <para><xref linkend="ST_GeomFromText" />, <xref linkend="ST_GeographyFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
+                       <para><xref linkend="ST_3DArea" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_GeographyFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
                </refsection>
        </refentry>
 
index b7498120e234770484a808c5c39e352194c46ba4..900c18895db37b0b75d267bc988fbd2e729190c9 100644 (file)
@@ -560,7 +560,7 @@ CREATE OR REPLACE FUNCTION AddPoint(geometry, geometry, integer)
 -- Deprecation in 1.2.3
 CREATE OR REPLACE FUNCTION Area(geometry)
        RETURNS FLOAT8
-       AS 'MODULE_PATHNAME','LWGEOM_area_polygon'
+       AS 'MODULE_PATHNAME','ST_Area'
        LANGUAGE 'c' IMMUTABLE STRICT;
 
 -- this is an alias for 'area(geometry)'
@@ -568,7 +568,7 @@ CREATE OR REPLACE FUNCTION Area(geometry)
 -- Deprecation in 1.2.3
 CREATE OR REPLACE FUNCTION Area2D(geometry)
        RETURNS FLOAT8
-       AS 'MODULE_PATHNAME', 'LWGEOM_area_polygon'
+       AS 'MODULE_PATHNAME', 'ST_Area'
        LANGUAGE 'c' IMMUTABLE STRICT;
 
 -- Deprecation in 1.2.3
index a9c1fe39f89bc72c295a34ac79b764c729587d25..82e69bd519dc79645561b82ed16c0b0ec9840dc3 100644 (file)
@@ -57,7 +57,6 @@ struct lwgeom_backend_definition
     Datum (*intersection_fn)  (PG_FUNCTION_ARGS);
     Datum (*difference_fn)    (PG_FUNCTION_ARGS);
     Datum (*union_fn)         (PG_FUNCTION_ARGS);
-    Datum (*area_fn)          (PG_FUNCTION_ARGS);
     Datum (*distance_fn)      (PG_FUNCTION_ARGS);
     Datum (*distance3d_fn)    (PG_FUNCTION_ARGS);
 };
@@ -75,7 +74,6 @@ struct lwgeom_backend_definition lwgeom_backends[LWGEOM_NUM_BACKENDS] = {
       .intersection_fn  = geos_intersection,
       .difference_fn    = geos_difference,
       .union_fn         = geos_geomunion,
-      .area_fn          = LWGEOM_area_polygon,
       .distance_fn      = LWGEOM_mindistance2d,
       .distance3d_fn    = LWGEOM_mindistance3d
     },
@@ -86,7 +84,6 @@ struct lwgeom_backend_definition lwgeom_backends[LWGEOM_NUM_BACKENDS] = {
       .intersection_fn  = sfcgal_intersection,
       .difference_fn    = sfcgal_difference,
       .union_fn         = sfcgal_union,
-      .area_fn          = sfcgal_area,
       .distance_fn      = sfcgal_distance,
       .distance3d_fn    = sfcgal_distance3D
     }
@@ -189,12 +186,6 @@ Datum geomunion(PG_FUNCTION_ARGS)
     return (*lwgeom_backend->union_fn)( fcinfo );
 }
 
-PG_FUNCTION_INFO_V1(area);
-Datum area(PG_FUNCTION_ARGS)
-{
-    return (*lwgeom_backend->area_fn)( fcinfo );
-}
-
 PG_FUNCTION_INFO_V1(distance);
 Datum distance(PG_FUNCTION_ARGS)
 {
index 98ce3ed4bdc75e3a4c3aeab4a1bd9651f61d9e65..4d2be7ceb039b056fc360320b7fef318c1dd0e83 100644 (file)
@@ -44,7 +44,7 @@ Datum LWGEOM_mem_size(PG_FUNCTION_ARGS);
 Datum LWGEOM_summary(PG_FUNCTION_ARGS);
 Datum LWGEOM_npoints(PG_FUNCTION_ARGS);
 Datum LWGEOM_nrings(PG_FUNCTION_ARGS);
-Datum LWGEOM_area_polygon(PG_FUNCTION_ARGS);
+Datum ST_Area(PG_FUNCTION_ARGS);
 Datum postgis_uses_stats(PG_FUNCTION_ARGS);
 Datum postgis_autocache_bbox(PG_FUNCTION_ARGS);
 Datum postgis_scripts_released(PG_FUNCTION_ARGS);
@@ -269,15 +269,13 @@ Datum LWGEOM_nrings(PG_FUNCTION_ARGS)
  *             area (line) = 0
  *             area(polygon) = find its 2d area
  */
-PG_FUNCTION_INFO_V1(LWGEOM_area_polygon);
-Datum LWGEOM_area_polygon(PG_FUNCTION_ARGS)
+PG_FUNCTION_INFO_V1(ST_Area);
+Datum ST_Area(PG_FUNCTION_ARGS)
 {
        GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
        LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
        double area = 0.0;
 
-       POSTGIS_DEBUG(2, "in LWGEOM_area_polygon");
-
        area = lwgeom_area(lwgeom);
 
        lwgeom_free(lwgeom);
index 5660486d7da9c37c04244675fbb39cbe8db5dcad..2b28e3fa041bfa4657a6a50086d7295f732d1247 100644 (file)
@@ -38,7 +38,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_area(PG_FUNCTION_ARGS);
 Datum sfcgal_area3D(PG_FUNCTION_ARGS);
 Datum sfcgal_intersects(PG_FUNCTION_ARGS);
 Datum sfcgal_intersects3D(PG_FUNCTION_ARGS);
@@ -156,27 +155,6 @@ Datum sfcgal_from_ewkt(PG_FUNCTION_ARGS)
 }
 
 
-PG_FUNCTION_INFO_V1(sfcgal_area);
-Datum sfcgal_area(PG_FUNCTION_ARGS)
-    {
-       GSERIALIZED *input;
-       sfcgal_geometry_t *geom;
-       double result;
-
-       sfcgal_postgis_init();
-
-       input = PG_GETARG_GSERIALIZED_P(0);
-       geom = POSTGIS2SFCGALGeometry(input);
-
-       result = sfcgal_geometry_area(geom);
-       sfcgal_geometry_delete(geom);
-
-       PG_FREE_IF_COPY(input, 0);
-
-       PG_RETURN_FLOAT8(result);
-}
-
-
 PG_FUNCTION_INFO_V1(sfcgal_area3D);
 Datum sfcgal_area3D(PG_FUNCTION_ARGS)
     {
index c350ba65f08053cf814f8b145ac54b50601c2f36..16e6988bde2fc9267097c10c6b6cca8231a6fa41 100644 (file)
@@ -46,7 +46,6 @@ Datum sfcgal_union3D(PG_FUNCTION_ARGS);
 Datum sfcgal_union(PG_FUNCTION_ARGS);
 Datum sfcgal_volume(PG_FUNCTION_ARGS);
 Datum sfcgal_triangulate(PG_FUNCTION_ARGS);
-Datum sfcgal_area(PG_FUNCTION_ARGS);
 Datum sfcgal_distance(PG_FUNCTION_ARGS);
 Datum sfcgal_distance3D(PG_FUNCTION_ARGS);
 Datum sfcgal_make_solid(PG_FUNCTION_ARGS);
index 3a88787c994f243afaf5f48f65fb24af25a0435a..2669ca03aa3b5fa2d9c7dcc9d7981d5b18f39e24 100644 (file)
@@ -1278,16 +1278,16 @@ CREATE OR REPLACE FUNCTION ST_Perimeter(geometry)
 
 -- Availability: 1.2.2
 -- Deprecation in 1.3.4
-CREATE OR REPLACE FUNCTION ST_area2d(geometry)
+CREATE OR REPLACE FUNCTION ST_Area2D(geometry)
        RETURNS FLOAT8
-       AS 'MODULE_PATHNAME', 'LWGEOM_area_polygon'
+       AS 'MODULE_PATHNAME', 'ST_Area'
        LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
        COST 10;
 
 -- PostGIS equivalent function: area(geometry)
 CREATE OR REPLACE FUNCTION ST_Area(geometry)
        RETURNS FLOAT8
-       AS 'MODULE_PATHNAME','area'
+       AS 'MODULE_PATHNAME','ST_Area'
        LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
        COST 10;
 
index dbfbee2e28bf1179fefcba3e33cfa1b2a770fc88..369f391ab61fa0f7e1c4bd66d66de3049b0c0b62 100644 (file)
@@ -51,3 +51,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);