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

Daniel Baston dbaston at gmail.com
Sun May 1 09:23:08 PDT 2016


Author: dbaston
Date: 2016-05-01 09:23:08 -0700 (Sun, 01 May 2016)
New Revision: 14874

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

Modified: branches/2.2/doc/reference_measure.xml
===================================================================
--- branches/2.2/doc/reference_measure.xml	2016-05-01 16:22:41 UTC (rev 14873)
+++ branches/2.2/doc/reference_measure.xml	2016-05-01 16:23:08 UTC (rev 14874)
@@ -2969,7 +2969,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>
@@ -2978,7 +2978,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>
@@ -2987,25 +2987,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>
 
@@ -3050,7 +3046,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>
@@ -3059,7 +3055,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>
@@ -3068,20 +3064,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: branches/2.2/regress/tickets.sql
===================================================================
--- branches/2.2/regress/tickets.sql	2016-05-01 16:22:41 UTC (rev 14873)
+++ branches/2.2/regress/tickets.sql	2016-05-01 16:23:08 UTC (rev 14874)
@@ -906,6 +906,16 @@
 
 SELECT '#2956', st_astwkb(null,0) is null;
 
+-- #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: branches/2.2/regress/tickets_expected
===================================================================
--- branches/2.2/regress/tickets_expected	2016-05-01 16:22:41 UTC (rev 14873)
+++ branches/2.2/regress/tickets_expected	2016-05-01 16:23:08 UTC (rev 14874)
@@ -275,6 +275,10 @@
 #2788|f|Self-intersection|POINT(1 1)
 #2870|Point[GS]
 #2956|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))
 #3367|POLYGON EMPTY



More information about the postgis-tickets mailing list