From dc0e1579aaac7ab7e12e97615e935402cd039f51 Mon Sep 17 00:00:00 2001 From: Daniel Baston Date: Sun, 1 May 2016 16:22:41 +0000 Subject: [PATCH] #3119, Wrong documented behavior for ST_LengthSpheroid git-svn-id: http://svn.osgeo.org/postgis/trunk@14873 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_measure.xml | 26 +++++++++----------------- regress/tickets.sql | 10 ++++++++++ regress/tickets_expected | 4 ++++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml index 174b76ad7..bd33c9d60 100644 --- a/doc/reference_measure.xml +++ b/doc/reference_measure.xml @@ -3431,7 +3431,7 @@ ST_3DLength ST_LengthSpheroid - Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This + 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. @@ -3440,7 +3440,7 @@ ST_3DLength float ST_LengthSpheroid - geometry a_linestring + geometry a_geometry spheroid a_spheroid @@ -3449,25 +3449,21 @@ ST_3DLength Description - Calculates the length of a geometry on an ellipsoid. This + 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: - SPHEROID[<NAME>,<SEMI-MAJOR - AXIS>,<INVERSE FLATTENING>] - + SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>] SPHEROID["GRS_1980",6378137,298.257222101] - Will return 0 for anything that is not a MULTILINESTRING or LINESTRING Availability: 1.2.2 Changed: 2.2.0 In prior versions this used to be called ST_Length_Spheroid and used to have a ST_3DLength_Spheroid alias &Z_support; - Examples @@ -3512,7 +3508,7 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo ST_Length2D_Spheroid - Calculates the 2D length of a linestring/multilinestring on an ellipsoid. This + 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. @@ -3521,7 +3517,7 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo float ST_Length2D_Spheroid - geometry a_linestring + geometry a_geometry spheroid a_spheroid @@ -3530,20 +3526,16 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo Description - Calculates the 2D length of a geometry on an ellipsoid. This + 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: - SPHEROID[<NAME>,<SEMI-MAJOR - AXIS>,<INVERSE FLATTENING>] - + SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>] SPHEROID["GRS_1980",6378137,298.257222101] - Will return 0 for anything that is not a MULTILINESTRING or LINESTRING - This is much like except it will throw away the Z coordinate in calculations. - + This is much like except it will ignore the Z ordinate in calculations. diff --git a/regress/tickets.sql b/regress/tickets.sql index 623d390dd..eeae6a3ab 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -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)')); diff --git a/regress/tickets_expected b/regress/tickets_expected index 1326c0c65..03247250f 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -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 -- 2.40.0