Brian Quinion
Sarah Hoffmann
Marc Tobias Metten
+
markigail
+ gemo1011
IrlJidel
Frederik Ramm
- Michael Spreng
- Daniele Forsi
- mfn
- Grant Slater
- Andree Klattenhoff
- appelflap
- b3nn0
- Spin0us
- Kurt Roeckx
- Rodolphe QuiƩdeville
+
+and many more.
+
+For a full list of contributors see
+https://github.com/openstreetmap/Nominatim/graphs/contributors
project(nominatim)
set(NOMINATIM_VERSION_MAJOR 3)
-set(NOMINATIM_VERSION_MINOR 1)
+set(NOMINATIM_VERSION_MINOR 2)
set(NOMINATIM_VERSION_PATCH 0)
set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
+# Setting PHP binary variable as to command line (prevailing) or auto detect
+if (NOT PHP_BIN)
+ find_program (PHP_BIN php)
+endif()
+# sanity check if PHP binary exists
+if (NOT EXISTS ${PHP_BIN})
+ message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
+endif()
+message (STATUS "Using PHP binary " ${PHP_BIN})
+
#-----------------------------------------------------------------------------
#
# Setup settings and paths
+3.2.0
+
+ * complete rewrite of reverse search algorithm
+ * add new geojson and geocodejson output formats
+ * add simple export script to exprot addresses to CSV
+ * remove is_in terms from address computation
+ * remove unused search_name_country tables
+ * various smaller fixes to query parsing
+ * convert Tokens and token types to class types
+ * correctly handle update when boundary object type is changed
+ * improve debug output for /search endpoint
+ * update to latest osm2pgsql and leaflet.js
+ * overhaul of /details endpoint:
+ * new class parameter when using osmtype/osmid parameters
+ * permalink to instance-independent osmtype/osmid parameter format
+ * new json output format
+ * update CentOS vagrant machine to use SELinux
+ * add vagrant scripts for Ubuntu 18.04
+ * fix build process for BSD
+ * enable running the database on a different host than the setup scripts
+ * allow to configure use of custom PHP binaries (PHP_BIN)
+ * extensive coding style improvements to PHP code
+ * more PHP unit tests for new classes
+ * increase coverage for API tests
+ * add documentation for API
+
3.1.0
* rework postcode handling and introduce location_postcode table
The source code is available under a GPLv2 license.
-Contact and Bug reports
-======================
+
+Contributing
+============
+
+Contributions are welcome. For details see [CONTRIBUTING.md](contribution guide).
+
+Both bug reports and pull requests are welcome.
+
+
+Mailing list
+============
For questions you can join the geocoding mailinglist, see
https://lists.openstreetmap.org/listinfo/geocoding
-
-Bugs may be reported on the github project site:
-https://github.com/openstreetmap/Nominatim
end
config.vm.define "ubuntu", primary: true do |sub|
+ sub.vm.box = "bento/ubuntu-18.04"
+ sub.vm.provision :shell do |s|
+ s.path = "vagrant/Install-on-Ubuntu-18.sh"
+ s.privileged = false
+ s.args = [checkout]
+ end
+ end
+
+ config.vm.define "ubuntu16" do |sub|
sub.vm.box = "bento/ubuntu-16.04"
sub.vm.provision :shell do |s|
s.path = "vagrant/Install-on-Ubuntu-16.sh"
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/develop ${CMAKE_CURRENT_BINARY_DIR}/develop
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/api ${CMAKE_CURRENT_BINARY_DIR}/api
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/index.md ${CMAKE_CURRENT_BINARY_DIR}/index.md
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/extra.css ${CMAKE_CURRENT_BINARY_DIR}/extra.css
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Centos-7.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Centos-7.md
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-16.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-16.md
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-18.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-18.md
COMMAND mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
)
-# Running Your Own Instance
-
-### Can I import multiple countries and keep them up to date?
-
-You should use the extracts and updates from https://download.geofabrik.de.
-For the initial import, download the countries you need and merge them.
-See [OSM Help](https://help.openstreetmap.org/questions/48843/merging-two-or-more-geographical-areas-to-import-two-or-more-osm-files-in-nominatim)
-for examples how to do that. Use the resulting single osm file when
-running `setup.php`.
-
-For updates you need to download the change files for each country
-once per day and apply them **separately** using
-
- ./utils/update.php --import-diff <filename> --index
-
-See [this issue](https://github.com/openstreetmap/Nominatim/issues/60#issuecomment-18679446)
-for a script that runs the updates using osmosis.
-
-### Can I import negative OSM ids into Nominatim?
-
-See [https://help.openstreetmap.org/questions/64662/nominatim-flatnode-with-negative-id]()
-
-### Missing XML or text declaration
-
-The website might show: `XML Parsing Error: XML or text declaration not at start of entity Location.`
-
-Make sure there are no spaces at the beginning of your `settings/local.php` file.
+# Troubleshooting Nominatim Installations
-
-# Installation
+## Installation Issues
### Can a stopped/killed import process be resumed?
CONTEXT: PL/pgSQL function make_standard_name(text) line 5 at assignment]
```
-The user the webserver, e.g. Apache, runs under needs to have access to that file. Same for the user the Postgres runs as. You can find the user like [this](https://serverfault.com/questions/125865/finding-out-what-user-apache-is-running-as), for default Ubuntu operating system for example it's `www-data`.
+The Postgresql database, i.e. user postgres, needs to have access to that file.
-The permission need to be read&executable by everybody, e.g.
+The permission need to be read & executable by everybody, e.g.
```
-rwxr-xr-x 1 nominatim nominatim 297984 build/module/nominatim.so
Try `chmod a+r nominatim.so; chmod a+x nominatim.so`.
+When running SELinux, make sure that the
+[context is set up correctly](../appendix/Install-on-Centos-7/#adding-selinux-security-settings).
+
### Setup.php fails with "DB Error: extension not found"
Make sure you have the Postgres extensions hstore and postgis installed.
See [https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage]()
for more information.
+
+## Running your own instance
+
+### Can I import multiple countries and keep them up to date?
+
+You should use the extracts and updates from https://download.geofabrik.de.
+For the initial import, download the countries you need and merge them.
+See [OSM Help](https://help.openstreetmap.org/questions/48843/merging-two-or-more-geographical-areas-to-import-two-or-more-osm-files-in-nominatim)
+for examples how to do that. Use the resulting single osm file when
+running `setup.php`.
+
+For updates you need to download the change files for each country
+once per day and apply them **separately** using
+
+ ./utils/update.php --import-diff <filename> --index
+
+See [this issue](https://github.com/openstreetmap/Nominatim/issues/60#issuecomment-18679446)
+for a script that runs the updates using osmosis.
+
+### Can I import negative OSM ids into Nominatim?
+
+See [this question of Stackoverflow](https://help.openstreetmap.org/questions/64662/nominatim-flatnode-with-negative-id).
+
+### Missing XML or text declaration
+
+The website might show: `XML Parsing Error: XML or text declaration not at start of entity Location.`
+
+Make sure there are no spaces at the beginning of your `settings/local.php` file.
+
+
+# Importing and Updating the Database
+
The following instructions explain how to create a Nominatim database
from an OSM planet file and how to keep the database up to date. It
is assumed that you have already successfully installed the Nominatim
software itself, if not return to the [installation page](Installation.md).
-# Configuration setup in settings/local.php
+## Configuration setup in settings/local.php
The Nominatim server can be customized via the file `settings/local.php`
in the build directory. Note that this is a PHP file, so it must always
There are lots of configuration settings you can tweak. Have a look
at `settings/default.php` for a full list. Most should have a sensible default.
-### Flatnode files
+#### Flatnode files
If you plan to import a large dataset (e.g. Europe, North America, planet),
you should also enable flatnode storage of node locations. With this
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.
-# Downloading additional data
+## Downloading additional data
-## Wikipedia rankings
+### Wikipedia rankings
Wikipedia can be used as an optional auxiliary data source to help indicate
the importance of osm features. Nominatim will work without this information
the initial import of the data if you want the rankings applied to the
loaded data.
-## UK postcodes
+### UK postcodes
Nominatim can use postcodes from an external source to improve searches that involve a UK postcode. This data can be optionally downloaded:
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
-# Initial import of the data
+## Initial import of the data
**Important:** first try the import with a small excerpt, for example from
[Geofabrik](https://download.geofabrik.de).
Note that this command downloads the phrases from the wiki link above.
-# Installing Tiger housenumber data for the US
+## Installing Tiger housenumber data for the US
Nominatim is able to use the official TIGER address set to complement the
OSM house number data in the US. You can add TIGER data to your own Nominatim
Be warned that this can take quite a long time. After this process is finished,
the same preprocessed files as above are available in `data/tiger`.
-# Updates
+## Updates
There are many different possibilities to update your Nominatim database.
The following section describes how to keep it up-to-date with Pyosmium.
For a list of other methods see the output of `./utils/update.php --help`.
-### Installing the newest version of Pyosmium
+#### Installing the newest version of Pyosmium
It is recommended to install Pyosmium via pip. Run (as the same user who
will later run the updates):
pip install --user osmium
```
-Nominatim needs a tool called `pyosmium-get-updates` that comes with
+Nominatim needs a tool called `pyosmium-get-updates`, which comes with
Pyosmium. You need to tell Nominatim where to find it. Add the
following line to your `settings/local.php`:
The path above is fine if you used the `--user` parameter with pip.
Replace `user` with your user name.
-### Setting up the update process
+#### Setting up the update process
Next the update needs to be initialised. By default Nominatim is configured
to update using the global minutely diffs.
The --init-updates command needs to be rerun whenever the replication service
is changed.
-### Updating Nominatim
+#### Updating Nominatim
The following command will keep your database constantly up to date:
+# Basic Installation
+
This page contains generic installation instructions for Nominatim and its
prerequisites. There are also step-by-step instructions available for
the following operating systems:
+ * [Ubuntu 18.04](../appendix/Install-on-Ubuntu-18.md)
* [Ubuntu 16.04](../appendix/Install-on-Ubuntu-16.md)
* [CentOS 7.2](../appendix/Install-on-Centos-7.md)
* [Docker on Kubernetes](https://github.com/peter-evans/nominatim-k8s)
* [Ansible](https://github.com/synthesio/infra-ansible-nominatim)
-# Prerequisites
+## Prerequisites
-## Software
+### Software
For compiling:
* [pyosmium](http://osmcode.org/pyosmium/)
-## Hardware
+### Hardware
A minimum of 2GB of RAM is required or installation will fail. For a full
planet import 32GB of RAM or more strongly are recommended.
-For a full planet install you will need about 600GB of hard disk space (as of
-January 2017, take into account that the OSM database is growing fast). SSD disks
+For a full planet install you will need at least 700GB 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.
-# Setup of the server
+## Setup of the server
-## PostgreSQL tuning
+### PostgreSQL tuning
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
corruption. Autovacuum must not be switched off because it ensures that the
tables are frequently analysed.
-## Webserver setup
+### Webserver setup
The `website/` directory in the build directory contains the configured
website. Include the directory into your webbrowser to serve php files
from there.
-### Configure for use with Apache
+#### Configure for use with Apache
Make sure your Apache configuration contains the required permissions for the
directory and create an alias:
After making changes in the apache config you need to restart apache.
The website should now be available on http://localhost/nominatim.
-### Configure for use with Nginx
+#### Configure for use with Nginx
Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx.
-Database Migrations
-===================
+# Database Migrations
This page describes database migrations necessary to update existing databases
to newer versions of Nominatim.
SQL statements should be executed from the postgres commandline. Execute
`psql nominiatim` to enter command line mode.
-# 3.0.0 -> 3.1.0
+## 3.1.0 -> 3.2.0
+
+### New reverse algorithm
+
+The reverse algorithm has changed and requires new indexes. Run the following
+SQL statements to create the indexes:
+
+```
+CREATE INDEX idx_placex_geometry_reverse_lookupPoint
+ ON placex USING gist (geometry)
+ WHERE (name is not null or housenumber is not null or rank_address between 26 and 27)
+ AND class not in ('railway','tunnel','bridge','man_made')
+ AND rank_address >= 26 AND indexed_status = 0 AND linked_place_id is null;
+CREATE INDEX idx_placex_geometry_reverse_lookupPolygon
+ ON placex USING gist (geometry)
+ WHERE St_GeometryType(geometry) in ('ST_Polygon', 'ST_MultiPolygon')
+ AND rank_address between 4 and 25 AND type != 'postcode'
+ AND name is not null AND indexed_status = 0 AND linked_place_id is null;
+CREATE INDEX idx_placex_geometry_reverse_placeNode
+ ON placex USING gist (geometry)
+ WHERE osm_type = 'N' AND rank_search between 5 and 25
+ AND class = 'place' AND type != 'postcode'
+ AND name is not null AND indexed_status = 0 AND linked_place_id is null;
+```
+
+You also need to grant the website user access to the `country_osm_grid` table:
+
+```
+GRANT SELECT ON table country_osm_grid to "www-user";
+```
+
+Replace the `www-user` with the user name of your website server if necessary.
+
+Finally, you can drop the now unused indexes:
+
+```
+DROP INDEX idx_placex_reverse_geometry;
+```
+
+## 3.0.0 -> 3.1.0
### Postcode Table
CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id);
CREATE INDEX idx_postcode_postcode ON location_postcode USING BTREE (postcode);
GRANT SELECT ON location_postcode TO "www-data";
+drop type if exists nearfeaturecentr cascade;
+create type nearfeaturecentr as (
+ place_id BIGINT,
+ keywords int[],
+ rank_address smallint,
+ rank_search smallint,
+ distance float,
+ isguess boolean,
+ postcode TEXT,
+ centroid GEOMETRY
+);
```
Add postcode column to `location_area` tables with SQL statement:
The details API supports the following two request formats:
```
- https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=<value>
+ https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=<value>&class=<value>
```
-Both parameters are required, the type is one of node(N), way(W) or relation(R).
-
-Or
+`osmtype` and `osmid` are required parameter. The type is one of node (N), way (W)
+or relation (R). The id must be a number. The `class` parameter is optional and
+allows to distinguish between entries, when the corresponding OSM object has more
+than one main tag. For example, when a place is tagged with `tourism=hotel` and
+`amenity=restaurant`, there will be two place entries in Nominatim, one for a
+restaurant, one for a hotel. You need to specify `class=tourism` or `class=amentity`
+to get exactly the one you want. If there are multiple places in the database
+but the `class` parameter is left out, then one of the places will be chosen
+at random and displayed.
```
https://nominatim.openstreetmap.org/details?placeid=<value>
##### HTML
-[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407]()
+[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407)
##### JSON
-[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json]()
+[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json)
```json
--- /dev/null
+.toctree-l3 {
+ display: none!important
+}
- 'Search': 'api/Search.md'
- 'Reverse': 'api/Reverse.md'
- 'Address Lookup': 'api/Lookup.md'
+ - 'Details' : 'api/Details.md'
- 'Place Output Formats': 'api/Output.md'
- 'FAQ': 'api/Faq.md'
- 'Administration Guide':
- 'Appendix':
- 'Installation on CentOS 7' : 'appendix/Install-on-Centos-7.md'
- 'Installation on Ubuntu 16' : 'appendix/Install-on-Ubuntu-16.md'
+ - 'Installation on Ubuntu 18' : 'appendix/Install-on-Ubuntu-18.md'
markdown_extensions:
- codehilite:
use_pygments: False
+ - toc:
+ permalink: ļ
+extra_css: [extra.css]
if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
$oSearch = clone $this;
- $oSearch->iSearchRank++;
+ $oSearch->iSearchRank += 2;
$oSearch->aAddress[$iWordID] = $iWordID;
$aNewSearches[] = $oSearch;
} else {
fail('unable to start pgsql');
}
+ if (!$bVerbose) {
+ fwrite($ahPipes[0], 'set client_min_messages to WARNING;');
+ }
+
while (strlen($sScript)) {
$iWritten = fwrite($ahPipes[0], $sScript);
if ($iWritten <= 0) break;
CREATE TABLE import_osmosis_log (
batchend timestamp,
batchseq integer,
- batchsize integer,
+ batchsize bigint,
starttime timestamp,
endtime timestamp,
event text
namespace Nominatim;
-use Exception;
+require_once(CONST_BasePath.'/lib/DebugHtml.php');
-require_once('../../lib/DebugHtml.php');
-
-class DebugTest extends \PHPUnit_Framework_TestCase
+class DebugTest extends \PHPUnit\Framework\TestCase
{
+
protected function setUp()
{
- $this->oWithDebuginfo = $this->getMock(Geocode::class, array('debugInfo'));
+ $this->oWithDebuginfo = $this->getMockBuilder(\GeococdeMock::class)
+ ->setMethods(array('debugInfo'))
+ ->getMock();
$this->oWithDebuginfo->method('debugInfo')
->willReturn(array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'));
- $this->oWithToString = $this->getMock(Geocode::class, array('__toString'));
+
+ $this->oWithToString = $this->getMockBuilder(\SomeMock::class)
+ ->setMethods(array('__toString'))
+ ->getMock();
$this->oWithToString->method('__toString')->willReturn('me as string');
}
namespace Nominatim;
-require_once '../../lib/lib.php';
-require_once '../../lib/ClassTypes.php';
+require_once(CONST_BasePath.'/lib/ClassTypes.php');
-class LibTest extends \PHPUnit_Framework_TestCase
+class LibTest extends \PHPUnit\Framework\TestCase
{
public function testGetClassTypesWithImportance()
{
namespace Nominatim;
-use Exception;
-
-require_once('../../lib/ParameterParser.php');
+require_once(CONST_BasePath.'/lib/ParameterParser.php');
function userError($sError)
{
- throw new Exception($sError);
+ throw new \Exception($sError);
}
-class ParameterParserTest extends \PHPUnit_Framework_TestCase
+class ParameterParserTest extends \PHPUnit\Framework\TestCase
{
public function testGetIntWithNonNumber()
{
- $this->setExpectedException(Exception::class, "Integer number expected for parameter 'int4'");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Integer number expected for parameter 'int4'");
+
(new ParameterParser(array('int4' => 'a')))->getInt('int4');
}
public function testGetIntWithEmpytString()
{
- $this->setExpectedException(Exception::class, "Integer number expected for parameter 'int5'");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Integer number expected for parameter 'int5'");
+
(new ParameterParser(array('int5' => '')))->getInt('int5');
}
public function testGetFloatWithEmptyString()
{
- $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float4'");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Floating-point number expected for parameter 'float4'");
+
(new ParameterParser(array('float4' => '')))->getFloat('float4');
}
public function testGetFloatWithTextString()
{
- $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float5'");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Floating-point number expected for parameter 'float5'");
+
(new ParameterParser(array('float5' => 'a')))->getFloat('float5');
}
public function testGetFloatWithInvalidNumber()
{
- $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float6'");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Floating-point number expected for parameter 'float6'");
+
(new ParameterParser(array('float6' => '-55.')))->getFloat('float6');
}
public function testGetSetWithValueNotInSet()
{
- $this->setExpectedException(Exception::class, "Parameter 'val4' must be one of: foo, bar");
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage("Parameter 'val4' must be one of: foo, bar");
+
(new ParameterParser(array('val4' => 'faz')))->getSet('val4', array('foo', 'bar'));
}
namespace Nominatim;
-require_once '../../lib/Phrase.php';
+require_once(CONST_BasePath.'/lib/Phrase.php');
-class PhraseTest extends \PHPUnit_Framework_TestCase
+class PhraseTest extends \PHPUnit\Framework\TestCase
{
namespace Nominatim;
-@define('CONST_BasePath', '../../');
+require_once(CONST_BasePath.'/lib/SearchContext.php');
-require_once '../../lib/SearchContext.php';
-
-class SearchContextTest extends \PHPUnit_Framework_TestCase
+class SearchContextTest extends \PHPUnit\Framework\TestCase
{
private $oCtx;
namespace Nominatim;
-require_once('../../lib/Status.php');
-require_once('DB.php');
+require_once(CONST_BasePath.'/lib/Status.php');
-use Exception;
-class StatusTest extends \PHPUnit_Framework_TestCase
+class StatusTest extends \PHPUnit\Framework\TestCase
{
-
public function testNoDatabaseGiven()
{
- $this->setExpectedException(Exception::class, 'No database', 700);
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No database');
+ $this->expectExceptionCode(700);
$oDB = null;
$oStatus = new Status($oDB);
public function testNoDatabaseConnectionFail()
{
- $this->setExpectedException(Exception::class, 'No database', 700);
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No database');
+ $this->expectExceptionCode(700);
// causes 'Non-static method should not be called statically, assuming $this from incompatible context'
// failure on travis
public function testModuleFail()
{
- $this->setExpectedException(Exception::class, 'Module call failed', 702);
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Module call failed');
+ $this->expectExceptionCode(702);
// stub has getOne method but doesn't return anything
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
+ $oDbStub = $this->getMockBuilder(\DB::class)
+ ->setMethods(array('getOne'))
+ ->getMock();
$oStatus = new Status($oDbStub);
$this->assertNull($oStatus->status());
public function testWordIdQueryFail()
{
- $this->setExpectedException(Exception::class, 'No value', 704);
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No value');
+ $this->expectExceptionCode(704);
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
+ $oDbStub = $this->getMockBuilder(\DB::class)
+ ->setMethods(array('getOne'))
+ ->getMock();
// return no word_id
$oDbStub->method('getOne')
public function testOK()
{
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
+ $oDbStub = $this->getMockBuilder(\DB::class)
+ ->setMethods(array('getOne'))
+ ->getMock();
$oDbStub->method('getOne')
->will($this->returnCallback(function ($sql) {
public function testDataDate()
{
- $oDbStub = $this->getMock(\DB::class, array('getOne'));
+ $oDbStub = $this->getMockBuilder(\DB::class)
+ ->setMethods(array('getOne'))
+ ->getMock();
$oDbStub->method('getOne')
->willReturn(1519430221);
namespace Nominatim;
-@define('CONST_BasePath', '../../');
+require_once(CONST_BasePath.'/lib/db.php');
+require_once(CONST_BasePath.'/lib/cmd.php');
+require_once(CONST_BasePath.'/lib/TokenList.php');
-require_once '../../lib/db.php';
-require_once '../../lib/cmd.php';
-require_once '../../lib/TokenList.php';
-class TokenTest extends \PHPUnit_Framework_TestCase
+class TokenTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
{
- $this->oNormalizer = $this->getMock(\MockNormalizer::class, array('transliterate'));
+ $this->oNormalizer = $this->getMockBuilder(\MockNormalizer::class)
+ ->setMethods(array('transliterate'))
+ ->getMock();
$this->oNormalizer->method('transliterate')
->will($this->returnCallback(function ($text) {
return strtolower($text);
{
$this->expectOutputRegex('/<p><tt>/');
- $oDbStub = $this->getMock(\DB::class, array('getAll'));
+ $oDbStub = $this->getMockBuilder(\DB::class)
+ ->setMethods(array('getAll'))
+ ->getMock();
$oDbStub->method('getAll')
->will($this->returnCallback(function ($sql) {
$aResults = array();
<?php
+ @define('CONST_BasePath', '../..');
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
- bootstrap="test/php/bootstrap.php"
+ bootstrap="./bootstrap.php"
+ beStrictAboutTestsThatDoNotTestAnything="true"
>
<php>
</php>
<testsuites>
<testsuite name="Nominatim PHP Test Suite">
- <directory>./test/php/Nominatim</directory>
+ <directory>./Nominatim</directory>
</testsuite>
</testsuites>
<filter>
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
// Script to extract structured city and street data
// from a running nominatim instance as CSV data
$oDB =& getDB();
$sSQL = 'select page_title from content where page_namespace = 0 and page_id %10 = ';
$sSQL .= $aCMDResult['parse-wikipedia'];
- $sSQL .= ' and (page_content ilike \'%{{Coord%\' or (page_content ilike \'%lat%\' and page_content ilike \'%lon%\'))'
+ $sSQL .= ' and (page_content ilike \'%{{Coord%\' or (page_content ilike \'%lat%\' and page_content ilike \'%lon%\'))';
$aArticleNames = $oDB->getCol($sSQL);
/* $aArticleNames = $oDB->getCol($sSQL = 'select page_title from content where page_namespace = 0
and (page_content ilike \'%{{Coord%\' or (page_content ilike \'%lat%\'
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
$sFile = 'sample.log.txt'; // Apache log file
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
// PGSQL_EMPTY_QUERY, PGSQL_COMMAND_OK, PGSQL_TUPLES_OK,
// PGSQL_COPY_OUT, PGSQL_COPY_IN, PGSQL_BAD_RESPONSE,
// PGSQL_NONFATAL_ERROR and PGSQL_FATAL_ERROR
- echo 'Query result ' . $i . ' is: ' . $resultStatus . "\n";
if ($resultStatus != PGSQL_COMMAND_OK && $resultStatus != PGSQL_TUPLES_OK) {
$resultError = pg_result_error($hPGresult);
echo '-- error text ' . $i . ': ' . $resultError . "\n";
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
fail('pyosmium-get-changes not found or not usable');
}
if (!$aResult['no-update-functions']) {
- $sSetup = CONST_InstallPath.'/utils/setup.php';
+ $sSetup ='@PHP_BIN@ '. CONST_InstallPath.'/utils/setup.php';
$iRet = -1;
passthru($sSetup.' --create-functions --enable-diff-updates', $iRet);
if ($iRet != 0) {
-#!/usr/bin/php -Cq
+#!@PHP_BIN@ -Cq
<?php
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
--- /dev/null
+#!/bin/bash
+#
+# hacks for broken vagrant box #DOCS:
+sudo rm -f /var/lib/dpkg/lock #DOCS:
+sudo update-locale LANG=en_US.UTF-8 #DOCS:
+export APT_LISTCHANGES_FRONTEND=none #DOCS:
+export DEBIAN_FRONTEND=noninteractive #DOCS:
+
+#
+# *Note:* these installation instructions are also available in executable
+# form for use with vagrant under vagrant/Install-on-Ubuntu-18.sh.
+#
+# Installing the Required Software
+# ================================
+#
+# These instructions expect that you have a freshly installed Ubuntu 18.04.
+#
+# Make sure all packages are are up-to-date by running:
+#
+
+#DOCS: :::sh
+ sudo apt-get -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" --force-yes -fuy install grub-pc #DOCS:
+ sudo apt-get update -qq
+
+# Now you can install all packages needed for Nominatim:
+
+ sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
+ libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
+ libbz2-dev libpq-dev libproj-dev \
+ postgresql-server-dev-10 postgresql-10-postgis-2.4 \
+ postgresql-contrib-10 \
+ apache2 php php-pgsql libapache2-mod-php php-pear php-db \
+ php-intl git
+
+# If you want to run the test suite, you need to install the following
+# additional packages:
+
+ sudo apt-get install -y python3-setuptools python3-dev python3-pip \
+ python3-psycopg2 python3-tidylib phpunit php-cgi
+
+ pip3 install --user behave nose
+ sudo pear install PHP_CodeSniffer
+
+#
+# System Configuration
+# ====================
+#
+# The following steps are meant to configure a fresh Ubuntu installation
+# for use with Nominatim. You may skip some of the steps if you have your
+# OS already configured.
+#
+# Creating Dedicated User Accounts
+# --------------------------------
+#
+# Nominatim will run as a global service on your machine. It is therefore
+# best to install it under its own separate user account. In the following
+# we assume this user is called nominatim and the installation will be in
+# /srv/nominatim. To create the user and directory run:
+#
+# sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim
+#
+# You may find a more suitable location if you wish.
+#
+# To be able to copy and paste instructions from this manual, export
+# user name and home directory now like this:
+#
+ export USERNAME=vagrant #DOCS: export USERNAME=nominatim
+ export USERHOME=/home/vagrant #DOCS: export USERHOME=/srv/nominatim
+#
+# **Never, ever run the installation as a root user.** You have been warned.
+#
+# Make sure that system servers can read from the home directory:
+
+ chmod a+x $USERHOME
+
+# Setting up PostgreSQL
+# ---------------------
+#
+# Tune the postgresql configuration, which is located in
+# `/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in
+# [the installation page](../admin/Installation.md#postgresql-tuning)
+# for the parameters to change.
+#
+# Restart the postgresql service after updating this config file.
+
+ sudo systemctl restart postgresql
+
+#
+# Finally, we need to add two postgres users: one for the user that does
+# the import and another for the webserver which should access the database
+# for reading only:
+#
+
+ sudo -u postgres createuser -s $USERNAME
+ sudo -u postgres createuser www-data
+
+#
+# Setting up the Apache Webserver
+# -------------------------------
+#
+# You need to create an alias to the website directory in your apache
+# configuration. Add a separate nominatim configuration to your webserver:
+
+#DOCS:```sh
+sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
+<Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
+ Options FollowSymLinks MultiViews
+ AddType text/html .php
+ DirectoryIndex search.php
+ Require all granted
+</Directory>
+
+Alias /nominatim $USERHOME/build/website #DOCS:Alias /nominatim $USERHOME/Nominatim/build/website
+EOFAPACHECONF
+#DOCS:```
+
+sudo sed -i 's:#.*::' /etc/apache2/conf-available/nominatim.conf #DOCS:
+
+#
+# Then enable the configuration and restart apache
+#
+
+ sudo a2enconf nominatim
+ sudo systemctl restart apache2
+
+#
+# Installing Nominatim
+# ====================
+#
+# Building and Configuration
+# --------------------------
+#
+# Get the source code from Github and change into the source directory
+#
+if [ "x$1" == "xyes" ]; then #DOCS: :::sh
+ cd $USERHOME
+ git clone --recursive git://github.com/openstreetmap/Nominatim.git
+ cd Nominatim
+else #DOCS:
+ cd $USERHOME/Nominatim #DOCS:
+fi #DOCS:
+
+# When installing the latest source from github, you also need to
+# download the country grid:
+
+if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
+ wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
+fi #DOCS:
+
+# The code must be built in a separate directory. Create this directory,
+# then configure and build Nominatim in there:
+
+ cd $USERHOME #DOCS: :::sh
+ mkdir build
+ cd build
+ cmake $USERHOME/Nominatim
+ make
+
+# You need to create a minimal configuration file that tells nominatim
+# where it is located on the webserver:
+
+#DOCS:```sh
+tee settings/local.php << EOF
+<?php
+ @define('CONST_Website_BaseURL', '/nominatim/');
+EOF
+#DOCS:```
+
+
+# Nominatim is now ready to use. Continue with
+# [importing a database from OSM data](../admin/Import-and-Update.md).