]> granicus.if.org Git - postgis/commitdiff
Have functions deprecated in 2.1.0 raise a WARNING message (#1994)
authorSandro Santilli <strk@keybit.net>
Wed, 20 Mar 2013 17:38:58 +0000 (17:38 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 20 Mar 2013 17:38:58 +0000 (17:38 +0000)
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
regress/tickets.sql
regress/tickets_expected
topology/sql/export/TopoJSON.sql.in
topology/sql/export/gml.sql.in
topology/sql/populate.sql.in
topology/sql/sqlmm.sql.in

index d4344b18a7fb85d91030638584b2230d37a87448..7ea625899f439f7871dfc9215c2734248f88ef98 100644 (file)
@@ -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( <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> )
 -----------------------------------------------------------------------
@@ -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);
index 3f4f03bf58ef40f24d4fbb1f6d7920f61e31447c..cbe197eed4bf6523619dbd8c75a0673eefeb21b1 100644 (file)
@@ -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;
index b104a7f809576668989240cf422dd8b4edeaf653..50a3acb700ec86e4e453f64a22cb89582f58e01a 100644 (file)
@@ -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
index fb6c87fb369cf299a84f3bf412b9f2aedad70f04..4f25f5e6bf9b6aca787bd6dd75e7a201246670cc 100644 (file)
@@ -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)
index 9aec7ee79c2ca49eb8345c7322c1a06f74642182..a131f3859303fcfcf80ef836aa99f5a24c21a2d2 100644 (file)
@@ -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)
index 1e2e3119d2e07705c7925c4fe4bc4aed0bfd01c7..5b7f6fe4ad98b409c449c6f714855eedb11c8ed9 100644 (file)
@@ -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 : %',
index 3eb90f0622968d24f23a5cb2106decb98b212030..a7b81f5e233b4d2cb55fa60d743e6a796cadad1f 100644 (file)
@@ -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