Nominatim-> Search OSM with name

Nominatim-> Search OSM with name

Hie guys. Today, I am going to nomenclature my OSM map.:p

Implementation

You can clone the repo from https://github.com/openstreetmap/Nominatim

The detailed information of installation and set up of nominatim is given in ‘docs‘ directory.

Here, I will discuss the summary and struggles you may face while doing it.

$sudo apt-get install osmosis  /* For running continuous updates */

$sudo apt-get install php5-pgsql

After installing the software dependencies when I tried to import the data I encountered with the following error.

amisha@amisha:~/git/Nominatim$ ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf –all

PHP Warning:  require_once(DB.php): failed to open stream: No such file or directory in /home/amisha/git/Nominatim/lib/db.php on line 3
PHP Fatal error:  require_once(): Failed opening required ‘DB.php’ (include_path=’.:/usr/share/php:/usr/share/pear/share/php’) in /home/amisha/git/Nominatim/lib/db.php on line 3

It means ‘db.php’ requires file ‘DB.php’ for it’s execution. On goggled I came to know that ‘DB.php’ file comes with the installation of PEAR::DB. It means I have not installed it initially.

PEAR::DB Installation

$wget http://pear.php.net/go-pear.phar

$php go-pear.phar

$pear install DB

On executing the same command with the user <amisha> an error of permission denied came. Then I realized correct system user is postgres. It’s through not only.

amisha@amisha:~/git/Nominatim$ sudo -u amisha ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf –all
Create DB
createdb: database creation failed: ERROR:  permission denied to create database
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim
Error executing external command: createdb -E UTF-8 -p 5432 nominatim

$ sudo -u postgres ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf  –all

Create DB
Setup DB
Postgres version found: 9.3
CREATE EXTENSION
ERROR:  could not access file “$libdir/postgis-2.2”: No such file or directory
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

Again error in the same command but of different type. The above error explains itself only. So, what you are waiting for. Install postgis-2.2.

$ sudo apt-get install postgresql-9.3-postgis-2.2

While installing it I got an error of broken packages which I solved it with the help of my previous blog.

You can verify that whether database nominatim created or not.

postgres-# \l
List of databases
Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
———–+———-+———-+———+——-+———————–
gis       | amisha   | UTF8     | en_IN   | en_IN |
nominatim | postgres | UTF8     | en_IN   | en_IN |
postgres  | postgres | UTF8     | en_IN   | en_IN |
template0 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
|          |          |         |       | postgres=CTc/postgres
template1 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
|          |          |         |       | postgres=CTc/postgres
(5 rows)

After the installation and importing the database, I browse to the search.php file on the local server. But, unfortunately I got the Internal Server Error.

Internal Server Error

SQL Error: DB Error: connect failed

Details: [nativecode=pg_connect(): Unable to connect to PostgreSQL server: FATAL:  role “www-data” does not exist] ** pgsql://@/nominatim

This error came because the owner of nominatim database was postgres and in settings.php permissions was given to the <www-data> user. So, I changed the ownership of database to <www-data> also. You can do vice versa.

postgres=# create role “www-data”;
CREATE ROLE
postgres=# ALTER ROLE “www-data” WITH login;
ALTER ROLE

After re-loading the page the category of the error was same but with different type. This time it was not able to find the tables shown below.

in.png

It means that the defination of the tables and functions were missing. Command to create functions. I think errors loves me a lot that is why coming again and again.:P

$ ./build/utils/setup.php –create-functions

Functions
ERROR:  type geometry does not exist
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

It means that the type geometry was missing which come with the extension postgis.

nominatim=# create extension postgis;
CREATE EXTENSION

$ ./utils/setup.php –create-functions
Functions
CREATE FUNCTION
CREATE FUNCTION
ERROR:  permission denied for language c
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

The above command runs with the owner of the database <postgres>.

$sudo -u postgres ./utils/setup.php –create-functions

$ sudo -u postgres ./utils/setup.php –create-tables

ERROR:  type “wikipedia_article_match” does not exist
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

I have ignored this error as it demands for the optional data to be import.

$ ./utils/specialphrases.php –wiki-import > specialphrases.sql

$sudo -u postgres ./utils/setup.php –osm-file ~/Downloads/ludhiana.pbf –all –osm2pgsql-cache 2300 | tee setup.log

The above command will cache the imported data.

Then browse to the file search.php and you will be able to see the Nominatim main page through local server.

nom.png

The tiles are coming from the osm.org website and the it is using the local database. You can check it over the settings.php file. Now, my next task is to server the local tiles in the nominatim. I don’t know whether it is possible or not. Will update you soon.

I hope you will like it.

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s