From: Sarah Hoffmann Date: Sun, 1 Dec 2019 19:47:33 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~269 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/47714357cb800c69d006b3a868356bf80d09549a?hp=974bd2d8b205bb4947fa546a95caed088c470bb0 Merge remote-tracking branch 'upstream/master' --- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd8d1cc1..89b76e3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index a9a5a3e2..1ae0dab0 100644 --- 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) diff --git a/docs/admin/Import-and-Update.md b/docs/admin/Import-and-Update.md index 246fcdda..afda83b2 100644 --- a/docs/admin/Import-and-Update.md +++ b/docs/admin/Import-and-Update.md @@ -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 --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log +./utils/setup.php --osm-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 diff --git a/docs/admin/Installation.md b/docs/admin/Installation.md index d0724927..89afd2bc 100644 --- a/docs/admin/Installation.md +++ b/docs/admin/Installation.md @@ -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: diff --git a/lib/AddressDetails.php b/lib/AddressDetails.php index 783a0fda..61823b4c 100644 --- a/lib/AddressDetails.php +++ b/lib/AddressDetails.php @@ -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; } diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index 506d4202..4fafbec2 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -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) { diff --git a/lib/setup/SetupClass.php b/lib/setup/SetupClass.php index 2fdb3926..12a1bb0d 100755 --- a/lib/setup/SetupClass.php +++ b/lib/setup/SetupClass.php @@ -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(); } diff --git a/lib/template/details-html.php b/lib/template/details-html.php index 9b76efc1..cfba6eb3 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -64,7 +64,7 @@ $bNotUsed = isset($aAddressLine['isaddress']) && !$aAddressLine['isaddress']; echo ''."\n"; - echo ' '.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'No Name')."\n"; + echo ' '.(trim($aAddressLine['localname'])!==null?$aAddressLine['localname']:'No Name')."\n"; echo ' ' . $aAddressLine['class'].':'.$aAddressLine['type'] . "\n"; echo ' ' . osmLink($aAddressLine) . "\n"; echo ' ' . (isset($aAddressLine['rank_address']) ? $aAddressLine['rank_address'] : '') . "\n"; diff --git a/test/bdd/api/search/queries.feature b/test/bdd/api/search/queries.feature index cf5a00c9..8c2fa2b8 100644 --- a/test/bdd/api/search/queries.feature +++ b/test/bdd/api/search/queries.feature @@ -55,6 +55,22 @@ Feature: Search queries | country | Uruguay | | country_code | uy | + Scenario Outline: Housenumber 0 can be found + When sending 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" diff --git a/test/bdd/environment.py b/test/bdd/environment.py index b12b6481..f0658c33 100644 --- a/test/bdd/environment.py +++ b/test/bdd/environment.py @@ -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): diff --git a/website/js/nominatim-ui.js b/website/js/nominatim-ui.js index 32e7cbda..d631e7aa 100644 --- a/website/js/nominatim-ui.js +++ b/website/js/nominatim-ui.js @@ -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 ) //'© OpenStreetMap 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('
')); + 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(); });