replace ST_Line_Interpolate_Point with ST_LineInterpolatePoint (DB adaption needed)

Name of function was changed in postgis 2.1 and now prints ugly
deprecation warnings. For older versions of postgis, function
will be renamed to the new name during the setup of the DB.

To update existing databases with postgis < 2.1 run:

ALTER FUNCTION st_line_interpolate_point(geometry, double precision) RENAME TO ST_LineInterpolatePoint

and then reinstall the SQL functions:

./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
This commit is contained in:
Sarah Hoffmann
2014-02-06 08:04:42 +01:00
parent edc5733715
commit e0b1e3b66d
4 changed files with 12 additions and 8 deletions

View File

@@ -895,7 +895,7 @@ BEGIN
insert into placex (osm_type, osm_id, class, type, admin_level, housenumber, street, addr_place, isin, postcode, insert into placex (osm_type, osm_id, class, type, admin_level, housenumber, street, addr_place, isin, postcode,
country_code, parent_place_id, rank_address, rank_search, indexed_status, geometry) country_code, parent_place_id, rank_address, rank_search, indexed_status, geometry)
values ('N',prevnode.osm_id, 'place', 'house', prevnode.admin_level, housenum, prevnode.street, prevnode.addr_place, prevnode.isin, coalesce(prevnode.postcode, defpostalcode), values ('N',prevnode.osm_id, 'place', 'house', prevnode.admin_level, housenum, prevnode.street, prevnode.addr_place, prevnode.isin, coalesce(prevnode.postcode, defpostalcode),
prevnode.country_code, prevnode.parent_place_id, prevnode.rank_address, prevnode.rank_search, 1, ST_Line_Interpolate_Point(linegeo, (housenum::float-orginalstartnumber::float)/originalnumberrange::float)); prevnode.country_code, prevnode.parent_place_id, prevnode.rank_address, prevnode.rank_search, 1, ST_LineInterpolatePoint(linegeo, (housenum::float-orginalstartnumber::float)/originalnumberrange::float));
newpoints := newpoints + 1; newpoints := newpoints + 1;
--RAISE WARNING 'interpolation number % % ',prevnode.place_id,housenum; --RAISE WARNING 'interpolation number % % ',prevnode.place_id,housenum;
END LOOP; END LOOP;
@@ -1484,9 +1484,9 @@ BEGIN
FOR relation IN SELECT place_id FROM placex FOR relation IN SELECT place_id FROM placex
WHERE ST_DWithin(location.geometry, placex.geometry, 0.001) and placex.rank_search = 26 WHERE ST_DWithin(location.geometry, placex.geometry, 0.001) and placex.rank_search = 26
and st_geometrytype(location.geometry) in ('ST_LineString') and st_geometrytype(location.geometry) in ('ST_LineString')
ORDER BY (ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,0))+ ORDER BY (ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,0))+
ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,0.5))+ ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,0.5))+
ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,1))) ASC limit 1 ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,1))) ASC limit 1
LOOP LOOP
--RAISE WARNING 'using nearest street to address interpolation line,0.001 %',relation; --RAISE WARNING 'using nearest street to address interpolation line,0.001 %',relation;
NEW.parent_place_id := relation.place_id; NEW.parent_place_id := relation.place_id;

View File

@@ -327,9 +327,9 @@ BEGIN
RETURN; RETURN;
END IF; END IF;
p1 := ST_Line_Interpolate_Point(line,0); p1 := ST_LineInterpolatePoint(line,0);
p2 := ST_Line_Interpolate_Point(line,0.5); p2 := ST_LineInterpolatePoint(line,0.5);
p3 := ST_Line_Interpolate_Point(line,1); p3 := ST_LineInterpolatePoint(line,1);
-- start -- start
IF in_partition = -partition- THEN IF in_partition = -partition- THEN

View File

@@ -79,7 +79,7 @@ BEGIN
FOR housenum IN startnumber..endnumber BY stepsize LOOP FOR housenum IN startnumber..endnumber BY stepsize LOOP
insert into location_property_tiger_import (place_id, partition, parent_place_id, housenumber, postcode, centroid) insert into location_property_tiger_import (place_id, partition, parent_place_id, housenumber, postcode, centroid)
values (nextval('seq_place'), out_partition, out_parent_place_id, housenum, in_postcode, values (nextval('seq_place'), out_partition, out_parent_place_id, housenum, in_postcode,
ST_Line_Interpolate_Point(linegeo, (housenum::float-rangestartnumber::float)/numberrange::float)); ST_LineInterpolatePoint(linegeo, (housenum::float-rangestartnumber::float)/numberrange::float));
newpoints := newpoints + 1; newpoints := newpoints + 1;
END LOOP; END LOOP;

View File

@@ -132,6 +132,10 @@
} else { } else {
pgsqlRunScript('CREATE EXTENSION postgis'); pgsqlRunScript('CREATE EXTENSION postgis');
} }
if ($fPostgisVersion < 2.1) {
// Function was renamed in 2.1 and throws an annoying deprecation warning
pgsqlRunScript('ALTER FUNCTION st_line_interpolate_point(geometry, double precision) RENAME TO ST_LineInterpolatePoint');
}
$sVersionString = $oDB->getOne('select postgis_full_version()'); $sVersionString = $oDB->getOne('select postgis_full_version()');
preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches); preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
if (CONST_Postgis_Version != $aMatches[1].'.'.$aMatches[2]) if (CONST_Postgis_Version != $aMatches[1].'.'.$aMatches[2])