From f1b955e09116c966b48cfd5c6d39f2a9e75734e9 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 4 Jan 2015 17:08:14 +0000 Subject: [PATCH] CamelCase-ize ST_LengtSpheroid, ST_DistanceSpheroid (#2748) git-svn-id: http://svn.osgeo.org/postgis/trunk@13173 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 4 +++- doc/reference_measure.xml | 29 ++++++++++++++++------------- postgis/postgis.sql.in | 27 +++++++++++++++++++++++---- regress/measures.sql | 3 ++- regress/measures_expected | 1 + regress/tickets.sql | 3 ++- regress/tickets_expected | 1 + 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index c1e499792..7e6701af9 100644 --- a/NEWS +++ b/NEWS @@ -13,7 +13,9 @@ PostGIS 2.2.0 - #2748, ST_Shift_Longitude renamed to ST_ShiftLongitude, ST_Find_Extent renamed to ST_FindExtent, - ST_Combine_BBox renamed to ST_CombineBbox + ST_Combine_BBox renamed to ST_CombineBbox, + ST_Length_Spheroid renamed to ST_LengthSpheroid, + ST_Distance_Spheroid renamed to ST_DistanceSpheroid - #2769, ST_Mem_Size renamed to ST_MemSize - #2565, ST_SummaryStats(tablename, rastercolumn, ...) - #2567, ST_Count(tablename, rastercolumn, ...) diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml index 6a8ad3953..1c8f868b7 100644 --- a/doc/reference_measure.xml +++ b/doc/reference_measure.xml @@ -2179,7 +2179,7 @@ postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 ) Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius of 6370986 meters. - Faster than ST_Distance_Spheroid , but less + Faster than ST_DistanceSpheroid , but less accurate. PostGIS versions prior to 1.5 only implemented for points. @@ -2236,7 +2236,7 @@ FROM - ST_Distance_Spheroid + ST_DistanceSpheroid Returns the minimum distance between two lon/lat geometries given a particular spheroid. @@ -2246,7 +2246,7 @@ FROM - float ST_Distance_Spheroid + float ST_DistanceSpheroid geometry geomlonlatA geometry geomlonlatB spheroid measurement_spheroid @@ -2265,6 +2265,7 @@ FROM Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. + Changed: 2.2.0 In prior versions this used to be called ST_Distance_Spheroid @@ -2272,7 +2273,7 @@ FROM Examples SELECT round(CAST( - ST_Distance_Spheroid(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]') + ST_DistanceSpheroid(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]') As numeric),2) As dist_meters_spheroid, round(CAST(ST_Distance_Sphere(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters_sphere, round(CAST(ST_Distance(ST_Transform(ST_Centroid(the_geom),32611), @@ -2845,7 +2846,7 @@ ST_3DLength - ST_Length_Spheroid + ST_LengthSpheroid Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This is useful if the coordinates of the geometry are in @@ -2855,7 +2856,7 @@ ST_3DLength - float ST_Length_Spheroid + float ST_LengthSpheroid geometry a_linestring spheroid a_spheroid @@ -2878,6 +2879,8 @@ ST_3DLength 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 &Z_support; @@ -2885,13 +2888,13 @@ ST_3DLength Examples - SELECT ST_Length_Spheroid( geometry_column, + SELECT ST_LengthSpheroid( geometry_column, 'SPHEROID["GRS_1980",6378137,298.257222101]' ) FROM geometry_table; -SELECT ST_Length_Spheroid( the_geom, sph_m ) As tot_len, -ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, -ST_Length_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2 +SELECT ST_LengthSpheroid( the_geom, sph_m ) As tot_len, +ST_LengthSpheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, +ST_LengthSpheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2 FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5), (-71.05957 42.3589 , -71.061 43))') As the_geom, CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo; @@ -2900,9 +2903,9 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo 85204.5207562955 | 13986.8725229309 | 71217.6482333646 --3D -SELECT ST_Length_Spheroid( the_geom, sph_m ) As tot_len, -ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, -ST_Length_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2 +SELECT ST_LengthSpheroid( the_geom, sph_m ) As tot_len, +ST_LengthSpheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, +ST_LengthSpheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2 FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30), (-71.05957 42.3589 75, -71.061 43 90))') As the_geom, CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo; diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index 23c6f2061..2c35bc06c 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -1140,6 +1140,7 @@ CREATE OR REPLACE FUNCTION ST_Length(geometry) -- this is a fake (for back-compatibility) -- uses 3d if 3d is available, 2d otherwise +-- TODO: deprecate ? -- Availability: 2.0.0 CREATE OR REPLACE FUNCTION ST_3DLength_spheroid(geometry, spheroid) RETURNS FLOAT8 @@ -1147,13 +1148,22 @@ CREATE OR REPLACE FUNCTION ST_3DLength_spheroid(geometry, spheroid) LANGUAGE 'c' IMMUTABLE STRICT COST 100; --- Availability: 1.2.2 -CREATE OR REPLACE FUNCTION ST_length_spheroid(geometry, spheroid) +-- Availability in 2.2.0 +CREATE OR REPLACE FUNCTION ST_LengthSpheroid(geometry, spheroid) RETURNS FLOAT8 AS 'MODULE_PATHNAME','LWGEOM_length_ellipsoid_linestring' LANGUAGE 'c' IMMUTABLE STRICT COST 100; +-- Availability: 1.2.2 +-- Deprecation in 2.2.0 +CREATE OR REPLACE FUNCTION ST_length_spheroid(geometry, spheroid) + RETURNS FLOAT8 AS + $$ SELECT _postgis_deprecate('ST_Length_Spheroid', 'ST_LengthSpheroid', '2.2.0'); + SELECT ST_LengthSpheroid($1,$2); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + -- Availability: 1.2.2 CREATE OR REPLACE FUNCTION ST_length2d_spheroid(geometry, spheroid) RETURNS FLOAT8 @@ -1192,13 +1202,22 @@ CREATE OR REPLACE FUNCTION ST_Area(geometry) AS 'MODULE_PATHNAME','area' LANGUAGE 'c' IMMUTABLE STRICT; --- Availability: 1.2.2 -CREATE OR REPLACE FUNCTION ST_distance_spheroid(geom1 geometry, geom2 geometry,spheroid) +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION ST_DistanceSpheroid(geom1 geometry, geom2 geometry,spheroid) RETURNS FLOAT8 AS 'MODULE_PATHNAME','LWGEOM_distance_ellipsoid' LANGUAGE 'c' IMMUTABLE STRICT COST 100; +-- Availability: 1.2.2 +-- Deprecation in 2.2.0 +CREATE OR REPLACE FUNCTION ST_distance_spheroid(geom1 geometry, geom2 geometry,spheroid) + RETURNS FLOAT8 AS + $$ SELECT _postgis_deprecate('ST_Distance_Spheroid', 'ST_DistanceSpheroid', '2.2.0'); + SELECT ST_DistanceSpheroid($1,$2,$3); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + -- Minimum distance. 2d only. -- PostGIS equivalent function: distance(geom1 geometry, geom2 geometry) diff --git a/regress/measures.sql b/regress/measures.sql index 22136bab0..e84e1318f 100644 --- a/regress/measures.sql +++ b/regress/measures.sql @@ -260,4 +260,5 @@ select 'emptyMultiPointArea', st_area('MULTIPOINT EMPTY'); select 'emptyCollectionArea', st_area('GEOMETRYCOLLECTION EMPTY'); -- -select 'spheroidLength1', round(st_length_spheroid('MULTILINESTRING((-118.584 38.374,-118.583 38.5),(-71.05957 42.3589 , -71.061 43))'::geometry,'SPHEROID["GRS_1980",6378137,298.257222101]'::spheroid)::numeric,5); +select 'spheroidLength1_deprecated', round(st_length_spheroid('MULTILINESTRING((-118.584 38.374,-118.583 38.5),(-71.05957 42.3589 , -71.061 43))'::geometry,'SPHEROID["GRS_1980",6378137,298.257222101]'::spheroid)::numeric,5); +select 'spheroidLength1', round(ST_LengthSpheroid('MULTILINESTRING((-118.584 38.374,-118.583 38.5),(-71.05957 42.3589 , -71.061 43))'::geometry,'SPHEROID["GRS_1980",6378137,298.257222101]'::spheroid)::numeric,5); diff --git a/regress/measures_expected b/regress/measures_expected index f945b1502..e2e2fefc3 100644 --- a/regress/measures_expected +++ b/regress/measures_expected @@ -42,4 +42,5 @@ emptyMultiPolyArea|0 emptyMultiLineArea|0 emptyMultiPointArea|0 emptyCollectionArea|0 +spheroidLength1_deprecated|85204.52077 spheroidLength1|85204.52077 diff --git a/regress/tickets.sql b/regress/tickets.sql index a33003406..ef0840146 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -325,7 +325,8 @@ SELECT '#650', ST_AsText(ST_Collect(ARRAY[ST_MakePoint(0,0), ST_MakePoint(1,1), SELECT '#667', ST_AsEWKT(ST_LineToCurve(ST_Buffer(ST_SetSRID(ST_Point(i,j),4326), j))) As the_geom FROM generate_series(-10,50,10) As i CROSS JOIN generate_series(40,70, 20) As j ORDER BY i, j, i*j LIMIT 1; -- #677 -- -SELECT '#677',round(ST_Distance_Spheroid(ST_GeomFromEWKT('MULTIPOLYGON(((-10 40,-10 55,-10 70,5 40,-10 40)))'), ST_GeomFromEWKT('MULTIPOINT(20 40,20 55,20 70,35 40,35 55,35 70,50 40,50 55,50 70)'), 'SPHEROID["GRS_1980",6378137,298.257222101]')) As result; +SELECT '#677.deprecated',round(ST_Distance_Spheroid(ST_GeomFromEWKT('MULTIPOLYGON(((-10 40,-10 55,-10 70,5 40,-10 40)))'), ST_GeomFromEWKT('MULTIPOINT(20 40,20 55,20 70,35 40,35 55,35 70,50 40,50 55,50 70)'), 'SPHEROID["GRS_1980",6378137,298.257222101]')) As result; +SELECT '#677',round(ST_DistanceSpheroid(ST_GeomFromEWKT('MULTIPOLYGON(((-10 40,-10 55,-10 70,5 40,-10 40)))'), ST_GeomFromEWKT('MULTIPOINT(20 40,20 55,20 70,35 40,35 55,35 70,50 40,50 55,50 70)'), 'SPHEROID["GRS_1980",6378137,298.257222101]')) As result; -- #680 -- SELECT '#680', encode(ST_AsBinary(geography(foo1.the_geom),'ndr'),'hex') As result FROM ((SELECT ST_SetSRID(ST_MakePointM(i,j,m),4326) As the_geom FROM generate_series(-10,50,10) As i CROSS JOIN generate_series(50,70, 20) AS j CROSS JOIN generate_series(1,2) As m ORDER BY i, j, i*j*m)) As foo1 LIMIT 1; diff --git a/regress/tickets_expected b/regress/tickets_expected index 514e22e17..a95fc96e5 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -96,6 +96,7 @@ NOTICE: IllegalArgumentException: Invalid number of points in LinearRing found #835.12|MULTIPOLYGON EMPTY #650|MULTIPOINT(0 0,1 1,2 2) #667|SRID=4326;CURVEPOLYGON(CIRCULARSTRING(30 40,-50 39.9999999999999,30 40)) +#677.deprecated|1121395 #677|1121395 #680|01d107000000000000000024c000000000000049400000000000000040 #681a| -- 2.40.0