ubuntu16.4 基于OpenStreetMap地圖搭建離線地理編碼服務Nominatim

問題十:Nominatim安裝

openstreetmap地圖的地理編碼服務Nominatim

本文有道筆記鏈接:http://note.youdao.com/noteshare?id=488a724840948f5d9b0e857ec9e7b3a2 ?————可以直接打開這里看圖片循榆、附件

參考網(wǎng)址http://wiki.openstreetmap.org/wiki/Nominatim/Installation

參考網(wǎng)址2:https://github.com/twain47/Nominatim/blob/master/docs/install-on-ubuntu-16.md

https://github.com/twain47/Nominatim/blob/master/docs/Import_and_update.md

10.1預先安裝

sudo?apt-get?install?build-essential?wget

sudo?apt-get?install?libxml2-dev?wget

sudo?apt-get?install?libpq-dev?wget

sudo?apt-get?update

sudo?apt-get?install?libbz2-dev?wget

sudo?apt-get?install?libtool?wget

sudo?apt-get?install?automake?wget

sudo?apt-get?install?libproj-dev?wget

sudo?apt-get?install?libboost-dev?wget

sudo?apt-get?install?libboost-system-dev?wget

sudo?apt-get?install?libboost-filesystem-dev?wget

sudo?apt-get?install?libboost-thread-dev?wget

sudo?apt-get?install?libexpat-dev?wget

sudo?apt-get?install?gcc?wget

sudo?apt-get?install??proj-bin?wget

sudo?apt-get?install?libgeos-c1?wget---有問題,用 sudo?apt-get?install?libgeos-c1v5?wget 替換

sudo?apt-get?install?libgeos++-dev?wget

ubuntu上默認只能安裝php7了墨坚,如果想要安裝php5秧饮,可以按照如下命令——此處必須安裝php5,php7沒有用

sudo?add-apt-repository?ppa:ondrej/php

sudo?apt?update

sudo?apt?install?php5.6

sudo?apt?install?libapache2-mod-php5.6

sudo?apt?install?php5.6-curl

sudo?apt?install?php5.6-gd

sudo?apt?install?php5.6-mbstring

sudo?apt?install?php5.6-mcrypt

sudo?apt?install?php5.6-mysql

sudo?apt?install?php5.6-xml

sudo?apt?install?php5.6-xmlrpc

sudo?a2dismod?php7.0

sudo?a2enmod?php5.6

sudo?systemctl?restart?apache2

sudo?apt-get?install?php-pear?wget

sudo?apt-get?install?php5.6-pgsql?wget

sudo?apt-get?install?php5-json?wget

sudo?apt-get?install?php-db?wget

sudo?apt-get?install?postgresql-server-dev-9.5?wget

sudo?apt-get?install??postgresql-contrib-9.5?wget

因為sudo?apt-get?update導致postgresql9.5升級到9.6了

sudo?apt-get?install?postgresql-contrib-9.6?wget

sudo?apt-get?install?postgresql-server-dev-9.6?wget

apt-get?install?postgresql-9.6-postgis

由于導入的地理數(shù)據(jù)格式為pbf,所以需要安裝pbf支持軟件

sudo?apt-get?install?libprotobuf-c0-dev

sudo?apt-get?installprotobuf-c-compiler

10.2 postgresql配置

打開/etc/postgresql/9.3/main中的postgresql.conf文件泽篮,設置如下屬性:

fsync = off

full_page_writes = off

synchronous_commit = off

具體命令為:

sudo gedit /etc/postgresql/9.5/main/postgresql.conf

10.3 下載Nominatim-2.5.1.tar.bz2

wgethttp://www.nominatim.org/release/Nominatim-2.5.1.tar.bz2tar xvf Nominatim-2.5.1.tar.bz2

10.4編譯Nominatim

cd Nominatim-2.5.1

./configure

make

備注:The warning about missing lua libraries can be ignored. Nominatim does not make use of osm2pgsql's lua extension.

10.5 自定義安裝

您可以通過創(chuàng)建本地配置文件設置/ local.php來自定義Nominatim盗尸。 看看settings / settings.php可用的配置設置。


您需要創(chuàng)建一個最小的配置文件帽撑,告知nominatim它在網(wǎng)絡服務器上的位置:

tee settings/local.php << EOF


//?Paths

@define('CONST_Postgresql_Version',?'9.5');

@define('CONST_Postgis_Version',?'2.3');

@define('CONST_Website_BaseURL',?'http://localhost/nominatim/');

EOF

具體如下:


//?Paths

