X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b955883a5bff28acbc6c5c62254cf6d479d8c111..11a6b8a6e23a150d6e9e6d0094ef4613df4650a5:/sql/functions.sql?ds=sidebyside

diff --git a/sql/functions.sql b/sql/functions.sql
index ac726cb3..9b083609 100644
--- a/sql/functions.sql
+++ b/sql/functions.sql
@@ -1380,9 +1380,12 @@ BEGIN
         FOR relation IN select * from planet_osm_rels r where r.id = NEW.osm_id and r.parts != array[]::bigint[]
         LOOP
             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
+                IF relation.members[i+1] in ('', 'main_stream', 'side_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 = substring(relation.members[i],2,200)::bigint 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
+                    and ( relation.members[i+1] != 'side_stream' or NEW.name->'name' = name->'name')
                   LOOP
                     UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = location.place_id;
                   END LOOP;
@@ -2970,14 +2973,14 @@ BEGIN
       wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3}).wikipedia.org/wiki/',E'\\2:');
       wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3}).wikipedia.org/w/index.php\\?title=',E'\\2:');
       wiki_article := regexp_replace(wiki_article,E'^(.*?)/([a-z]{2,3})/wiki/',E'\\2:');
-      wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3})[=:]',E'\\2:');
+      --wiki_article := regexp_replace(wiki_article,E'^(.*?)([a-z]{2,3})[=:]',E'\\2:');
       wiki_article := replace(wiki_article,' ','_');
-      wiki_article_title := trim(split_part(wiki_article, ':', 2));
-      IF wiki_article_title IS NULL OR wiki_article_title = '' THEN
+      IF strpos(wiki_article, ':') IN (3,4) THEN
+        wiki_article_language := lower(trim(split_part(wiki_article, ':', 1)));
+        wiki_article_title := trim(substr(wiki_article, strpos(wiki_article, ':')+1));
+      ELSE
         wiki_article_title := trim(wiki_article);
         wiki_article_language := CASE WHEN langs[i] = 'english' THEN 'en' WHEN langs[i] = 'country' THEN get_country_language_code(country_code) ELSE langs[i] END;
-      ELSE
-        wiki_article_language := lower(trim(split_part(wiki_article, ':', 1)));
       END IF;
 
       select wikipedia_article.language,wikipedia_article.title,wikipedia_article.importance
