[postgis-tickets] r14873 - #3119, Wrong documented behavior for ST_LengthSpheroid

Daniel Baston dbaston at gmail.com
Sun May 1 09:22:41 PDT 2016


Author: dbaston
Date: 2016-05-01 09:22:41 -0700 (Sun, 01 May 2016)
New Revision: 14873

Modified:
   trunk/doc/reference_measure.xml
   trunk/regress/tickets.sql
   trunk/regress/tickets_expected
Log:
#3119, Wrong documented behavior for ST_LengthSpheroid

Modified: trunk/doc/reference_measure.xml
===================================================================
--- trunk/doc/reference_measure.xml	2016-04-30 19:12:54 UTC (rev 14872)
+++ trunk/doc/reference_measure.xml	2016-05-01 16:22:41 UTC (rev 14873)
@@ -3431,7 +3431,7 @@
 	  <refnamediv>
 		<refname>ST_LengthSpheroid</refname>
 
-		<refpurpose>Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This
+        <refpurpose>Calculates the 2D or 3D length/perimeter of a geometry on an ellipsoid. This
 			is useful if the coordinates of the geometry are in
 			longitude/latitude and a length is desired without reprojection.</refpurpose>
 	  </refnamediv>
@@ -3440,7 +3440,7 @@
 		<funcsynopsis>
 		  <funcprototype>
 			<funcdef>float <function>ST_LengthSpheroid</function></funcdef>
-			<paramdef><type>geometry </type> <parameter>a_linestring</parameter></paramdef>
+			<paramdef><type>geometry </type> <parameter>a_geometry</parameter></paramdef>
 			<paramdef><type>spheroid </type> <parameter>a_spheroid</parameter></paramdef>
 		  </funcprototype>
 		</funcsynopsis>
@@ -3449,25 +3449,21 @@
 	  <refsection>
 		<title>Description</title>
 
-		<para>Calculates the length of a geometry on an ellipsoid. This
+        <para>Calculates the length/perimeter of a geometry on an ellipsoid. This
 			is useful if the coordinates of the geometry are in
 			longitude/latitude and a length is desired without reprojection.
 			The ellipsoid is a separate database type and can be constructed
 			as follows:</para>
 
-		<literallayout>SPHEROID[<NAME>,<SEMI-MAJOR
-		  AXIS>,<INVERSE FLATTENING>]</literallayout>
+		<literallayout>SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]</literallayout>
 
-
 		<literallayout>SPHEROID["GRS_1980",6378137,298.257222101]</literallayout>
-		<note><para>Will return 0 for anything that is not a MULTILINESTRING or LINESTRING</para></note>
 
 		<para>Availability: 1.2.2</para>
 		<para>Changed: 2.2.0 In prior versions this used to be called ST_Length_Spheroid and used to have a ST_3DLength_Spheroid alias</para>
 		<para>&Z_support;</para>
 	  </refsection>
 
-
 	  <refsection>
 		<title>Examples</title>
 
@@ -3512,7 +3508,7 @@
 	  <refnamediv>
 		<refname>ST_Length2D_Spheroid</refname>
 
-		<refpurpose>Calculates the 2D length of a linestring/multilinestring on an ellipsoid. This
+        <refpurpose>Calculates the 2D length/perimeter of a geometry on an ellipsoid. This
 			is useful if the coordinates of the geometry are in
 			longitude/latitude and a length is desired without reprojection.  </refpurpose>
 	  </refnamediv>
@@ -3521,7 +3517,7 @@
 		<funcsynopsis>
 		  <funcprototype>
 			<funcdef>float <function>ST_Length2D_Spheroid</function></funcdef>
-			<paramdef><type>geometry </type> <parameter>a_linestring</parameter></paramdef>
+			<paramdef><type>geometry </type> <parameter>a_geometry</parameter></paramdef>
 			<paramdef><type>spheroid </type> <parameter>a_spheroid</parameter></paramdef>
 		  </funcprototype>
 		</funcsynopsis>
