[postgis-tickets] r17092 - SFCGAL: remove ST_Area SFCGAL implementation

Darafei komzpa at gmail.com
Fri Nov 30 09:25:51 PST 2018


Author: komzpa
Date: 2018-11-30 09:25:51 -0800 (Fri, 30 Nov 2018)
New Revision: 17092

Modified:
   trunk/NEWS
   trunk/doc/reference_measure.xml
   trunk/postgis/legacy.sql.in
   trunk/postgis/lwgeom_backend_api.c
   trunk/postgis/lwgeom_functions_basic.c
   trunk/postgis/lwgeom_sfcgal.c
   trunk/postgis/lwgeom_sfcgal.h
   trunk/postgis/postgis.sql.in
   trunk/postgis/postgis_legacy.c
Log:
SFCGAL: remove ST_Area SFCGAL implementation

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


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/NEWS	2018-11-30 17:25:51 UTC (rev 17092)
@@ -46,6 +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)
 
 PostGIS 2.5.0
 2018/09/23

Modified: trunk/doc/reference_measure.xml
===================================================================
--- trunk/doc/reference_measure.xml	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/doc/reference_measure.xml	2018-11-30 17:25:51 UTC (rev 17092)
@@ -675,12 +675,12 @@
 		  </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 >= 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 @@
 				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>
+<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>
 
-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>
-
 <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>
 

Modified: trunk/postgis/legacy.sql.in
===================================================================
--- trunk/postgis/legacy.sql.in	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/legacy.sql.in	2018-11-30 17:25:51 UTC (rev 17092)
@@ -560,7 +560,7 @@
 -- 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 @@
 -- 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

Modified: trunk/postgis/lwgeom_backend_api.c
===================================================================
--- trunk/postgis/lwgeom_backend_api.c	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/lwgeom_backend_api.c	2018-11-30 17:25:51 UTC (rev 17092)
@@ -57,7 +57,6 @@
     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 @@
       .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 @@
       .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 @@
     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)
 {

Modified: trunk/postgis/lwgeom_functions_basic.c
===================================================================
--- trunk/postgis/lwgeom_functions_basic.c	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/lwgeom_functions_basic.c	2018-11-30 17:25:51 UTC (rev 17092)
@@ -44,7 +44,7 @@
 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 @@
  * 		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);

Modified: trunk/postgis/lwgeom_sfcgal.c
===================================================================
--- trunk/postgis/lwgeom_sfcgal.c	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/lwgeom_sfcgal.c	2018-11-30 17:25:51 UTC (rev 17092)
@@ -38,7 +38,6 @@
 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 @@
 }
 
 
-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)
     {

Modified: trunk/postgis/lwgeom_sfcgal.h
===================================================================
--- trunk/postgis/lwgeom_sfcgal.h	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/lwgeom_sfcgal.h	2018-11-30 17:25:51 UTC (rev 17092)
@@ -46,7 +46,6 @@
 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);

Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/postgis.sql.in	2018-11-30 17:25:51 UTC (rev 17092)
@@ -1278,9 +1278,9 @@
 
 -- 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;
 
@@ -1287,7 +1287,7 @@
 -- 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;
 

Modified: trunk/postgis/postgis_legacy.c
===================================================================
--- trunk/postgis/postgis_legacy.c	2018-11-30 17:01:32 UTC (rev 17091)
+++ trunk/postgis/postgis_legacy.c	2018-11-30 17:25:51 UTC (rev 17092)
@@ -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);



More information about the postgis-tickets mailing list