@define('CONST_Postgresql_Version',?'9.5');

@define('CONST_Postgis_Version',?'2.3');

//?Website?settings

@define('CONST_Website_BaseURL',?'http://localhost/nominatim/');

?>

bak兩個命令泼各,無需執(zhí)行

sudo?cp?-r?/etc/postgresql/9.6 ?/home/zhanggeoo7/document

sudo?cp?-r?/usr/lib/postgresql/9.6?/home/zhanggeoo7/document/usr

10.6 創(chuàng)建導入賬戶

導入需要使用與執(zhí)行導入的帳戶同名的postgres超級用戶來完成。 您可以通過運行以下命令來創(chuàng)建這樣的postgres超級用戶帳戶:

sudo -u postgres createuser -s test這里test用于登錄postgres數(shù)據(jù)庫

sudo?adduser?test這里test用于登錄ubuntu系統(tǒng)的亏拉,密碼為luomouren

其中test是將用于執(zhí)行安裝的帳戶的名稱扣蜻。 您應該確保此用戶可以登錄到數(shù)據(jù)庫,而不需要密碼(例如及塘,使用ident身份驗證)莽使。 這是大多數(shù)發(fā)行版的默認值。 有關詳細信息笙僚,請參閱信任身份驗證吮旅。

您不能以用戶www-data或root運行導入。

創(chuàng)建網(wǎng)站用戶

將網(wǎng)站用戶www-data創(chuàng)建為PostgreSQL數(shù)據(jù)庫角色

10.7 新建網(wǎng)站用戶

su - postgres

createuser -SDR www-data

對于安裝過程,您必須具有此用戶庇勃。如果要在其他用戶下運行網(wǎng)站檬嘀,請參閱設置網(wǎng)站一節(jié)中的注釋。

10.8 更改nominatim的讀取權限

sudo chmod +x -R /home/zhanggeoo7

sudo chmod +x -R/home/zhanggeoo7/Nominatim-2.5.1

sudo chmod +x -R/home/zhanggeoo7/Nominatim-2.5.1/module

10.9下載pdf 格式的osm數(shù)據(jù)

http://download.bbbike.org/osm/

http://download.bbbike.org/osm/bbbike/Beijing/

10.10導入pdf數(shù)據(jù)

su - test

/home/zhanggeoo7/Nominatim-2.5.1/utils/setup.php?--osm-file?/home/zhanggeoo7/Beijing.osm.pbf?--all

或者是下面的命令

/home/zhanggeoo7/Nominatim-2.5.1/utils/setup.php --osm-file /home/zhanggeoo7/Beijing.osm.pbf--all --osm2pgsql-cache 400] 2>&1 | tee setup.log

如果出現(xiàn)問題责嚷,您可能需要通過刪除數(shù)據(jù)庫進行清理鸳兽,因為在嘗試重新創(chuàng)建現(xiàn)有數(shù)據(jù)庫時腳本將失敗。使用此命令來執(zhí)行此操作:sudo -u postgres dropdb nominatim

出現(xiàn)錯誤及解決方案如下

error.txt ?見有道筆記分項鏈接


10.11 添加額外字段

sudo?chmod?777/home/zhanggeoo7/Nominatim-2.5.1/data-R

su - test

Add country codes and country names to the search index:

/home/zhanggeoo7/Nominatim-2.5.1/utils/specialphrases.php --countries >/home/zhanggeoo7/Nominatim-2.5.1/data/specialphrases_countries.sql

psql -d nominatim -f/home/zhanggeoo7/Nominatim-2.5.1/data/specialphrases_countries.sql

If you want to be able to search for special amenities likepubs in Dublin, you need to import special phrases from this wiki like this:

/home/zhanggeoo7/Nominatim-2.5.1/utils/specialphrases.php --wiki-import >/home/zhanggeoo7/Nominatim-2.5.1/data/specialphrases.sql

psql -d nominatim -f/home/zhanggeoo7/Nominatim-2.5.1/data/specialphrases.sql

This may be repeated from time to time when there are changes in the wiki. There is no need to repeat it after each update.

If you do not need phrases for all languages, editsettings/phrase_settings.phpand delete unneeded languages at the beginning of the file.

10.12 建立網(wǎng)站

Create the directory for the website and make sure it is writable by the install user and readable by Apache:

sudo mkdir -m 755/var/www/html/nominatim

sudo?chmod?777/var/www/html/nominatim-R

Populate the website directory with the necessary symlinks:

/home/zhanggeoo7/Nominatim-2.5.1/utils/setup.php --create-website /var/www/html/nominatim

