From bd7e18d27dd016619a9ea29a4f99548ed1d8c59f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 20 Mar 2013 17:38:58 +0000 Subject: [PATCH] Have functions deprecated in 2.1.0 raise a WARNING message (#1994) Drop use of some deprecated functions by other functions (as exposed by testsuite). Add a _postgis_deprecate service function for the message, so we can change from WARNING to NOTICE or we can tweak the message, in a central place. git-svn-id: http://svn.osgeo.org/postgis/trunk@11191 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/postgis.sql.in | 85 +++++++++++++++++++---------- regress/tickets.sql | 2 +- regress/tickets_expected | 1 + topology/sql/export/TopoJSON.sql.in | 8 +-- topology/sql/export/gml.sql.in | 16 +++--- topology/sql/populate.sql.in | 10 ++-- topology/sql/sqlmm.sql.in | 10 ++-- 7 files changed, 79 insertions(+), 53 deletions(-) diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index d4344b18..7ea62589 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -27,6 +27,17 @@ SET client_min_messages TO warning; BEGIN; +------------------------------------------------------------------- +-- SPHEROID TYPE +------------------------------------------------------------------- +CREATE OR REPLACE FUNCTION _postgis_deprecate(oldname text, newname text, version text) +RETURNS void AS +$$ +BEGIN + RAISE WARNING '% signature was deprecated in %. Please use %', oldname, version, newname; +END; +$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; + ------------------------------------------------------------------- -- SPHEROID TYPE ------------------------------------------------------------------- @@ -935,33 +946,41 @@ CREATE OR REPLACE FUNCTION ST_Combine_BBox(box2d,geometry) LANGUAGE 'c' IMMUTABLE; ----------------------------------------------------------------------- --- ESTIMATED_EXTENT( , , ) +-- ST_ESTIMATED_EXTENT( ,
, ) ----------------------------------------------------------------------- --- Availability: 1.2.2 --- Deprecation in 2.1.0 -CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text,text) RETURNS box2d AS - 'MODULE_PATHNAME', 'gserialized_estimated_extent' - LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER; -- Availability: 2.1.0 CREATE OR REPLACE FUNCTION ST_EstimatedExtent(text,text,text) RETURNS box2d AS 'MODULE_PATHNAME', 'gserialized_estimated_extent' LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER; ------------------------------------------------------------------------ --- ESTIMATED_EXTENT(
, ) ------------------------------------------------------------------------ -- Availability: 1.2.2 -- Deprecation in 2.1.0 -CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text) RETURNS box2d AS - 'MODULE_PATHNAME', 'gserialized_estimated_extent' - LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER; +CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text,text) RETURNS box2d AS + $$ SELECT _postgis_deprecate('ST_Estimated_Extent', 'ST_EstimatedExtent', '2.1.0'); + -- explicit schema for security reason + SELECT public.ST_EstimatedExtent($1, $2, $3); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT SECURITY DEFINER; + +----------------------------------------------------------------------- +-- ST_ESTIMATED_EXTENT(
, ) +----------------------------------------------------------------------- -- Availability: 2.1.0 CREATE OR REPLACE FUNCTION ST_EstimatedExtent(text,text) RETURNS box2d AS 'MODULE_PATHNAME', 'gserialized_estimated_extent' LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER; +-- Availability: 1.2.2 +-- Deprecation in 2.1.0 +CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text) RETURNS box2d AS + $$ SELECT _postgis_deprecate('ST_Estimated_Extent', 'ST_EstimatedExtent', '2.1.0'); + -- explicit schema for security reason + SELECT public.ST_EstimatedExtent($1, $2); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT SECURITY DEFINER; + ----------------------------------------------------------------------- -- FIND_EXTENT( ,
, ) ----------------------------------------------------------------------- @@ -2691,13 +2710,6 @@ CREATE OR REPLACE FUNCTION ST_Segmentize(geometry, float8) -- LRS --------------------------------------------------------------- --- Availability: 1.2.2 --- Deprecation in 2.1.0 -CREATE OR REPLACE FUNCTION ST_line_interpolate_point(geometry, float8) - RETURNS geometry - AS 'MODULE_PATHNAME', 'LWGEOM_line_interpolate_point' - LANGUAGE 'c' IMMUTABLE STRICT; - -- Availability: 2.1.0 CREATE OR REPLACE FUNCTION ST_LineInterpolatePoint(geometry, float8) RETURNS geometry @@ -2706,10 +2718,12 @@ CREATE OR REPLACE FUNCTION ST_LineInterpolatePoint(geometry, float8) -- Availability: 1.2.2 -- Deprecation in 2.1.0 -CREATE OR REPLACE FUNCTION ST_line_substring(geometry, float8, float8) - RETURNS geometry - AS 'MODULE_PATHNAME', 'LWGEOM_line_substring' - LANGUAGE 'c' IMMUTABLE STRICT; +CREATE OR REPLACE FUNCTION ST_line_interpolate_point(geometry, float8) + RETURNS geometry AS + $$ SELECT _postgis_deprecate('ST_Line_Interpolate_Point', 'ST_LineInterpolatePoint', '2.1.0'); + SELECT ST_LineInterpolatePoint($1, $2); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT; -- Availability: 2.1.0 CREATE OR REPLACE FUNCTION ST_LineSubstring(geometry, float8, float8) @@ -2719,10 +2733,12 @@ CREATE OR REPLACE FUNCTION ST_LineSubstring(geometry, float8, float8) -- Availability: 1.2.2 -- Deprecation in 2.1.0 -CREATE OR REPLACE FUNCTION ST_line_locate_point(geom1 geometry, geom2 geometry) - RETURNS float8 - AS 'MODULE_PATHNAME', 'LWGEOM_line_locate_point' - LANGUAGE 'c' IMMUTABLE STRICT; +CREATE OR REPLACE FUNCTION ST_line_substring(geometry, float8, float8) + RETURNS geometry AS + $$ SELECT _postgis_deprecate('ST_Line_Substring', 'ST_LineSubstring', '2.1.0'); + SELECT ST_LineSubstring($1, $2, $3); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT; -- Availability: 2.1.0 CREATE OR REPLACE FUNCTION ST_LineLocatePoint(geom1 geometry, geom2 geometry) @@ -2730,6 +2746,15 @@ CREATE OR REPLACE FUNCTION ST_LineLocatePoint(geom1 geometry, geom2 geometry) AS 'MODULE_PATHNAME', 'LWGEOM_line_locate_point' LANGUAGE 'c' IMMUTABLE STRICT; +-- Availability: 1.2.2 +-- Deprecation in 2.1.0 +CREATE OR REPLACE FUNCTION ST_line_locate_point(geom1 geometry, geom2 geometry) + RETURNS float8 AS + $$ SELECT _postgis_deprecate('ST_Line_Locate_Point', 'ST_LineLocatePoint', '2.1.0'); + SELECT ST_LineLocatePoint($1, $2); + $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + -- Availability: 1.2.2 CREATE OR REPLACE FUNCTION ST_locate_between_measures(geometry, float8, float8) RETURNS geometry @@ -4856,7 +4881,7 @@ $BODY$ -- The radius is half the distance between them and the center is midway between them radius = ST_Distance(ST_PointN(ring,idx1),ST_PointN(ring,idx2)) / 2.0; - center = ST_Line_interpolate_point(ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2)),0.5); + center = ST_LineInterpolatePoint(ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2)),0.5); -- Loop through each vertex and check if the distance from the center to the point -- is greater than the current radius. @@ -4871,7 +4896,7 @@ $BODY$ -- Draw a line from the first diameter to this point l1 = ST_Makeline(ST_PointN(ring,idx1),ST_PointN(ring,k)); -- Compute the midpoint - p1 = ST_line_interpolate_point(l1,0.5); + p1 = ST_LineInterpolatePoint(l1,0.5); -- Rotate the line 90 degrees around the midpoint (perpendicular bisector) l1 = ST_Rotate(l1,pi()/2,p1); -- Compute the azimuth of the bisector @@ -4882,7 +4907,7 @@ $BODY$ -- Repeat for the line from the point to the other diameter point l2 = ST_Makeline(ST_PointN(ring,idx2),ST_PointN(ring,k)); - p2 = ST_Line_interpolate_point(l2,0.5); + p2 = ST_LineInterpolatePoint(l2,0.5); l2 = ST_Rotate(l2,pi()/2,p2); a2 = ST_Azimuth(ST_PointN(l2,1),ST_PointN(l2,2)); l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,2))+sin(a2)*dist,ST_Y(ST_PointN(l2,2))+cos(a2)*dist),-1); diff --git a/regress/tickets.sql b/regress/tickets.sql index 3f4f03bf..cbe197ee 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -804,7 +804,7 @@ FROM (SELECT 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry as a, 'LINES ) as foo; -- 2112 -- End -SELECT '#2108', ST_AsEWKT(ST_Line_Interpolate_Point('SRID=3395;LINESTRING M EMPTY'::geometry, 0.5)); +SELECT '#2108', ST_AsEWKT(ST_LineInterpolatePoint('SRID=3395;LINESTRING M EMPTY'::geometry, 0.5)); SELECT '#2117', ST_AsEWKT(ST_PointOnSurface('SRID=3395;MULTIPOLYGON M EMPTY'::geometry)); SELECT '#2110.1', 'POINT(0 0)'::geometry = 'POINT EMPTY'::geometry; diff --git a/regress/tickets_expected b/regress/tickets_expected index b104a7f8..50a3acb7 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -145,6 +145,7 @@ ERROR: First argument must be a LINESTRING #1273.1|t ERROR: stats for "t.g" do not exist ERROR: stats for "t.g" do not exist +WARNING: ST_Estimated_Extent signature was deprecated in 2.1.0. Please use ST_EstimatedExtent ERROR: stats for "t.g" do not exist ERROR: stats for "t.g" do not exist #877.4|-10.15000|20.15000|-50.40000|30.40000 diff --git a/topology/sql/export/TopoJSON.sql.in b/topology/sql/export/TopoJSON.sql.in index fb6c87fb..4f25f5e6 100644 --- a/topology/sql/export/TopoJSON.sql.in +++ b/topology/sql/export/TopoJSON.sql.in @@ -61,12 +61,12 @@ BEGIN FOR rec IN SELECT (ST_Dump(topology.Geometry(tg))).geom LOOP -- { - sql := 'SELECT e.*, ST_Line_Locate_Point(' + sql := 'SELECT e.*, ST_LineLocatePoint(' || quote_literal(rec.geom::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.2)) as pos' - || ', ST_Line_Locate_Point(' + || ', ST_LineInterpolatePoint(e.geom, 0.2)) as pos' + || ', ST_LineLocatePoint(' || quote_literal(rec.geom::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.8)) as pos2 FROM ' + || ', ST_LineInterpolatePoint(e.geom, 0.8)) as pos2 FROM ' || quote_ident(toponame) || '.edge e WHERE ST_Covers(' || quote_literal(rec.geom::text) diff --git a/topology/sql/export/gml.sql.in b/topology/sql/export/gml.sql.in index 9aec7ee7..a131f385 100644 --- a/topology/sql/export/gml.sql.in +++ b/topology/sql/export/gml.sql.in @@ -199,12 +199,12 @@ BEGIN bounds = ST_Boundary(rec.geom); FOR rec2 IN EXECUTE - 'SELECT e.*, ST_Line_Locate_Point(' + 'SELECT e.*, ST_LineLocatePoint(' || quote_literal(bounds::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.2)) as pos' - || ', ST_Line_Locate_Point(' + || ', ST_LineInterpolatePoint(e.geom, 0.2)) as pos' + || ', ST_LineLocatePoint(' || quote_literal(bounds::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.8)) as pos2 FROM ' + || ', ST_LineInterpolatePoint(e.geom, 0.8)) as pos2 FROM ' || quote_ident(toponame) || '.edge e WHERE ( e.left_face = ' || face_id || ' OR e.right_face = ' || face_id @@ -347,12 +347,12 @@ BEGIN FOR rec IN SELECT (ST_Dump(topology.Geometry(tg))).geom LOOP FOR rec2 IN EXECUTE - 'SELECT e.*, ST_Line_Locate_Point(' + 'SELECT e.*, ST_LineLocatePoint(' || quote_literal(rec.geom::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.2)) as pos' - || ', ST_Line_Locate_Point(' + || ', ST_LineInterpolatePoint(e.geom, 0.2)) as pos' + || ', ST_LineLocatePoint(' || quote_literal(rec.geom::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.8)) as pos2 FROM ' + || ', ST_LineInterpolatePoint(e.geom, 0.8)) as pos2 FROM ' || quote_ident(toponame) || '.edge e WHERE ST_Covers(' || quote_literal(rec.geom::text) diff --git a/topology/sql/populate.sql.in b/topology/sql/populate.sql.in index 1e2e3119..5b7f6fe4 100644 --- a/topology/sql/populate.sql.in +++ b/topology/sql/populate.sql.in @@ -508,22 +508,22 @@ BEGIN p3 = ST_StartPoint(bounds); IF ST_DWithin(edgeseg, p3, 0) THEN -- Edge segment covers ring endpoint, See bug #874 - loc = ST_Line_Locate_Point(edgeseg, p3); + loc = ST_LineLocatePoint(edgeseg, p3); -- WARNING: this is as robust as length of edgeseg allows... IF loc > 0.9 THEN -- shift last point down - p2 = ST_Line_Interpolate_Point(edgeseg, loc - 0.1); + p2 = ST_LineInterpolatePoint(edgeseg, loc - 0.1); ELSIF loc < 0.1 THEN -- shift first point up - p1 = ST_Line_Interpolate_Point(edgeseg, loc + 0.1); + p1 = ST_LineInterpolatePoint(edgeseg, loc + 0.1); ELSE -- when ring start point is in between, we swap the points p3 = p1; p1 = p2; p2 = p3; END IF; END IF; - right_side = ST_Line_Locate_Point(bounds, p1) < - ST_Line_Locate_Point(bounds, p2); + right_side = ST_LineLocatePoint(bounds, p1) < + ST_LineLocatePoint(bounds, p2); #ifdef POSTGIS_TOPOLOGY_DEBUG RAISE DEBUG 'Edge % (left:%, right:%) - ring : % - right_side : %', diff --git a/topology/sql/sqlmm.sql.in b/topology/sql/sqlmm.sql.in index 3eb90f06..a7b81f5e 100644 --- a/topology/sql/sqlmm.sql.in +++ b/topology/sql/sqlmm.sql.in @@ -78,12 +78,12 @@ BEGIN sql := 'WITH er2 AS ( ' || 'WITH er AS ( SELECT ' || 'min(e.edge_id) over (), count(*) over () as cnt, e.edge_id, ' - || 'ST_Line_Locate_Point(' + || 'ST_LineLocatePoint(' || quote_literal(bounds::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.2)) as pos' - || ', ST_Line_Locate_Point(' + || ', ST_LineInterpolatePoint(e.geom, 0.2)) as pos' + || ', ST_LineLocatePoint(' || quote_literal(bounds::text) - || ', ST_Line_Interpolate_Point(e.geom, 0.8)) as pos2 FROM ' + || ', ST_LineInterpolatePoint(e.geom, 0.8)) as pos2 FROM ' || quote_ident(toponame) || '.edge e WHERE ( e.left_face = ' || face_id || ' OR e.right_face = ' || face_id @@ -3054,7 +3054,7 @@ BEGIN IF ishole THEN sql := sql || 'NOT '; END IF; sql := sql || 'ST_Contains(' || quote_literal(fan.shell::text) -- We only need to check a single point, but must not be an endpoint - || '::geometry, ST_Line_Interpolate_Point(geom, 0.2))'; + || '::geometry, ST_LineInterpolatePoint(geom, 0.2))'; #ifdef POSTGIS_TOPOLOGY_DEBUG RAISE DEBUG 'Updating edges bounding the old face'; #endif