@@ -3530,20 +3526,16 @@
 	  <refsection>
 		<title>Description</title>
 
-		<para>Calculates the 2D length of a geometry on an ellipsoid. This
+        <para>Calculates the 2D length/perimeter of a geometry on an ellipsoid. This
 			is useful if the coordinates of the geometry are in
 			longitude/latitude and a length is desired without reprojection.
 			The ellipsoid is a separate database type and can be constructed
 			as follows:</para>
 
-		<literallayout>SPHEROID[<NAME>,<SEMI-MAJOR
-		  AXIS>,<INVERSE FLATTENING>]</literallayout>
+		<literallayout>SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]</literallayout>
 
-
 		<literallayout>SPHEROID["GRS_1980",6378137,298.257222101]</literallayout>
-		<note><para>Will return 0 for anything that is not a MULTILINESTRING or LINESTRING</para></note>
-		<note><para>This is much like <xref linkend="ST_Length_Spheroid" /> except it will throw away the Z coordinate in calculations.</para></note>
-
+		<note><para>This is much like <xref linkend="ST_Length_Spheroid" /> except it will ignore the Z ordinate in calculations.</para></note>
 	  </refsection>
 
 

Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql	2016-04-30 19:12:54 UTC (rev 14872)
+++ trunk/regress/tickets.sql	2016-05-01 16:22:41 UTC (rev 14873)
@@ -886,6 +886,16 @@
   mbc   AS (SELECT (mb).center, (mb).radius FROM (SELECT ST_MinimumBoundingRadius(geom) mb FROM input) sq)
 SELECT '#2996', radius = ST_Length(ST_LongestLine(geom, center)) FROM input, mbc;
 
+-- #3119 --
+SELECT '#3119a', floor(ST_LengthSpheroid('SRID=4326;LINESTRING (-72.640965 42.11867, -72.6395 42.1187)', 'SPHEROID["GRS_1980",6378137,298.257222101]'));
+-- polygons are also handled
+SELECT '#3119b', floor(ST_LengthSpheroid('SRID=4326;POLYGON ((-72.640965 42.11867, -72.6395 42.1187, -72.64065 42.11819, -72.640965 42.11867))', 'SPHEROID["GRS_1980",6378137,298.257222101]'));
+-- for polygons with holes, all rings are considered
+SELECT '#3119c', floor(ST_LengthSpheroid('SRID=4326;POLYGON ((-72.640965 42.11819, -72.640965 42.1187, -72.6395 42.1187, -72.6395 42.11819, -72.640965 42.11819),
+          (-72.63965 42.118305, -72.64083 42.118305, -72.64083 42.118595, -72.63965 42.118595, -72.63965 42.118305))', 'SPHEROID["GRS_1980",6378137,298.257222101]'));
+-- triangles also work
+SELECT '#3119d', floor(ST_LengthSpheroid('SRID=4326;TRIANGLE ((-72.640965 42.11867, -72.6395 42.1187, -72.64065 42.11819, -72.640965 42.11867))', 'SPHEROID["GRS_1980",6378137,298.257222101]'));
+
 SELECT '#3172', ST_AsText(ST_AddMeasure('LINESTRING(0 0,0 0)', 1, 2));
 
 --SELECT '#3244a', ST_AsText(ST_3DClosestPoint('POINT(0 0 0)', 'POINT(0 0)'));

Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected	2016-04-30 19:12:54 UTC (rev 14872)
+++ trunk/regress/tickets_expected	2016-05-01 16:22:41 UTC (rev 14873)
@@ -270,6 +270,10 @@
 #2870|Point[GS]
 #2956|t
 #2996|t
+#3119a|121
+#3119b|291
+#3119c|615
+#3119d|291
 #3172|LINESTRING M (0 0 1,0 0 2)
 #3300|POLYGON((-71.7821 42.2622,-71.7821 42.9067,-71.029 42.9067,-71.029 42.2622,-71.7821 42.2622))
 #3355|t



More information about the postgis-tickets mailing list