<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>
<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>
<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>
<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>
<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>
<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>
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)'));