]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 1 Dec 2019 19:47:33 +0000 (20:47 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 1 Dec 2019 19:47:33 +0000 (20:47 +0100)
CONTRIBUTING.md
README.md
docs/admin/Import-and-Update.md
docs/admin/Installation.md
lib/AddressDetails.php
lib/SearchDescription.php
lib/setup/SetupClass.php
lib/template/details-html.php
test/bdd/api/search/queries.feature
test/bdd/environment.py
website/js/nominatim-ui.js

index cd8d1cc1bd7c16d042b356eb385f116d787052fa..89b76e3b18e8f098987fe0a47b1b98ce06ccf5e2 100644 (file)
@@ -15,9 +15,9 @@ Please make sure to add the following information:
  * the result you are getting
  * the expected result, preferably a link to the OSM object you want to find,
    otherwise an address that is as precise as possible
- To get the link to the OSM object, you can try the following:
+
+To get the link to the OSM object, you can try the following:
+
  * go to https://openstreetmap.org
  * zoom to the area of the map where you expect the result and
    zoom in as much as possible
@@ -26,7 +26,7 @@ Please make sure to add the following information:
  * find the object of interest in the list that appears on the left side
  * click on the object and report the URL back that the browser shows
 
-### When Reporting Problems with your Installation...
+### When Reporting Bugs...
 
 Please add the following information to your issue:
 
@@ -38,6 +38,9 @@ Please add the following information to your issue:
    if you run from the git repo, the output of `git rev-parse HEAD`)
  * (if applicable) exact command line of the command that was causing the issue
 
+Bug reports that do not include extensive information about your system,
+about the problem and about what you have been trying to debug the problem
+will be closed.
 
 ## Workflow for Pull Requests
 
index a9a5a3e24c638dca13661485c836fc2964b86feb..1ae0dab029ab6c194e59f468eb2030a3b799ff3d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -19,8 +19,16 @@ https://nominatim.org/release-docs/develop/ .
 Installation
 ============
 
