]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge branch 'observe-bounded-viewbox-in-postcode-search' of https://github.com/mtmai...
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 14 Apr 2019 09:29:28 +0000 (11:29 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 14 Apr 2019 09:29:28 +0000 (11:29 +0200)
docs/admin/Faq.md
lib/AddressDetails.php
lib/DB.php
lib/setup/SetupClass.php
lib/setup_functions.php
lib/template/details-html.php
lib/template/details-json.php
sql/functions.sql
utils/setup.php
utils/update.php
website/hierarchy.php

index 1e874c789bf5b210985a542080ecd41829590fe0..db5e101c83dbfafc579ad03ea693b029343fdb66 100644 (file)
@@ -81,6 +81,14 @@ If you are using a flatnode file, then it may also be that the underlying
 filesystem does not fully support 'mmap'. A notable candidate is virtualbox's
 vboxfs.
 
+### nominatim UPDATE failed: ERROR: buffer 179261 is not owned by resource owner Portal
+
+Several users [reported this](https://github.com/openstreetmap/Nominatim/issues/1168) during the initial import of the database. It's 
+something Postgresql internal Nominatim doesn't control. And Postgresql forums
+suggest it's threading related but definitely some kind of crash of a process.
+Users reported either rebooting the server, different hardware or just trying
+the import again worked. 
+
 ### The website shows: "Could not get word tokens"
 
 The server cannot access your database. Add `&debug=1` to your URL
@@ -104,11 +112,8 @@ However, you can solve this the quick and dirty way by commenting out that line
 
 ### "must be an array or an object that implements Countable" warning in /usr/share/pear/DB.php
 
-As reported starting PHP 7.2. This external DB library is no longer maintained and will be replaced in future Nominatim versions. In the meantime you'd have to manually change the line near 774 from
-`if (!count($dsn)) {` to  `if (!$dsn && !count($dsn))`. [More details](https://github.com/openstreetmap/Nominatim/issues/1184)
-
-
-
+The warning started with PHP 7.2. Make sure you have at least [version 1.9.3 of PEAR DB](https://github.com/pear/DB/releases)
+installed.
 
 ### Website reports "DB Error: insufficient permissions"
 
index f52935863ce0c37d1a219fddb229d18efb1ff3a2..2d40c84f4efc35e90421798cc14f35a35bde3f68 100644 (file)
@@ -31,7 +31,7 @@ class AddressDetails
 
     private static function isAddress($aLine)
     {
-        return $aLine['isaddress'] == 't' || $aLine['type'] == 'country_code';
+        return $aLine['isaddress'] || $aLine['type'] == 'country_code';
     }
 
     public function getAddressDetails($bAll = false)
@@ -49,7 +49,7 @@ class AddressDetails
         $sPrevResult = '';
 
         foreach ($this->aAddressLines as $aLine) {
-            if ($aLine['isaddress'] == 't' && $sPrevResult != $aLine['localname']) {
+            if ($aLine['isaddress'] && $sPrevResult != $aLine['localname']) {
                 $sPrevResult = $aLine['localname'];
                 $aParts[] = $sPrevResult;
             }
index 033e23f7f593512229cc3e6752a6031090ca4962..17dfe67d3a9e02a02fba8e5c6fd26e070d7fe235 100644 (file)
@@ -229,12 +229,6 @@ class DB
         return 'ARRAY['.join(',', $a).']';
     }
 
-    public function getLastError()
-    {
-        // https://secure.php.net/manual/en/pdo.errorinfo.php
-        return $this->connection->errorInfo();
-    }
-
     /**
      * Check if a table exists in the database. Returns true if it does.
      *
index 9fcec2f01e63c994f939134c3f5864e7dac6c39e..c14190c3a1be66020216defca9686262ac44f3f0 100755 (executable)
@@ -144,9 +144,7 @@ class SetupFunctions
         }
 
         // Try accessing the C module, so we know early if something is wrong
-        if (!checkModulePresence()) {
-            fail('error loading nominatim.so module');
-        }
+        checkModulePresence(); // raises exception on failure
 
         if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
             echo 'Error: you need to download the country_osm_grid first:';
@@ -227,11 +225,9 @@ class SetupFunctions
     {
         info('Create Functions');
 
-        // Try accessing the C module, so we know eif something is wrong
-        // update.php calls this function
-        if (!checkModulePresence()) {
-            fail('error loading nominatim.so module');
-        }
+        // Try accessing the C module, so we know early if something is wrong
+        checkModulePresence(); // raises exception on failure
+
         $this->createSqlFunctions();
     }
 
index 89736ae0515c53039403014a3180e9413e09e18d..43f30a090dfff4939f4f511e786e2615d467c1c1 100755 (executable)
@@ -17,8 +17,9 @@ function checkInFile($sOSMFile)
 
 function checkModulePresence()
 {
-    // Try accessing the C module, so we know early if something is wrong
-    // and can simply error out.
+    // Try accessing the C module, so we know early if something is wrong.
+    // Raises Nominatim\DatabaseError on failure
+
     $sModulePath = CONST_Database_Module_Path;
     $sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
     $sSQL .= $sModulePath . "/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
@@ -26,15 +27,5 @@ function checkModulePresence()
 
     $oDB = new \Nominatim\DB();
     $oDB->connect();
-
-    $bResult = true;
-    try {
-        $oDB->exec($sSQL);
-    } catch (\Nominatim\DatabaseError $e) {
-        echo "\nERROR: Failed to load nominatim module. Reason:\n";
-        echo $oDB->getLastError()[2] . "\n\n";
-        $bResult = false;
-    }
-
-    return $bResult;
+    $oDB->exec($sSQL, null, 'Database server failed to load '.$sModulePath.'/nominatim.so module');
 }
index 01583e5f789499a27a28dbdb4d9e3048c72b761e..9ef595634f5c0a1e3d64014cd3c114ad05dbbc69 100644 (file)
@@ -61,7 +61,7 @@
 
 
     function _one_row($aAddressLine){
-        $bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f');
+        $bNotUsed = !$aAddressLine['isaddress'];
 
         echo '<tr class="' . ($bNotUsed?'notused':'') . '">'."\n";
         echo '  <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>')."</td>\n";
                     if ($aPointDetails['calculated_importance']) {
                         kv('Importance'    , $aPointDetails['calculated_importance'].($aPointDetails['importance']?'':' (estimated)') );
                     }
-                    kv('Coverage'        , ($aPointDetails['isarea']=='t'?'Polygon':'Point') );
+                    kv('Coverage'        , ($aPointDetails['isarea']?'Polygon':'Point') );
                     kv('Centre Point'    , $aPointDetails['lat'].','.$aPointDetails['lon'] );
                     kv('OSM'             , osmLink($aPointDetails) );
                     if ($aPointDetails['wikipedia'])
index 06554aba68f2143c6a24b46ce9cdb39e9cfc3362..4afb1b0bc4e717dcd7609d8e5630c6500b566da9 100644 (file)
@@ -33,7 +33,7 @@ if ($aPointDetails['icon']) {
 $aPlaceDetails['rank_address'] = (int) $aPointDetails['rank_address'];
 $aPlaceDetails['rank_search'] = (int) $aPointDetails['rank_search'];
 
-$aPlaceDetails['isarea'] = ($aPointDetails['isarea'] == 't');
+$aPlaceDetails['isarea'] = $aPointDetails['isarea'];
 $aPlaceDetails['centroid'] = array(
                               'type' => 'Point',
                               'coordinates' => array( (float) $aPointDetails['lon'], (float) $aPointDetails['lat'] )
index 73790353059a683cdfec0db2f101e1dbc5935f4e..8ecb8c2c1aa1da18a20d31afae360534127476c2 100644 (file)
@@ -2318,6 +2318,7 @@ DECLARE
   searchhousename HSTORE;
   searchrankaddress INTEGER;
   searchpostcode TEXT;
+  postcode_isaddress BOOL;
   searchclass TEXT;
   searchtype TEXT;
   countryname HSTORE;
@@ -2325,6 +2326,8 @@ BEGIN
   -- The place ein question might not have a direct entry in place_addressline.
   -- Look for the parent of such places then and save if in for_place_id.
 
+  postcode_isaddress := true;
+
   -- first query osmline (interpolation lines)
   IF in_housenumber >= 0 THEN
     SELECT parent_place_id, country_code, in_housenumber::text, 30, postcode,
@@ -2441,7 +2444,10 @@ BEGIN
       searchcountrycode := location.country_code;
     END IF;
     IF location.type in ('postcode', 'postal_code') THEN
-      location.isaddress := FALSE;
+      postcode_isaddress := false;
+      IF location.osm_type != 'R' THEN
+        location.isaddress := FALSE;
+      END IF;
     END IF;
     countrylocation := ROW(location.place_id, location.osm_type, location.osm_id,
                            location.name, location.class, location.type,
@@ -2485,7 +2491,7 @@ BEGIN
 
   IF searchpostcode IS NOT NULL THEN
     location := ROW(null, null, null, hstore('ref', searchpostcode), 'place',
-                    'postcode', null, true, true, 5, 0)::addressline;
+                    'postcode', null, false, postcode_isaddress, 5, 0)::addressline;
     RETURN NEXT location;
   END IF;
 
index 66b719205705d2b68be4dafc6fbf7c6ccdce9109..8ad96a9524eac81360106412b00c3070ea1458a0 100644 (file)
@@ -84,9 +84,7 @@ if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
 }
 
 // Try accessing the C module, so we know early if something is wrong
-if (!checkModulePresence()) {
-    fail('error loading nominatim.so module');
-}
+checkModulePresence(); // raises exception on failure
 
 if ($aCMDResult['import-data'] || $aCMDResult['all']) {
     $bDidSomething = true;
index a18c17211861d39695771d94e734ebf5859b4727..c3620b063c80fa06101626691a4dd6dc55770b98 100644 (file)
@@ -352,7 +352,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
         $sBatchEnd = $aLastState['lastimportdate'];
         $iEndSequence = $aLastState['sequence_id'];
 
-        if ($aLastState['indexed'] == 't') {
+        if ($aLastState['indexed']) {
             // Sleep if the update interval has not yet been reached.
             $fNextUpdate = $aLastState['unix_ts'] + CONST_Replication_Update_Interval;
             if ($fNextUpdate > $fStartTime) {
index b31b85d1090954ed3f681e720ff695a13c61b084..87e8a0afbb258fdaefd03d2169baac6d5522fcbc 100644 (file)
@@ -121,7 +121,7 @@ if (!empty($aParentOfLines)) {
             echo '<div class="line">';
             echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
             echo ' (';
-            echo '<span class="area">'.($aAddressLine['isarea']=='t'?'Polygon':'Point').'</span>';
+            echo '<span class="area">'.($aAddressLine['isarea']?'Polygon':'Point').'</span>';
             if ($sOSMType) echo ', <span class="osm"><span class="label"></span>'.$sOSMType.' '.osmLink($aAddressLine).'</span>';
             echo ', <a href="hierarchy.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
             echo ', '.$aAddressLine['area'];