]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 6 Jul 2014 19:05:16 +0000 (21:05 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 6 Jul 2014 19:05:16 +0000 (21:05 +0200)
sql/functions.sql
sql/tiger_import_start.sql
utils/setup.php
utils/update.php

index 488d340f09958250ab1f5ff0d725896bacc5dc5a..d86f4a9be321dfb69e8d07847a13ac4e8670199c 100644 (file)
@@ -1379,10 +1379,10 @@ BEGIN
     IF NEW.osm_type = 'R' and NEW.class = 'waterway' THEN
         FOR relation IN select * from planet_osm_rels r where r.id = NEW.osm_id
         LOOP
-            FOR i IN relation.way_off+1..relation.rel_off LOOP
-                IF relation.members[2*i] in ('', 'main_stream') THEN
+            FOR i IN 1..array_upper(relation.members, 1) BY 2 LOOP
+                IF relation.members[i+1] in ('', 'main_stream') AND substring(relation.members[i],1,1) = 'w' THEN
                   --DEBUG: RAISE WARNING 'waterway parent %, child %/%', NEW.osm_id, i, relation.parts[i];
-                  FOR location IN SELECT * FROM placex WHERE osm_type = 'W' and osm_id = relation.parts[i] and class = NEW.class and type = NEW.type
+                  FOR location IN SELECT * FROM placex WHERE osm_type = 'W' and osm_id = substring(relation.members[i],2,200)::bigint and class = NEW.class and type = NEW.type
                   LOOP
                     UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = location.place_id;
                   END LOOP;
index d9def2b43a1c428c044a9f8cee505df921a3107e..a6f417f2977689bd8a2818b0e8f93f61d1d3bc51 100644 (file)
@@ -53,12 +53,12 @@ BEGIN
   END IF;
 
   place_centroid := ST_Centroid(linegeo);
-  out_partition := get_partition(place_centroid, 'us');
+  out_partition := get_partition('us');
   out_parent_place_id := null;
 
   address_street_word_id := get_name_id(make_standard_name(in_street));
   IF address_street_word_id IS NOT NULL THEN
-    FOR location IN SELECT * from getNearestNamedRoadFeature(out_partition, place_centroid, address_street_word_id) LOOP
+    FOR location IN SELECT * from getNearestNamedRoadFeature(out_partition, place_centroid, ARRAY[address_street_word_id]) LOOP
       out_parent_place_id := location.place_id;
     END LOOP;
   END IF;
index 734f669f61082774181fe0014858ef064a5f830f..870d37eca3a5de45c7d275375bab04583bc28f99 100755 (executable)
                fclose($ahPipes[1]);
 
                $iReturn = proc_close($hProcess);
-               if ($iReturn > 0)
-               {
-                       fail("pgsql returned with error code ($iReturn)");
-               }
        }
 
        function pgsqlRunDropAndRestore($sDumpFile)
                fclose($ahPipes[1]);
 
                $iReturn = proc_close($hProcess);
-               if ($iReturn > 0)
-               {
-                       fail("pgsql returned with error code ($iReturn)");
-               }
        }
 
        function passthruCheckReturn($cmd)
index ccf693000da1998c76a59287247e869f70ec3b5b..a561aaa3656cc88ebf9099027bda7c63412425c4 100755 (executable)
 
        if ($aResult['deduplicate'])
        {
+
+               $pgver = (float) CONST_Postgresql_Version;
+                if ($pgver < 9.3) {
+                       echo "ERROR: deduplicate is only currently supported in postgresql 9.3";
+                       exit;
+               }
+
                 $oDB =& getDB();
                 $sSQL = 'select partition from country_name order by country_code';
                 $aPartitions = $oDB->getCol($sSQL);
                                var_dump($aTokenSet, $sSQL);
                                exit;
                        }
-                       
+
                        $aKeep = array_shift($aTokenSet);
                        $iKeepID = $aKeep['word_id'];
 
                        foreach($aTokenSet as $aRemove)
                        {
                                $sSQL = "update search_name set";
-                               $sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.",";
-                               $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
+                               $sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID."),";
+                               $sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
                                $sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
                                $x = $oDB->query($sSQL);
                                if (PEAR::isError($x))
                                }
 
                                $sSQL = "update search_name set";
-                               $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
+                               $sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
                                $sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
                                $x = $oDB->query($sSQL);
                                if (PEAR::isError($x))
                                }
 
                                $sSQL = "update location_area_country set";
-                               $sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID;
+                               $sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
                                $sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
                                $x = $oDB->query($sSQL);
                                if (PEAR::isError($x))
                                foreach ($aPartitions as $sPartition)
                                {
                                        $sSQL = "update search_name_".$sPartition." set";
-                                       $sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.",";
-                                       $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
+                                       $sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID.")";
                                        $sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
                                        $x = $oDB->query($sSQL);
                                        if (PEAR::isError($x))
                                                exit;
                                        }
 
-                                       $sSQL = "update search_name_".$sPartition." set";
-                                       $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
-                                       $sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
-                                       $x = $oDB->query($sSQL);
-                                       if (PEAR::isError($x))
-                                       {
-                                               var_dump($x);
-                                               exit;
-                                       }
-
                                        $sSQL = "update location_area_country set";
-                                       $sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID;
+                                       $sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
                                        $sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
                                        $x = $oDB->query($sSQL);
                                        if (PEAR::isError($x))