+**Nominatim is a complex piece of software and runs in a complex environment.
+Installing and running Nominatim is something for experienced system
+administrators only who can do some trouble-shooting themselves. We are sorry,
+but we can not provide installation support. We are all doing this in our free
+time and there is just so much of that time to go around. Do not open issues in
+our bug tracker if you need help. You can ask questions on the mailing list
+(see below) or on [help.openstreetmap.org](https://help.openstreetmap.org/).**
+
 The latest stable release can be downloaded from https://nominatim.org.
-There you can also find [installation instructions for the release](https://nominatim.org/release-docs/latest/admin/Installation).
+There you can also find [installation instructions for the release](https://nominatim.org/release-docs/latest/admin/Installation), as well as an extensive [Troubleshooting/FAQ section](https://nominatim.org/release-docs/latest/admin/Faq/).
 
 Detailed installation instructions for the development version can be
 found at [nominatim.org](https://nominatim.org/release-docs/develop/admin/Installation)
index 246fcddab1ad615cb127af75317de3579505c762..afda83b2dc00f85a6dd4134b2df3028807a9302b 100644 (file)
@@ -29,7 +29,7 @@ Add to your `settings/local.php`:
     @define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
 
 Replace the second part with a suitable path on your system and make sure
-the directory exists. There should be at least 40GB of free space.
+the directory exists. There should be at least 64GB of free space.
 
 ## Downloading additional data
 
@@ -62,7 +62,7 @@ involve a GB or US postcode. This data can be optionally downloaded:
 
 In its default setup Nominatim is configured to import the full OSM data
 set for the entire planet. Such a setup requires a powerful machine with
-at least 32GB of RAM and around 800GB of SSD hard disks. Depending on your
+at least 64GB of RAM and around 800GB of SSD hard disks. Depending on your
 use case there are various ways to reduce the amount of data imported. This
 section discusses these methods. They can also be combined.
 
@@ -124,7 +124,7 @@ The style can be changed with the configuration `CONST_Import_Style`.
 To give you an idea of the impact of using the different styles, the table
 below gives rough estimates of the final database size after import of a
 2018 planet and after using the `--drop` option. It also shows the time
-needed for the import on a machine with 32GB RAM, 4 CPUS and SSDs. Note that
+needed for the import on a machine with 64GB RAM, 4 CPUS and SSDs. Note that
 the given sizes are just an estimate meant for comparison of style requirements.
 Your planet import is likely to be larger as the OSM data grows with time.
 
@@ -135,7 +135,7 @@ street    |   42h        |  400 GB    |  180 GB
 address   |   59h        |  500 GB    |  260 GB
 full      |   80h        |  575 GB    |  300 GB
 
-You can also customize the styles further. For an description of the
+You can also customize the styles further. For a description of the
 style format see [the development section](../develop/Import.md).
 
 ## Initial import of the data
@@ -147,18 +147,44 @@ Download the data to import and load the data with the following command
 from the build directory:
 
 ```sh
-./utils/setup.php --osm-file <data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log
+./utils/setup.php --osm-file <data file> --all 2>&1 | tee setup.log
 ```
 
-The `--osm2pgsql-cache` parameter is optional but strongly recommended for
-planet imports. It sets the node cache size for the osm2pgsql import part
-(see `-C` parameter in osm2pgsql help). As a rule of thumb, this should be
-about the same size as the file you are importing but never more than
-2/3 of RAM available. If your machine starts swapping reduce the size.
-
-Computing word frequency for search terms can improve the performance of
-forward geocoding in particular under high load as it helps PostgreSQL's query
-planner to make the right decisions. To recompute word counts run:
+***Note for full planet imports:*** Even on a perfectly configured machine
+the import of a full planet takes at least 2 days. Once you see messages
+with `Rank .. ETA` appear, the indexing process has started. This part takes
+the most time. There are 30 ranks to process. Rank 26 and 30 are the most complex.
+They take each about a third of the total import time. If you have not reached
+rank 26 after two days of import, it is worth revisiting your system
+configuration as it may not be optimal for the import.
+
+### Notes on memory usage
+
+In the first step of the import Nominatim uses osm2pgsql to load the OSM data
+into the PostgreSQL database. This step is very demanding in terms of RAM usage.
+osm2pgsql and PostgreSQL are running in parallel at this point. PostgreSQL
+blocks at least the part of RAM that has been configured with the
+`shared_buffers` parameter during [PostgreSQL tuning](Installation#PostgreSQL_tuning)
+and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
+its internal data structures, potentially more when it has to process very large
+relations. In addition it needs to maintain a cache for node locations. The size
+of this cache can be configured with the parameter `--osm2pgsql-cache`.
+
+When importing with a flatnode file, it is best to disable the node cache
+completely and leave the memory for the flatnode file. Nominatim will do this
+by default, so you do not need to configure anything in this case.
+
+For imports without a flatnode file, set `--osm2pgsql-cache` approximately to
+the size of the OSM pbf file (in MB) you are importing. Make sure you leave
+enough RAM for PostgreSQL and osm2pgsql as mentioned above. If the system starts
+swapping or you are getting out-of-memory errors, reduce the cache size or
+even consider using a flatnode file.
+
+## Tuning the database
+
+Accurate word frequency information for search terms helps PostgreSQL's query
+planner to make the right decisions. Recomputing them can improve the performance
+of forward geocoding in particular under high load. To recompute word counts run:
 
 ```sh
 ./utils/update.php --recompute-word-counts
@@ -176,7 +202,8 @@ you also need to enable these key phrases like this:
     ./utils/specialphrases.php --wiki-import > specialphrases.sql
     psql -d nominatim -f specialphrases.sql
 
-Note that this command downloads the phrases from the wiki link above.
+Note that this command downloads the phrases from the wiki link above. You
+need internet access for the step.
 
 
 ## Installing Tiger housenumber data for the US
index d07249276177c8413bc8dd48c584929ba6dd068a..89afd2bcdda3cb011c13d0264c166a24fd48a7e8 100644 (file)
@@ -29,7 +29,8 @@ For compiling:
   * a recent C++ compiler
 
 Nominatim comes with its own version of osm2pgsql. See the
-osm2pgsql README for additional dependencies required for compiling osm2pgsql.
+[osm2pgsql README](https://github.com/openstreetmap/osm2pgsql/blob/master/README.md#building)
+for additional dependencies required for compiling osm2pgsql.
 
 For running tests:
 
@@ -45,7 +46,6 @@ For running Nominatim:
   * [PHP](https://php.net) (7.0 or later)
   * PHP-pgsql
   * PHP-intl (bundled with PHP)
-  * [PEAR::DB](https://pear.php.net/package/DB)
   * a webserver (apache or nginx are recommended)
 
 For running continuous updates:
@@ -55,15 +55,15 @@ For running continuous updates:
 ### Hardware
 
 A minimum of 2GB of RAM is required or installation will fail. For a full
-planet import 32GB of RAM or more are strongly recommended.
+planet import 64GB of RAM or more are strongly recommended. Do not report
+out of memory problems if you have less than 64GB RAM.
 
-For a full planet install you will need at least 700GB of hard disk space
+For a full planet install you will need at least 800GB of hard disk space
 (take into account that the OSM database is growing fast). SSD disks
 will help considerably to speed up import and queries.
 
-On a 6-core machine with 32GB RAM and SSDs the import of a full planet takes
-a bit more than 2 days. Without SSDs 7-8 days are more realistic.
-
+Even on a well configured machine the import of a full planet takes
+at least 2 days. Without SSDs 7-8 days are more realistic.
 
 ## Setup of the server
 
@@ -73,17 +73,21 @@ You might want to tune your PostgreSQL installation so that the later steps
 make best use of your hardware. You should tune the following parameters in
 your `postgresql.conf` file.
 
-    shared_buffers (2GB)
-    maintenance_work_mem (10GB)
-    work_mem (50MB)
-    effective_cache_size (24GB)
+    shared_buffers = 2GB
+    maintenance_work_mem = (10GB)
+    autovacuum_work_mem = 2GB
+    work_mem = (50MB)
+    effective_cache_size = (24GB)
     synchronous_commit = off
     checkpoint_segments = 100 # only for postgresql <= 9.4
+    max_wal_size = 1GB # postgresql > 9.4
     checkpoint_timeout = 10min
     checkpoint_completion_target = 0.9
 
 The numbers in brackets behind some parameters seem to work fine for
-32GB RAM machine. Adjust to your setup.
+64GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
+means that PostgreSQL needs to run checkpoints less often but it does require
+the additional space on your disk.
 
 For the initial import, you should also set:
 
index 783a0fdae673b8b155b5a823cd913d201196cd08..61823b4ce9dc504010ed33e67aeb575df400d047 100644 (file)
@@ -76,14 +76,14 @@ class AddressDetails
                 $bFallback = true;
             }
 
-            $sName = false;
-            if (isset($aLine['localname']) && $aLine['localname']) {
+            $sName = null;
+            if (isset($aLine['localname']) && $aLine['localname']!=='') {
                 $sName = $aLine['localname'];
-            } elseif (isset($aLine['housenumber']) && $aLine['housenumber']) {
+            } elseif (isset($aLine['housenumber']) && $aLine['housenumber']!=='') {
                 $sName = $aLine['housenumber'];
             }
 
-            if ($sName) {
+            if (isset($sName)) {
                 $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel']) ? $aTypeLabel['simplelabel'] : $aTypeLabel['label']);
                 $sTypeLabel = str_replace(' ', '_', $sTypeLabel);
                 if (!isset($aAddress[$sTypeLabel])
@@ -97,6 +97,7 @@ class AddressDetails
                 }
             }
         }
+
         return $aAddress;
     }
 
index 506d4202253f61f909c46f3d1c08275b2c12faa9..4fafbec2b21c9899fb1e35c51ac8241647876b58 100644 (file)
@@ -447,8 +447,8 @@ class SearchDescription
                 $iLimit
             );
 
-            //now search for housenumber, if housenumber provided
-            if ($this->sHouseNumber && !empty($aResults)) {
+            // Now search for housenumber, if housenumber provided. Can be zero.
+            if (($this->sHouseNumber || $this->sHouseNumber === '0') && !empty($aResults)) {
                 // Downgrade the rank of the street results, they are missing
                 // the housenumber.
                 foreach ($aResults as $oRes) {
index 2fdb3926d59ecc23d2f26ecc75e94776f3b81ca8..12a1bb0d7b6a7549c2dc0a772a2b6a216a0c8d9d 100755 (executable)
@@ -29,10 +29,13 @@ class SetupFunctions
             warn('resetting threads to '.$this->iInstances);
         }
 
-        // Assume we can steal all the cache memory in the box (unless told otherwise)
         if (isset($aCMDResult['osm2pgsql-cache'])) {
             $this->iCacheMemory = $aCMDResult['osm2pgsql-cache'];
+        } elseif (!is_null(CONST_Osm2pgsql_Flatnode_File)) {
+            // When flatnode files are enabled then disable cache per default.
+            $this->iCacheMemory = 0;
         } else {
+            // Otherwise: Assume we can steal all the cache memory in the box.
             $this->iCacheMemory = getCacheMemoryMB();
         }
 
index 9b76efc12f90977a4b91927a75be8e35bb950dc2..cfba6eb39d5f2344730de4ad68fd7bd8703094e3 100644 (file)
@@ -64,7 +64,7 @@
         $bNotUsed = isset($aAddressLine['isaddress']) && !$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";
+        echo '  <td class="name">'.(trim($aAddressLine['localname'])!==null?$aAddressLine['localname']:'<span class="noname">No Name</span>')."</td>\n";
         echo '  <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . "</td>\n";
         echo '  <td>' . osmLink($aAddressLine) . "</td>\n";
         echo '  <td>' . (isset($aAddressLine['rank_address']) ? $aAddressLine['rank_address'] : '') . "</td>\n";
index cf5a00c9c093ebb37be08bc43d9a8b4b726114f4..8c2fa2b86c2d7c3de1275f761eda639aeb4ab522 100644 (file)
@@ -55,6 +55,22 @@ Feature: Search queries
           | country      | Uruguay |
           | country_code | uy |
 
+    Scenario Outline: Housenumber 0 can be found
+        When sending <format> search query "Pham Hung Road 0" with address
+        Then results contain
+          | display_name |
+          | ^.*, 0,.* |
+        And result addresses contain
+          | house_number |
+          | 0     |
+
+    Examples:
+        | format |
+        | xml |
+        | json |
+        | jsonv2 |
+        | geojson |
+
     @Tiger
     Scenario: TIGER house number
         When sending json search query "323 22nd Street Southwest, Huron"
index b12b648129f236af53b789a85b1cc74c01285960..f0658c335f95530cce4a2d82e6e268e7e6db7030 100644 (file)
@@ -82,6 +82,7 @@ class NominatimEnvironment(object):
                  (';password=' + self.db_pass) if self.db_pass else ''
                  ))
         f.write("@define('CONST_Osm2pgsql_Flatnode_File', null);\n")
+        f.write("@define('CONST_Import_Style', CONST_BasePath.'/settings/import-full.style');\n")
         f.close()
 
     def cleanup(self):
index 32e7cbda8fc3321b1fd4a6b0389b91bb900a764d..d631e7aa4861db4a63f54fa5715287f52e4e4686 100644 (file)
@@ -32,7 +32,6 @@ jQuery(document).ready(function(){
             });
 
     L.tileLayer(nominatim_map_init.tile_url, {
-        noWrap: true, // otherwise we end up with click coordinates like latitude -728
         // moved to footer
         attribution: (nominatim_map_init.tile_attribution || null ) //'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
     }).addTo(map);
@@ -78,6 +77,9 @@ jQuery(document).ready(function(){
 
     function display_map_position(mouse_lat_lng){
 
+        if (mouse_lat_lng) {
+            mouse_lat_lng = map.wrapLatLng(mouse_lat_lng);
+        }
         html_mouse = "mouse position " + (mouse_lat_lng ? [mouse_lat_lng.lat.toFixed(5), mouse_lat_lng.lng.toFixed(5)].join(',') : '-');
         html_click = "last click: " + (last_click_latlng ? [last_click_latlng.lat.toFixed(5),last_click_latlng.lng.toFixed(5)].join(',') : '-');
 
@@ -92,9 +94,10 @@ jQuery(document).ready(function(){
 
         $('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
 
+        var center_lat_lng = map.wrapLatLng(map.getCenter());
         var reverse_params = {
-            lat: map.getCenter().lat.toFixed(5),
-            lon: map.getCenter().lng.toFixed(5),
+            lat: center_lat_lng.lat.toFixed(5),
+            lon: center_lat_lng.lng.toFixed(5),
             zoom: map.getZoom(),
             format: 'html'
         }
@@ -134,12 +137,22 @@ jQuery(document).ready(function(){
 
 
     function map_viewbox_as_string() {
-        // since .toBBoxString() doesn't round numbers
+        var bounds = map.getBounds();
+        var west = bounds.getWest();
+        var east = bounds.getEast();
+
+        if ((east - west) >= 360) { // covers more than whole planet
+            west = map.getCenter().lng-179.999;
+            east = map.getCenter().lng+179.999;
+        }
+        east = L.latLng(77, east).wrap().lng;
+        west = L.latLng(77, west).wrap().lng;
+
         return [
-            map.getBounds().getSouthWest().lng.toFixed(5), // left
-            map.getBounds().getNorthEast().lat.toFixed(5), // top
-            map.getBounds().getNorthEast().lng.toFixed(5), // right
-            map.getBounds().getSouthWest().lat.toFixed(5)  // bottom
+            west.toFixed(5), // left
+            bounds.getNorth().toFixed(5), // top
+            east.toFixed(5), // right
+            bounds.getSouth().toFixed(5) // bottom
         ].join(',');
     }
     function map_link_to_osm(){
@@ -236,7 +249,7 @@ jQuery(document).ready(function(){
     if ( is_reverse_search ){
         map.on('click', function(e){
             $('form input[name=lat]').val( e.latlng.lat);
-            $('form input[name=lon]').val( e.latlng.lng);
+            $('form input[name=lon]').val( e.latlng.wrap().lng);
             $('form').submit();
         });