]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 1 Jun 2017 19:51:38 +0000 (21:51 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 1 Jun 2017 19:51:38 +0000 (21:51 +0200)
1  2 
lib/lib.php
sql/functions.sql

diff --combined lib/lib.php
index 7553117f7ad0da4f56674924b61f4709eab3444a,9691f88a371b159cf7d62190674402a392be3ded..941f6a1d9bcdcba817695bc3a13e0005c7618c5c
@@@ -475,11 -475,14 +475,14 @@@ function getResultDiameter($aResult
  
  function javascript_renderData($xVal, $iOptions = 0)
  {
-     if (defined('PHP_VERSION_ID') && PHP_VERSION_ID > 50400)
-         $iOptions |= JSON_UNESCAPED_UNICODE;
+     $iOptions |= JSON_UNESCAPED_UNICODE;
+     if (isset($_GET['pretty']) && in_array(strtolower($_GET['pretty']), array('1', 'true'))) {
+         $iOptions |= JSON_PRETTY_PRINT;
+     }
      $jsonout = json_encode($xVal, $iOptions);
  
-     if (! isset($_GET['json_callback'])) {
+     if (!isset($_GET['json_callback'])) {
          header("Content-Type: application/json; charset=UTF-8");
          echo $jsonout;
      } else {
@@@ -623,10 -626,10 +626,10 @@@ function geometryText2Points($geometry_
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
          //
 -    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
 +/*    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
          //
          preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
 -        //
 +        */
      } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
          //
          $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
diff --combined sql/functions.sql
index 691ba85e39716700e568565d620a98d3e324904f,b60ef97facea5b10285598affea2258b601541ef..434ab3182110e9653f1bb190e86352faa9b7f883
@@@ -1140,6 -1140,8 +1140,8 @@@ DECLAR
    nameaddress_vector INTEGER[];
  
    linked_node_id BIGINT;
+   linked_importance FLOAT;
+   linked_wikipedia TEXT;
  
    result BOOLEAN;
  BEGIN
  
            -- keep a note of the node id in case we need it for wikipedia in a bit
            linked_node_id := linkedPlacex.osm_id;
+           select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
          END LOOP;
  
        END LOOP;
  
                -- keep a note of the node id in case we need it for wikipedia in a bit
                linked_node_id := linkedPlacex.osm_id;
+               select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
              END IF;
  
            END LOOP;
  
          -- keep a note of the node id in case we need it for wikipedia in a bit
          linked_node_id := linkedPlacex.osm_id;
+         select language||':'||title,importance from get_wikipedia_match(linkedPlacex.extratags, NEW.country_code) INTO linked_wikipedia,linked_importance;
        END LOOP;
      END IF;
  
        END IF;
      END IF;
  
-     -- Did we gain a wikipedia tag in the process? then we need to recalculate our importance
-     IF NEW.importance is null THEN
-       select language||':'||title,importance from get_wikipedia_match(NEW.extratags, NEW.country_code) INTO NEW.wikipedia,NEW.importance;
+     -- Use the maximum importance if a one could be computed from the linked object.
+     IF linked_importance is not null AND
+         (NEW.importance is null or NEW.importance < linked_importance) THEN
+         NEW.importance = linked_importance;
      END IF;
      -- Still null? how about looking it up by the node id
      IF NEW.importance IS NULL THEN
        select language||':'||title,importance from wikipedia_article where osm_type = 'N'::char(1) and osm_id = linked_node_id order by importance desc limit 1 INTO NEW.wikipedia,NEW.importance;
@@@ -2374,7 -2381,7 +2381,7 @@@ BEGI
        CASE WHEN class = 'place' and type = 'postcode' THEN hstore('name', postcode) ELSE name END as name,
        CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class,
        CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type,
 -      admin_level, fromarea, isaddress,
 +      admin_level, fromarea, isaddress and linked_place_id is NULL as isaddress,
        CASE WHEN address_place_id = for_place_id AND rank_address = 0 THEN 100 WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address,
        distance,country_code,postcode
        from place_addressline join placex on (address_place_id = placex.place_id)