]> granicus.if.org Git - postgis/commitdiff
#3119, Wrong documented behavior for ST_LengthSpheroid
authorDaniel Baston <dbaston@gmail.com>
Sun, 1 May 2016 16:22:41 +0000 (16:22 +0000)
committerDaniel Baston <dbaston@gmail.com>
Sun, 1 May 2016 16:22:41 +0000 (16:22 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14873 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_measure.xml
regress/tickets.sql
regress/tickets_expected

index 174b76ad74781342a5e0e5a4366e7bb0ead9e5a9..bd33c9d608cace47c6ffe3fa92e8c1fad7b9269b 100644 (file)
@@ -3431,7 +3431,7 @@ ST_3DLength
          <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 @@ ST_3DLength
                <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 @@ ST_3DLength
          <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[&lt;NAME&gt;,&lt;SEMI-MAJOR
-                 AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</literallayout>
-
+               <literallayout>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</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 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo
          <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 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo
                <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 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo
          <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[&lt;NAME&gt;,&lt;SEMI-MAJOR
-                 AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</literallayout>
-
+               <literallayout>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</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>
 
 
index 623d390dde5e8c79fa556a54eba9b6c91d5d8a1f..eeae6a3ab0946e15b795e16e96fb5092f134d6b3 100644 (file)
@@ -886,6 +886,16 @@ WITH
   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)'));
index 1326c0c65a1eede25a0f4225f67e69203e1b31e8..03247250f46509e826b7cd47b98e66d2da931cdd 100644 (file)
@@ -270,6 +270,10 @@ ERROR:  invalid GML representation
 #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