]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 7 Feb 2014 19:20:20 +0000 (20:20 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 7 Feb 2014 19:20:20 +0000 (20:20 +0100)
lib/PlaceLookup.php
lib/template/address-jsonv2.php
sql/functions.sql
sql/partition-functions.src.sql
sql/tiger_import_start.sql
utils/setup.php
utils/warm.php [new file with mode: 0755]

index 65aff13eecebcdace754cc7c59217e78ce33cffc..ed2f494d45c41bbc66b3c2dc66a5012f158360c1 100644 (file)
@@ -41,8 +41,8 @@
 
                        $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted", $this->aLangPrefOrder))."]";
 
-                       $sSQL = "select placex.place_id, partition, osm_type, osm_id, class, type, admin_level, housenumber, street, isin, postcode, country_code, extratags, parent_place_id, linked_place_id, rank_address, rank_search";
-                       $sSQL .= " importance, indexed_status, indexed_date, wikipedia, calculated_country_code, ";
+                       $sSQL = "select placex.place_id, partition, osm_type, osm_id, class, type, admin_level, housenumber, street, isin, postcode, country_code, extratags, parent_place_id, linked_place_id, rank_address, rank_search";
+                       $sSQL .= " coalesce(importance,0.75-(rank_search::float/40)) as importance, indexed_status, indexed_date, wikipedia, calculated_country_code, ";
                        $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                        $sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
                        $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
index baf53129e13aec93d6e470c838d27e343c4061ca..92cf4f1cc5025d830ea92556682f2eb8e746348e 100644 (file)
                 }
                if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];
                if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];
+
+               $aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
+
                 $aFilteredPlaces['category'] = $aPlace['class'];
                 $aFilteredPlaces['type'] = $aPlace['type'];
+
+               $aFilteredPlaces['importance'] = $aPlace['importance'];
+
                 $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
 
                $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
index acaa6d838e411858314d1bf4bdcbd3ba3478eea5..1e411e04e180397b129fa8ff2b87d99941b19dc3 100644 (file)
@@ -895,7 +895,7 @@ BEGIN
                 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)
                   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;
 --RAISE WARNING 'interpolation number % % ',prevnode.place_id,housenum;
               END LOOP;
@@ -1502,9 +1502,9 @@ BEGIN
             FOR relation IN SELECT place_id FROM placex
               WHERE ST_DWithin(location.geometry, placex.geometry, 0.001) and placex.rank_search = 26
                 and st_geometrytype(location.geometry) in ('ST_LineString')
-              ORDER BY (ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,0))+
-                        ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,0.5))+
-                        ST_distance(placex.geometry, ST_Line_Interpolate_Point(location.geometry,1))) ASC limit 1
+              ORDER BY (ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,0))+
+                        ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,0.5))+
+                        ST_distance(placex.geometry, ST_LineInterpolatePoint(location.geometry,1))) ASC limit 1
             LOOP
 --RAISE WARNING 'using nearest street to address interpolation line,0.001 %',relation;
               NEW.parent_place_id := relation.place_id;
index d9da9b4258b803db620cca07106cb682eec35ecc..235e21a216088d4a06951279ad460277e03ca3df 100644 (file)
@@ -327,9 +327,9 @@ BEGIN
     RETURN;
   END IF;
 
-  p1 := ST_Line_Interpolate_Point(line,0);
-  p2 := ST_Line_Interpolate_Point(line,0.5);
-  p3 := ST_Line_Interpolate_Point(line,1);
+  p1 := ST_LineInterpolatePoint(line,0);
+  p2 := ST_LineInterpolatePoint(line,0.5);
+  p3 := ST_LineInterpolatePoint(line,1);
 
 -- start
   IF in_partition = -partition- THEN
index f40f544bd2a74d6937dffa753d369766d9a634b2..d9def2b43a1c428c044a9f8cee505df921a3107e 100644 (file)
@@ -79,7 +79,7 @@ BEGIN
   FOR housenum IN startnumber..endnumber BY stepsize LOOP
     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,
-      ST_Line_Interpolate_Point(linegeo, (housenum::float-rangestartnumber::float)/numberrange::float));
+      ST_LineInterpolatePoint(linegeo, (housenum::float-rangestartnumber::float)/numberrange::float));
     newpoints := newpoints + 1;
   END LOOP;
 
index 270c1a4916220af8d3aeb2f5b8403e340e0d6274..a5466432c8ae389d490b5449698bfc8532e297c4 100755 (executable)
                } else {
                        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()');
                preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches);
                if (CONST_Postgis_Version != $aMatches[1].'.'.$aMatches[2])
diff --git a/utils/warm.php b/utils/warm.php
new file mode 100755 (executable)
index 0000000..923e2ab
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/php -Cq
+<?php
+
+        require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
+        ini_set('memory_limit', '800M');
+
+       $aCMDOptions = array(
+               "Tools to warm nominatim db",
+               array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
+               array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
+               array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
+               array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
+               array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
+       );
+       getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
+
+       require_once(CONST_BasePath.'/lib/log.php');
+       require_once(CONST_BasePath.'/lib/Geocode.php');
+       require_once(CONST_BasePath.'/lib/PlaceLookup.php');
+       require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
+
+       $oDB =& getDB();
+
+       $bVerbose = $aResult['verbose'];
+
+       if (!$aResult['search-only']) {
+
+               $oReverseGeocode = new ReverseGeocode($oDB);
+               $oReverseGeocode->setIncludeAddressDetails(true);
+
+               echo "Warm reverse: ";
+               if ($bVerbose) echo "\n";
+               for($i = 0; $i < 1000; $i++) {
+                       $fLat = rand(-9000, 9000) / 100;
+                       $fLon = rand(-18000, 18000) / 100;
+                       if ($bVerbose) echo "$fLat, $fLon = ";
+                       $oReverseGeocode->setLanguagePreference(array('en'));
+                       $oReverseGeocode->setLatLon($fLat, $fLon);
+                       $oReverseGeocode->setZoom(20);
+                       $aDetails = $oReverseGeocode->lookup();
+                       if ($bVerbose) echo $aDetails['langaddress']."\n";
+                       else echo ".";
+               }
+               echo "\n";
+       }
+
+       if (!$aResult['reverse-only']) {
+
+               $oGeocode =& new Geocode($oDB);
+
+               echo "Warm search: ";
+               if ($bVerbose) echo "\n";
+               $sSQL = 'select word from word where word is not null order by search_name_count desc limit 1000';
+               foreach($oDB->getCol($sSQL) as $sWord) {
+                       if ($bVerbose) echo "$sWord = ";
+                       $oGeocode->setLanguagePreference(array('en'));
+                       $oGeocode->setQuery($sWord);
+                       $aSearchResults = $oGeocode->lookup();
+                       if ($bVerbose) echo $aSearchResults[0]['langaddress']."\n";
+                       else echo ".";
+               }
+       }
+