You will need to make sure settings/local.php is configured with correct values forCONST_Website_BaseURL. see above.

10.13 配置apache環(huán)境

打開/etc/apache2/sites-enabled/000-default.conf,在最后添加如下內(nèi)容:

Options FollowSymLinks MultiViews

AddType text/html .php

重啟apache

service apache2 restart

10.14 增加test對數(shù)據(jù)庫nominatim的權限

su – postgres

psql template1

GRANT ALL PRIVILEGES ON DATABASE nominatim to test

\q

10.15 運行nominatim

瀏覽器登陸http://localhost/nominatim/

看www-data用戶有沒有數(shù)據(jù)庫讀寫權限罕拂,若沒有揍异,則打開/etc/apache2/envvars,修改

export APACHE_RUN_USER=test

export APACHE_RUN_GROUP=test

如果想要局域網(wǎng)都可以訪問

local.php為


//?Paths

@define('CONST_Postgresql_Version',?'9.5');

@define('CONST_Postgis_Version',?'2.3');

//?Website?settings

@define('CONST_Website_BaseURL',?'http://172.16.0.14/nominatim/');

?>

修改后重啟Apache

service apache2 restart

使用參數(shù)說明:http://wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding_.2F_Address_lookup

在線服務:http://nominatim.openstreetmap.org/

demo測試html ?見有道筆記分享鏈接

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末爆班,一起剝皮案震驚了整個濱河市衷掷,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌柿菩,老刑警劉巖颠焦,帶你破解...
    沈念sama閱讀 217,542評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件朴上,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機去件,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,822評論 3 394
  • 文/潘曉璐 我一進店門鹃锈,熙熙樓的掌柜王于貴愁眉苦臉地迎上來比勉,“玉大人清钥,你說我怎么就攤上這事『笾冢” “怎么了胀糜?”我有些...
    開封第一講書人閱讀 163,912評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長蒂誉。 經(jīng)常有香客問我僚纷,道長,這世上最難降的妖魔是什么拗盒? 我笑而不...
    開封第一講書人閱讀 58,449評論 1 293
  • 正文 為了忘掉前任怖竭,我火速辦了婚禮,結(jié)果婚禮上陡蝇,老公的妹妹穿的比我還像新娘痊臭。我一直安慰自己,他們只是感情好登夫,可當我...
    茶點故事閱讀 67,500評論 6 392
  • 文/花漫 我一把揭開白布广匙。 她就那樣靜靜地躺著,像睡著了一般恼策。 火紅的嫁衣襯著肌膚如雪鸦致。 梳的紋絲不亂的頭發(fā)上潮剪,一...
    開封第一講書人閱讀 51,370評論 1 302
  • 那天,我揣著相機與錄音分唾,去河邊找鬼抗碰。 笑死,一個胖子當著我的面吹牛绽乔,可吹牛的內(nèi)容都是我干的弧蝇。 我是一名探鬼主播,決...
    沈念sama閱讀 40,193評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼折砸,長吁一口氣:“原來是場噩夢啊……” “哼看疗!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起睦授,我...
    開封第一講書人閱讀 39,074評論 0 276
  • 序言:老撾萬榮一對情侶失蹤两芳,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后去枷,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體怖辆,經(jīng)...
    沈念sama閱讀 45,505評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,722評論 3 335
  • 正文 我和宋清朗相戀三年沉填,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片佑笋。...
    茶點故事閱讀 39,841評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡翼闹,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出蒋纬,到底是詐尸還是另有隱情猎荠,我是刑警寧澤,帶...
    沈念sama閱讀 35,569評論 5 345
  • 正文 年R本政府宣布蜀备,位于F島的核電站关摇,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏碾阁。R本人自食惡果不足惜输虱,卻給世界環(huán)境...
    茶點故事閱讀 41,168評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望脂凶。 院中可真熱鬧宪睹,春花似錦、人聲如沸蚕钦。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,783評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽嘶居。三九已至罪帖,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背整袁。 一陣腳步聲響...
    開封第一講書人閱讀 32,918評論 1 269
  • 我被黑心中介騙來泰國打工菠齿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人葬项。 一個月前我還...
    沈念sama閱讀 47,962評論 2 370
  • 正文 我出身青樓泞当,卻偏偏與公主長得像,于是被迫代替她去往敵國和親民珍。 傳聞我的和親對象是個殘疾皇子襟士,可洞房花燭夜當晚...
    茶點故事閱讀 44,781評論 2 354

推薦閱讀更多精彩內(nèi)容