]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 3 Jul 2019 21:18:35 +0000 (23:18 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 3 Jul 2019 21:18:35 +0000 (23:18 +0200)
lib/Phrase.php
lib/log.php
sql/functions.sql
test/bdd/db/update/interpolation.feature
test/php/Nominatim/PhraseTest.php

index 2e90537e10c48c447fe450da388e8fef8adb5d52..e2643e878ed40a3bb22533600603647418e98011 100644 (file)
@@ -9,8 +9,8 @@ namespace Nominatim;
  */
 class Phrase
 {
-    public const MAX_WORDSET_LEN = 20;
-    public const MAX_WORDSETS = 100;
+    const MAX_WORDSET_LEN = 20;
+    const MAX_WORDSETS = 100;
 
     // Complete phrase as a string.
     private $sPhrase;
index ae4253c0f23861da1d8c4fedc48a415a0de19cac..25ed75cb2c7117411d013a5b78931129496cfec3 100644 (file)
@@ -36,7 +36,7 @@ function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
             $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
         else $sUserAgent = '';
         $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
-        $sSQL .= ' values ('.
+        $sSQL .= ' values (';
         $sSQL .= join(',', $oDB->getDBQuotedList(array(
             $sType,
             $hLog[0],
@@ -48,7 +48,7 @@ function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
             $hLog[3]
         )));
         $sSQL .= ')';
-        $oDB->query($sSQL);
+        $oDB->exec($sSQL);
     }
 
     return $hLog;
@@ -67,7 +67,7 @@ function logEnd(&$oDB, $hLog, $iNumResults)
         $sSQL .= ' where starttime = '.$oDB->getDBQuoted($hLog[0]);
         $sSQL .= ' and ipaddress = '.$oDB->getDBQuoted($hLog[1]);
         $sSQL .= ' and query = '.$oDB->getDBQuoted($hLog[2]);
-        $oDB->query($sSQL);
+        $oDB->exec($sSQL);
     }
 
     if (CONST_Log_File) {
index 97f78d2432bab2db25b1699c8bb3bd930c7417b7..c97d11da33473976d7489e5999db7f45d47cfda8 100644 (file)
@@ -768,6 +768,28 @@ END;
 $$
 LANGUAGE plpgsql;
 
+CREATE OR REPLACE FUNCTION osmline_reinsert(node_id BIGINT, geom GEOMETRY)
+  RETURNS BOOLEAN
+  AS $$
+DECLARE
+  existingline RECORD;
+BEGIN
+   SELECT w.id FROM planet_osm_ways w, location_property_osmline p
+     WHERE p.linegeo && geom and p.osm_id = w.id and p.indexed_status = 0
+           and node_id = any(w.nodes) INTO existingline;
+
+   IF existingline.id is not NULL THEN
+       DELETE FROM location_property_osmline WHERE osm_id = existingline.id;
+       INSERT INTO location_property_osmline (osm_id, address, linegeo)
+         SELECT osm_id, address, geometry FROM place
+           WHERE osm_type = 'W' and osm_id = existingline.id;
+   END IF;
+
+   RETURN true;
+END;
+$$
+LANGUAGE plpgsql;
+
 
 CREATE OR REPLACE FUNCTION osmline_insert() RETURNS TRIGGER
   AS $$
@@ -908,7 +930,10 @@ BEGIN
 
   RETURN NEW; -- %DIFFUPDATES% The following is not needed until doing diff updates, and slows the main index process down
 
-  IF NEW.rank_address > 0 THEN
+  IF NEW.osm_type = 'N' and NEW.rank_search > 28 THEN
+      -- might be part of an interpolation
+      result := osmline_reinsert(NEW.osm_id, NEW.geometry);
+  ELSEIF NEW.rank_address > 0 THEN
     IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN
       -- Performance: We just can't handle re-indexing for country level changes
       IF st_area(NEW.geometry) < 1 THEN
@@ -1230,6 +1255,8 @@ BEGIN
   END IF;
 
   --DEBUG: RAISE WARNING 'Copy over address tags';
+  -- housenumber is a computed field, so start with an empty value
+  NEW.housenumber := NULL;
   IF NEW.address is not NULL THEN
       IF NEW.address ? 'conscriptionnumber' THEN
         i := getorcreate_housenumber_id(make_standard_name(NEW.address->'conscriptionnumber'));
@@ -2198,12 +2225,13 @@ BEGIN
         indexed_status = 2,
         geometry = NEW.geometry
         where place_id = existingplacex.place_id;
-
       -- if a node(=>house), which is part of a interpolation line, changes (e.g. the street attribute) => mark this line for reparenting 
       -- (already here, because interpolation lines are reindexed before nodes, so in the second call it would be too late)
-      IF NEW.osm_type='N' and NEW.class='place' and NEW.type='house' THEN
-          -- Is this node part of an interpolation line? search for it in location_property_osmline and mark the interpolation line for reparenting
-          update location_property_osmline p set indexed_status = 2 from planet_osm_ways w where p.linegeo && NEW.geometry and p.osm_id = w.id and NEW.osm_id = any(w.nodes);
+      IF NEW.osm_type='N'
+         and (coalesce(existing.address, ''::hstore) != coalesce(NEW.address, ''::hstore)
+             or existing.geometry::text != NEW.geometry::text)
+      THEN
+          result:= osmline_reinsert(NEW.osm_id, NEW.geometry);
       END IF;
 
       -- linked places should get potential new naming and addresses
index f7f7dddbf7106cb0213b8a948d0ec0bbc428666a..27ac552e4d907315b2c711d756ddefdc317bf9b5 100644 (file)
@@ -275,7 +275,6 @@ Feature: Update of address interpolations
           | parent_place_id | start | end |
           | W2              | 2     | 6 |
 
-    @Fail
     Scenario: housenumber added in middle of interpolation
       Given the grid
           | 1 |  |  |   |  | 2 |
@@ -334,7 +333,6 @@ Feature: Update of address interpolations
           | parent_place_id | start | end | geometry |
           | W1              | 2     | 10  | 3,4,5    |
 
-    @Fail
     Scenario: Change the start housenumber
       Given the grid
           | 1 |  | 2 |
index c23d648338278a270cecf097669f60cf22a08f5e..ab031bb0b0cdedfd3bb1b449a77c788f4de45eb3 100644 (file)
@@ -113,9 +113,9 @@ class PhraseTest extends \PHPUnit\Framework\TestCase
 
         $oPhrase = new Phrase(join(' ', array_fill(0, 18, 'a')), '');
         $oPhrase->computeWordSets(new TokensFullSet());
-        $this->assertEquals(Phrase::MAX_WORDSETS, count($oPhrase->getWordSets()));
+        $this->assertEquals(100, count($oPhrase->getWordSets()));
         $oPhrase->invertWordSets();
-        $this->assertEquals(Phrase::MAX_WORDSETS, count($oPhrase->getWordSets()));
+        $this->assertEquals(100, count($oPhrase->getWordSets()));
     }