Skip to content

Commit

Permalink
Have functions deprecated in 2.1.0 raise a WARNING message (#1994)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sandro Santilli committed Mar 20, 2013
1 parent ef67651 commit bd7e18d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 53 deletions.
85 changes: 55 additions & 30 deletions postgis/postgis.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------------------------
Expand Down Expand Up @@ -935,33 +946,41 @@ CREATE OR REPLACE FUNCTION ST_Combine_BBox(box2d,geometry)
LANGUAGE 'c' IMMUTABLE;

-----------------------------------------------------------------------
-- ESTIMATED_EXTENT( <schema name>, <table name>, <column name> )
-- ST_ESTIMATED_EXTENT( <schema name>, <table name>, <column name> )
-----------------------------------------------------------------------
-- 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( <table name>, <column name> )
-----------------------------------------------------------------------
-- 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( <table name>, <column name> )
-----------------------------------------------------------------------

-- 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( <schema name>, <table name>, <column name> )
-----------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -2719,17 +2733,28 @@ 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)
RETURNS float8
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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion regress/tickets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions regress/tickets_expected
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions topology/sql/export/TopoJSON.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions topology/sql/export/gml.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions topology/sql/populate.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 : %',
Expand Down
10 changes: 5 additions & 5 deletions topology/sql/sqlmm.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd7e18d

Please sign in to comment.