From: Sarah Hoffmann Date: Fri, 18 Sep 2020 20:41:47 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~214 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/61e3a053723a6a1131e234aa8ad1a37f18bbec56?hp=44292713c6e11bbf09079c7c910f9f819776300a Merge remote-tracking branch 'upstream/master' --- diff --git a/.travis.yml b/.travis.yml index 4461add9..b16d8106 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,21 @@ --- os: linux -dist: bionic -language: python -python: - - "3.6" +dist: focal addons: - postgresql: "9.6" + postgresql: "12" apt: packages: - postgresql-server-dev-9.6 - postgresql-client-9.6 + - postgresql-server-dev-12 + - postgresql-12-postgis-3 git: depth: 3 env: - TEST_SUITE=tests - TEST_SUITE=monaco before_install: - - phpenv global 7.1 + - phpenv global 7.4 install: - - vagrant/install-on-travis-ci.sh + - vagrant/Install-on-Travis-CI.sh before_script: - psql -U postgres -c "create extension postgis" script: diff --git a/CMakeLists.txt b/CMakeLists.txt index e1ccae87..5aa71800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,11 @@ if (BUILD_API) php -S 127.0.0.1:8088 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/website ) + + add_custom_target(serve-global + php -S 0.0.0.0:8088 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/website + ) endif() #----------------------------------------------------------------------------- diff --git a/Vagrantfile b/Vagrantfile index 87118c43..033e1507 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,18 +4,38 @@ Vagrant.configure("2") do |config| # Apache webserver config.vm.network "forwarded_port", guest: 80, host: 8089 + config.vm.network "forwarded_port", guest: 8088, host: 8088 # If true, then any SSH connections made will enable agent forwarding. config.ssh.forward_agent = true + # Never sync the current directory to /vagrant. + config.vm.synced_folder ".", "/vagrant", disabled: true + checkout = "yes" if ENV['CHECKOUT'] != 'y' then - config.vm.synced_folder ".", "/home/vagrant/Nominatim" - checkout = "no" + checkout = "no" + end + + config.vm.provider "virtualbox" do |vb, override| + vb.gui = false + vb.memory = 2048 + vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//vagrant","0"] + if ENV['CHECKOUT'] != 'y' then + override.vm.synced_folder ".", "/home/vagrant/Nominatim" + end + end + + config.vm.provider "libvirt" do |lv, override| + lv.memory = 2048 + lv.nested = true + if ENV['CHECKOUT'] != 'y' then + override.vm.synced_folder ".", "/home/vagrant/Nominatim", type: 'nfs' + end end config.vm.define "ubuntu", primary: true do |sub| - sub.vm.box = "bento/ubuntu-20.04" + sub.vm.box = "generic/ubuntu2004" sub.vm.provision :shell do |s| s.path = "vagrant/Install-on-Ubuntu-20.sh" s.privileged = false @@ -23,69 +43,68 @@ Vagrant.configure("2") do |config| end end - config.vm.define "ubuntu18", primary: true do |sub| - sub.vm.box = "bento/ubuntu-18.04" + config.vm.define "ubuntu-apache" do |sub| + sub.vm.box = "generic/ubuntu2004" sub.vm.provision :shell do |s| - s.path = "vagrant/Install-on-Ubuntu-18.sh" + s.path = "vagrant/Install-on-Ubuntu-20.sh" s.privileged = false - s.args = [checkout] + s.args = [checkout, "install-apache"] end end - config.vm.define "ubuntu18nginx" do |sub| - sub.vm.box = "bento/ubuntu-18.04" + config.vm.define "ubuntu-nginx" do |sub| + sub.vm.box = "generic/ubuntu2004" sub.vm.provision :shell do |s| - s.path = "vagrant/Install-on-Ubuntu-18-nginx.sh" + s.path = "vagrant/Install-on-Ubuntu-20.sh" s.privileged = false - s.args = [checkout] + s.args = [checkout, "install-nginx"] end end - config.vm.define "ubuntu16" do |sub| - sub.vm.box = "bento/ubuntu-16.04" + config.vm.define "ubuntu18" do |sub| + sub.vm.box = "generic/ubuntu1804" sub.vm.provision :shell do |s| - s.path = "vagrant/Install-on-Ubuntu-16.sh" + s.path = "vagrant/Install-on-Ubuntu-18.sh" s.privileged = false s.args = [checkout] end end - config.vm.define "travis" do |sub| - sub.vm.box = "bento/ubuntu-14.04" + config.vm.define "ubuntu18-apache" do |sub| + sub.vm.box = "generic/ubuntu1804" sub.vm.provision :shell do |s| - s.path = "vagrant/install-on-travis-ci.sh" + s.path = "vagrant/Install-on-Ubuntu-18.sh" s.privileged = false - s.args = [checkout] + s.args = [checkout, "install-apache"] end end - config.vm.define "centos" do |sub| + config.vm.define "ubuntu18-nginx" do |sub| + sub.vm.box = "generic/ubuntu1804" + sub.vm.provision :shell do |s| + s.path = "vagrant/Install-on-Ubuntu-18.sh" + s.privileged = false + s.args = [checkout, "install-nginx"] + end + end + + config.vm.define "centos7" do |sub| sub.vm.box = "centos/7" sub.vm.provision :shell do |s| s.path = "vagrant/Install-on-Centos-7.sh" s.privileged = false - s.args = "yes" + s.args = [checkout] end - sub.vm.synced_folder ".", "/home/vagrant/Nominatim", disabled: true - sub.vm.synced_folder ".", "/vagrant", disabled: true end - config.vm.define "centos8" do |sub| + config.vm.define "centos" do |sub| sub.vm.box = "generic/centos8" sub.vm.provision :shell do |s| s.path = "vagrant/Install-on-Centos-8.sh" s.privileged = false - s.args = "yes" + s.args = [checkout] end - sub.vm.synced_folder ".", "/home/vagrant/Nominatim", disabled: true - sub.vm.synced_folder ".", "/vagrant", disabled: true end - config.vm.provider "virtualbox" do |vb| - vb.gui = false - vb.memory = 2048 - vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//vagrant","0"] - end - end diff --git a/data/country_name.sql b/data/country_name.sql index dc86ef16..8dc02382 100644 --- a/data/country_name.sql +++ b/data/country_name.sql @@ -129,7 +129,7 @@ kn "name"=>"Saint Kitts and Nevis", "name:af"=>"Sint Kitts en Nevis", "name:ar"= rs "name"=>"Србија (Serbia)", "name:af"=>"Serwië", "name:ar"=>"صربيا", "name:be"=>"Сербія", "name:br"=>"Serbia", "name:ca"=>"Sèrbia", "name:cy"=>"Serbia", "name:da"=>"Serbien", "name:de"=>"Serbien", "name:el"=>"Σερβία", "name:en"=>"Serbia", "name:eo"=>"Serbio", "name:es"=>"Serbia", "name:et"=>"Serbia", "name:fa"=>"صربستان", "name:fi"=>"Serbia", "name:fr"=>"Serbie", "name:fy"=>"Servje", "name:ga"=>"An tSeirbia", "name:gd"=>"An t-Sèarb", "name:he"=>"סרביה", "name:hr"=>"Srbija", "name:hu"=>"Szerbia", "name:id"=>"Serbia", "name:is"=>"Serbía", "name:it"=>"Serbia", "name:ja"=>"セルビア", "name:la"=>"Serbia", "name:lb"=>"Serbien", "name:li"=>"Servië", "name:lt"=>"Serbija", "name:mn"=>"Серби", "name:nb"=>"Serbia", "name:nl"=>"Servië", "name:nn"=>"Serbia", "name:no"=>"Serbia", "name:pl"=>"Serbia", "name:pt"=>"Sérvia", "name:ru"=>"Сербия", "name:sk"=>"Srbsko", "name:sl"=>"Srbija", "name:sr"=>"Србија", "name:sv"=>"Serbien", "name:th"=>"ประเทศเซอร์เบีย", "name:tr"=>"Sırbistan", "name:uk"=>"Сербія", "name:vi"=>"Serbia", "name:zh"=>"塞尔维亚", "name:haw"=>"Seripia", "name:zh_py"=>"Saierweiya", "name:zh_pyt"=>"Sāiěrwéiyà", "official_name:br"=>"Republik Serbia", "official_name:el"=>"Δημοκρατία της Σερβίας", "official_name:et"=>"Serbia Vabariik", "official_name:fr"=>"République de Serbie", "official_name:id"=>"Republik Serbia", "official_name:ja"=>"セルビア共和国", "official_name:lt"=>"Serbijos Respublika", "official_name:pt"=>"República da Sérvia", "official_name:sk"=>"Srbská republika", "official_name:sv"=>"Republiken Serbien" sr 59 lb "name"=>"لبنان Lebanon", "name:af"=>"Libanon", "name:ar"=>"لبنان", "name:be"=>"Ліван", "name:br"=>"Liban", "name:ca"=>"Líban", "name:cy"=>"Libanus", "name:da"=>"Libanon", "name:de"=>"Libanon", "name:el"=>"Λίβανος", "name:en"=>"Lebanon", "name:eo"=>"Libano", "name:es"=>"Líbano", "name:et"=>"Liibanon", "name:fa"=>"لبنان", "name:fi"=>"Libanon", "name:fr"=>"Liban", "name:fy"=>"Libanon", "name:ga"=>"An Liobáin", "name:gd"=>"Leabanon", "name:he"=>"לבנון", "name:hr"=>"Libanon", "name:hu"=>"Libanon", "name:id"=>"Lebanon", "name:is"=>"Líbanon", "name:it"=>"Libano", "name:ja"=>"レバノン", "name:la"=>"Libanus", "name:lb"=>"Libanon", "name:li"=>"Libanon", "name:lt"=>"Libanas", "name:lv"=>"Libāna", "name:mn"=>"Ливан", "name:nb"=>"Libanon", "name:nl"=>"Libanon", "name:nn"=>"Libanon", "name:no"=>"Libanon", "name:pl"=>"Liban", "name:pt"=>"Líbano", "name:ru"=>"Ливан", "name:sl"=>"Libanon", "name:sv"=>"Libanon", "name:th"=>"ประเทศเลบานอน", "name:tr"=>"Lübnan", "name:uk"=>"Ліван", "name:vi"=>"Liban", "name:zh"=>"黎巴嫩", "name:haw"=>"Lepanona", "name:zh_py"=>"Libanen", "name:zh_pyt"=>"Líbānèn", "official_name"=>"Republic of Lebanon", "official_name:br"=>"Republik Liban", "official_name:en"=>"Republic of Lebanon", "official_name:et"=>"Liibanoni Vabariik", "official_name:id"=>"Republik Lebanon", "official_name:it"=>"Repubblica Libanese", "official_name:ja"=>"レバノン共和国", "official_name:lb"=>"Republik Libanon", "official_name:lv"=>"Libānas Republika", "official_name:pl"=>"Republika Libańska", "official_name:pt"=>"República do Líbano", "official_name:sv"=>"Republiken Libanon", "official_name:vi"=>"Cộng hòa Liban" \N 66 bt "name"=>"Bhutan", "name:af"=>"Bhoetan", "name:ar"=>"بوتان", "name:be"=>"Бутан", "name:br"=>"Bhoutan", "name:dz"=>"འབྲུག་ཡུལ་", "name:el"=>"Μπουτάν", "name:en"=>"Bhutan", "name:eo"=>"Butano", "name:es"=>"Bután", "name:fa"=>"بوتان", "name:fi"=>"Bhutan", "name:fr"=>"Bhoutan", "name:fy"=>"Bûtan", "name:ga"=>"An Bhútain", "name:gd"=>"Butàn", "name:he"=>"בהוטן", "name:hr"=>"Butan", "name:hu"=>"Bhután", "name:is"=>"Bútan", "name:it"=>"Bhutan", "name:ja"=>"ブータン", "name:la"=>"Butania", "name:li"=>"Bhoetaan", "name:lt"=>"Butanas", "name:lv"=>"Butāna", "name:mn"=>"Бутан", "name:pl"=>"Bhutan", "name:pt"=>"Butão", "name:ru"=>"Бутан", "name:sl"=>"Butan", "name:sv"=>"Bhutan", "name:th"=>"ประเทศภูฏาน", "name:uk"=>"Бутан", "name:zh"=>"不丹", "name:haw"=>"Butana", "name:zh_py"=>"Budan", "name:zh_pyt"=>"Bùdān", "official_name:el"=>"Βασίλειο του Μπουτάν", "official_name:en"=>"Kingdom of Bhutan", "official_name:fi"=>"Bhutanin kuningaskunta", "official_name:it"=>"Regno del Bhutan", "official_name:lt"=>"Butano Karalystė", "official_name:lv"=>"Butānas Karaliste", "official_name:pt"=>"Reino do Butão", "official_name:sv"=>"Konungariket Bhutan", "official_name:vi"=>"Vương quốc Bhutan" dz 87 -mk "name"=>"Македонија", "name:af"=>"Masedonië", "name:ar"=>"مقدونيا", "name:be"=>"Македонія", "name:br"=>"Makedonia", "name:ca"=>"Macedònia", "name:cy"=>"Gweriniaeth Macedonia", "name:da"=>"Makedonien", "name:de"=>"Mazedonien", "name:en"=>"Macedonia", "name:eo"=>"Makedonio", "name:es"=>"Macedonia", "name:et"=>"Makedoonia", "name:fa"=>"مقدونیه", "name:fi"=>"Makedonia", "name:fr"=>"Macédoine", "name:fy"=>"Massedoanje", "name:ga"=>"An Mhacadóin", "name:gd"=>"Masadoinia", "name:he"=>"מקדוניה", "name:hr"=>"Makedonija", "name:hu"=>"Macedónia", "name:id"=>"Republik Makedonia", "name:is"=>"Makedónía", "name:it"=>"Macedonia", "name:ja"=>"マケドニア", "name:la"=>"Respublica Macedonica", "name:lb"=>"Makedonien", "name:li"=>"Macedonië", "name:lt"=>"Makedonija", "name:lv"=>"Maķedonija", "name:mn"=>"Македон", "name:nl"=>"Macedonië", "name:pl"=>"Macedonia", "name:pt"=>"Macedônia", "name:ru"=>"Македония", "name:sk"=>"Macedónsko", "name:sl"=>"Makedonija", "name:sv"=>"Makedonien", "name:th"=>"ประเทศมาซิโดเนีย", "name:tr"=>"Makedonya", "name:uk"=>"Македонія", "name:vi"=>"Macedonia", "name:zh"=>"马其顿", "name:haw"=>"Repupalika ‘o Makekonia", "name:zh_py"=>"Maqidun", "name:zh_pyt"=>"Mǎqídùn", "official_name"=>"Република Македонија", "official_name:af"=>"Republiek van Masedonië", "official_name:be"=>"Рэспубліка Македонія ", "official_name:br"=>"Republik Makedonia", "official_name:ca"=>"Exrepública Iugoslava de Macedònia", "official_name:en"=>"Republic of Macedonia", "official_name:es"=>"República de Macedonia", "official_name:et"=>"Makedoonia Vabariik", "official_name:fr"=>"République de Macédoine", "official_name:it"=>"Repubblica di Macedonia", "official_name:ja"=>"マケドニア旧ユーゴスラビア共和国", "official_name:lv"=>"Maķedonijas Republika", "official_name:pl"=>"Republika Macedonii", "official_name:pt"=>"República da Macedônia", "official_name:sk"=>"Macedónska republika", "official_name:sl"=>"Republika Makedonija", "official_name:sv"=>"Republiken Makedonien", "official_name:vi"=>"Cộng hòa Macedonia" mk 69 +mk "name"=>"Северна Македонија", "name:af"=>"Masedonië", "name:ak"=>"Masedonia", "name:am"=>"ማሴዶንያ", "name:an"=>"Republica de Macedonia", "name:ar"=>"شمال مقدونيا", "name:az"=>"Masedoniya", "name:ba"=>"Македония Республикаһы", "name:be"=>"Македонія", "name:bg"=>"Северна Македония", "name:bi"=>"Macedonia", "name:bm"=>"Macedɔni", "name:bn"=>"মেসিডোনিয়া[FYROM]", "name:bo"=>"མ་སེ་ཌོ་ནིཡ། (རྒྱལ་ཁབ།)", "name:br"=>"Makedonia", "name:bs"=>"Sjeverna Makedonija", "name:ca"=>"Macedònia del Nord", "name:ce"=>"Македони", "name:cs"=>"Severní Makedonie", "name:cu"=>"Макєдонїꙗ", "name:cv"=>"Македони Республики", "name:cy"=>"Gogledd Macedonia", "name:da"=>"Nordmakedonien", "name:de"=>"Nordmazedonien", "name:dv"=>"މެސެޑޯނިއާ", "name:dz"=>"མ་སེ་ཌོ་ནི་ཡ་ [ཡུ་གོ་སླཱ་བི་ཡ]", "name:ee"=>"Makedonia", "name:el"=>"Βόρεια Μακεδονία", "name:en"=>"North Macedonia", "name:eo"=>"Nord-Makedonio", "name:es"=>"Macedonia del Norte", "name:et"=>"Põhja-Makedoonia", "name:eu"=>"Ipar Mazedonia", "name:fa"=>"مقدونیه شمالی", "name:ff"=>"Meceduwaan", "name:fi"=>"Makedonia", "name:fo"=>"Makedónia", "name:fr"=>"Macédoine du Nord", "name:fy"=>"Noard-Masedoanje", "name:ga"=>"An Mhacadóin", "name:gd"=>"Masadoinia a Tuath", "name:gl"=>"Macedonia do Norte", "name:gn"=>"Masendoña", "name:gu"=>"મેસેડોનિયા", "name:gv"=>"Massadoan Hwoaie", "name:ha"=>"Masedoniya", "name:he"=>"מקדוניה הצפונית", "name:hi"=>"उत्तर मेसीडोनिया", "name:hr"=>"Sjeverna Makedonija", "name:ht"=>"Repiblik d Masedoni", "name:hu"=>"Észak-Macedónia", "name:hy"=>"Մակեդոնիայի Հանրապետություն", "name:ia"=>"Macedonia", "name:id"=>"Republik Makedonia", "name:ie"=>"Macedonia", "name:io"=>"Republiko Macedonia", "name:is"=>"Makedónía", "name:it"=>"Macedonia del Nord", "name:ja"=>"北マケドニア", "name:jv"=>"Républik Makedonia", "name:ka"=>"მაკედონია", "name:kg"=>"Makedonia", "name:ki"=>"Masedonia", "name:kk"=>"Македония Республикасы", "name:kl"=>"Makedonia", "name:km"=>"ម៉ាសេដ្វាន", "name:kn"=>"ಮ್ಯಾಸಿಡೋನಿಯ", "name:ko"=>"마케도니아", "name:ks"=>"مٮ۪سوڑونِیا", "name:ku"=>"Komara Makedonyayê", "name:kv"=>"Македония Республика", "name:kw"=>"Repoblek Makedoni", "name:la"=>"Macedonia Septentrionalis", "name:lb"=>"Nordmazedonien", "name:lg"=>"Masedoniya", "name:li"=>"Noord-Macedonië", "name:ln"=>"Masedoni", "name:lo"=>"ມາຊີໂດເນຍ", "name:lt"=>"Šiaurės Makedonija", "name:lv"=>"Ziemeļmaķedonija", "name:mg"=>"Makedonia", "name:mi"=>"Makerōnia", "name:mk"=>"Северна Македонија", "name:ml"=>"റിപ്പബ്ലിക് ഓഫ് മാസിഡോണിയ", "name:mn"=>"Бүгд Найрамдах Македон Улс", "name:mr"=>"मॅसिडोनिया", "name:ms"=>"Republik Macedonia", "name:mt"=>"Repubblika tal-Maċedonja", "name:my"=>"မက်စီဒိုးနီးယားနိုင်ငံ", "name:na"=>"Matedoniya", "name:ne"=>"म्यासेडोनिया", "name:nl"=>"Noord-Macedonië", "name:nn"=>"Nord-Makedonia", "name:no"=>"Nord-Makedonia", "name:oc"=>"Republica de Macedònia", "name:or"=>"ମାସିଡୋନିଆ", "name:os"=>"Республикæ Македони", "name:pa"=>"ਮਕਦੂਨੀਆ ਗਣਰਾਜ", "name:pl"=>"Macedonia Północna", "name:ps"=>"د مقدونيې ولسمشريزه", "name:pt"=>"Macedónia do Norte", "name:qu"=>"Makidunya", "name:rm"=>"Macedonia", "name:rn"=>"Masedoniya", "name:ro"=>"Macedonia de Nord", "name:ru"=>"Северная Македония", "name:rw"=>"Masedoniya", "name:sa"=>"मेसेडोनिया", "name:sc"=>"Matzedònia", "name:se"=>"Davvi-Makedonia", "name:sg"=>"Maseduäni", "name:sh"=>"Severna Makedonija", "name:si"=>"මැසිඩෝනියාන [FYROM]", "name:sk"=>"Severné Macedónsko", "name:sl"=>"Makedonija", "name:sn"=>"Macedonia", "name:so"=>"Makedonia", "name:sq"=>"Maqedonia e Veriut", "name:sr"=>"Северна Македонија", "name:ss"=>"IMakhedoniya", "name:su"=>"Makédonia", "name:sv"=>"Nordmakedonien", "name:sw"=>"Jamhuri ya Masedonia", "name:ta"=>"மாக்கடோனியக் குடியரசு", "name:te"=>"మేసిడోనియా", "name:tg"=>"Ҷумҳурии Мақдуния", "name:th"=>"ประเทศมาซิโดเนีย", "name:ti"=>"ማከዶኒያ", "name:tk"=>"Makedoniýa Respublikasy", "name:tl"=>"Republika ng Masedonya", "name:to"=>"Masitōnia [FYROM]", "name:tr"=>"Kuzey Makedonya", "name:tt"=>"Македония Җөмһүрияте", "name:ug"=>"ماكېدونىيە", "name:uk"=>"Північна Македонія", "name:ur"=>"شمالی مقدونیہ", "name:uz"=>"Makedoniya Respublikasi", "name:vi"=>"Bắc Macedonia", "name:vo"=>"Nolüda-Makedoniyän", "name:wo"=>"Réewum Maseduwaan", "name:yi"=>"רעפובליק פון מאקעדאניע", "name:yo"=>"Orílẹ̀-èdè Olómìnira ilẹ̀ Makẹdóníà", "name:zh"=>"北马其顿共和国", "name:zu"=>"isi-Macedonia [FYROM]", "int_name"=>"North Macedonia", "name:ace"=>"Masèdonia", "name:als"=>"Republik Mazedonien", "name:ang"=>"Macedonia Cynewīse", "name:arc"=>"ܩܘܛܢܝܘܬܐ ܕܡܩܕܘܢܝܐ", "name:arz"=>"جمهورية مقدونيا", "name:ast"=>"República de Macedonia", "name:bar"=>"Mazedonien", "name:bcl"=>"Republika kan Masedonya", "name:ceb"=>"Republika sa Macedonia", "name:chr"=>"ᎹᏏᏙᏂᎢᎠ", "name:ckb"=>"کۆماری مەقدوونیا", "name:crh"=>"Makedoniya Cumhuriyeti", "name:csb"=>"Macedońskô", "name:diq"=>"Cumhuriyetê Makedonya", "name:dsb"=>"Makedońska", "name:ext"=>"Repúbrica de Macedónia", "name:frp"=>"Rèpublica de Macèdonie", "name:frr"=>"Mazedoonien", "name:fur"=>"Macedonie", "name:gag"=>"Makedoniya", "name:hak"=>"Mâ-khì-tun", "name:haw"=>"Repupalika ‘o Makekonia", "name:hif"=>"Macedonia", "name:hsb"=>"Makedonska", "name:ilo"=>"Macedonia", "name:jbo"=>"makedonias", "name:kaa"=>"Makedoniya", "name:kab"=>"Masidwan", "name:kbd"=>"Республикэ Македониэ", "name:koi"=>"Республика Македония", "name:krc"=>"Македония", "name:ksh"=>"de vörmaals ens jugoßlaawesch jewääse Republik Mazedoonije", "name:lad"=>"Makedonia", "name:lfn"=>"Macedonia", "name:lij"=>"Maçedònia", "name:lmo"=>"Macedonia", "name:ltg"=>"Makedonejis Republika", "name:mdf"=>"Македоние", "name:mhr"=>"Македоний", "name:nah"=>"Tlācatlahtohcāyōtl Macedonia", "name:nan"=>"Makedonija Kiōng-hô-kok", "name:nds"=>"Republiek Makedonien", "name:pam"=>"Republika ning Makedonia", "name:pap"=>"Macedonia", "name:pcd"=>"Machédoène", "name:pih"=>"Repablik o' Masedoenya", "name:pms"=>"Macedònia", "name:rmy"=>"Nordutni Makedoniya", "name:sah"=>"Македония", "name:scn"=>"Macidonia", "name:sco"=>"Macedonie", "name:smn"=>"Tave-Makedonia", "name:sms"=>"Tâʹvv-Makedonia", "name:stq"=>"Makedonien", "name:szl"=>"Macedůńijo", "name:tok"=>"ma Maketonija", "name:udm"=>"Македония Республика", "name:vec"=>"Republica de Macedonia", "name:vep"=>"Makedonii", "name:vls"=>"Nôord-Macedonië", "name:war"=>"Republika han Macedonia", "name:wuu"=>"北马其顿", "name:xal"=>"Масидин Орн", "name:xmf"=>"მაკედონია", "name:yue"=>"北馬其頓共和國", "name:zea"=>"Macedonië", "old_name"=>"Македонија", "name:UN:ar"=>"جمهورية شمال مقدونيا", "name:UN:el"=>"Βόρεια Μακεδονία", "name:UN:en"=>"Republic of North Macedonia", "name:UN:es"=>"Macedonia del Norte", "name:UN:fr"=>"l'ex-République yougoslave de Macédoine", "name:UN:he"=>"הרפובליקה היוגוסלבית לשעבר של מקדוניה", "name:UN:hr"=>"Bivša Jugoslavenska Republika Makedonija", "name:UN:ru"=>"бывшая югославская Республика Македония", "name:UN:sk"=>"Bývalá Juhoslovanská Republika Macedónsko", "name:UN:zh"=>"前南斯拉夫的马其顿共和国", "name:pt-BR"=>"Macedônia do Norte", "name:zh_py"=>"Maqidun", "alt_name:ar"=>"مقدونيا الشمالية", "alt_name:br"=>"Ez-Republik Yougoslaviat Makedonia", "alt_name:eo"=>"Nord-Makedonujo", "alt_name:pt"=>"Antiga República Jugoslava da Macedónia", "alt_name:vi"=>"Bắc Ma-xê-đô-ni-a;Ma-xê-đô-ni-a;Bắc Mác-kê-đôn-ni-a;Mác-kê-đôn-ni-a", "name:nds-nl"=>"Massedonië", "name:zh_pyt"=>"Mǎqídùn", "old_name:ar"=>"مقدونيا", "old_name:bg"=>"Македония", "old_name:bs"=>"Makedonija", "old_name:cs"=>"Makedonie", "old_name:cy"=>"Macedonia", "old_name:de"=>"Mazedonien", "old_name:el"=>"Πρώην Γιουγκοσλαβική Δημοκρατία της Μακεδονίας", "old_name:en"=>"Macedonia", "old_name:eu"=>"Mazedonia", "old_name:fa"=>"مقدونیه", "old_name:fr"=>"Macédoine", "old_name:fy"=>"Masedoanje", "old_name:he"=>"מקדוניה", "old_name:hr"=>"Makedonija", "old_name:ja"=>"マケドニア", "old_name:mk"=>"Македонија", "old_name:nl"=>"Macedonië", "old_name:nn"=>"Makedonia", "old_name:no"=>"Makedonia", "old_name:pt"=>"Macedônia", "old_name:ro"=>"Macedonia", "old_name:se"=>"Makedonia", "old_name:sk"=>"Macedónsko", "old_name:sq"=>"Maqedoni", "old_name:sr"=>"Македонија", "old_name:tr"=>"Makedonya Cumhuriyeti", "old_name:uk"=>"Македонія", "old_name:ur"=>"مقدونیہ", "old_name:vi"=>"Macedonia", "old_name:zh"=>"马其顿共和国", "name:bat-smg"=>"Makeduonėjė", "name:fiu-vro"=>"Makõdoonia Vabariik", "name:roa-rup"=>"Machedonia", "name:sr-Latn"=>"Severna Makedonija", "old_name:rmy"=>"Makedoniya", "name:roa-tara"=>"Macidonie", "official_name"=>"Република Северна Македонија", "short_name:ca"=>"Macedònia", "short_name:en"=>"Macedonia", "short_name:hr"=>"Makedonija", "short_name:mk"=>"Македонија", "short_name:sl"=>"Makedonija", "short_name:zh"=>"北马其顿", "name:be-tarask"=>"Рэспубліка Македонія", "name:zh_pinyin"=>"Mǎqídùn", "official_name:af"=>"Republiek van Masedonië", "official_name:ar"=>"جمهورية شمال مقدونيا", "official_name:be"=>"Рэспубліка Македонія ", "official_name:bg"=>"Република Северна Македония", "official_name:br"=>"Republik Makedonia", "official_name:bs"=>"Republika Sjeverna Makedonija", "official_name:ca"=>"República de Macedònia del Nord", "official_name:cs"=>"Republika Severní Makedonie", "official_name:cy"=>"Gweriniaeth Gogledd Macedonia", "official_name:de"=>"Republik Nordmazedonien", "official_name:el"=>"Δημοκρατία της Βόρειας Μακεδονίας", "official_name:en"=>"Republic of North Macedonia", "official_name:eo"=>"Respubliko Makedonujo", "official_name:es"=>"República de Macedonia del Norte", "official_name:et"=>"Makedoonia Vabariik", "official_name:eu"=>"Ipar Mazedoniako Errepublika", "official_name:fa"=>"جمهوری مقدونیه شمالی", "official_name:fr"=>"République de Macédoine du Nord", "official_name:gl"=>"República de Macedonia do Norte", "official_name:he"=>"רפובליקת מקדוניה הצפונית", "official_name:hr"=>"Republika Sjeverna Makedonija", "official_name:it"=>"Repubblica di Macedonia del Nord", "official_name:ja"=>"マケドニア旧ユーゴスラビア共和国", "official_name:ku"=>"Komara Makedonyayê", "official_name:lv"=>"Maķedonijas Republika", "official_name:mk"=>"Република Северна Македонија", "official_name:nn"=>"Republikken Nord-Makedonia", "official_name:no"=>"Republikken Nord-Makedonia", "official_name:pl"=>"Republika Macedonii Północnej", "official_name:pt"=>"República da Macedônia", "official_name:ro"=>"Republica Macedonia", "official_name:se"=>"Dásseváldi Davvi-Makedonia", "official_name:sk"=>"Republika Severné Macedónsko", "official_name:sl"=>"Republika Makedonija", "official_name:sq"=>"Republika e Maqedonisë së Veriut", "official_name:sr"=>"Република Северна Македонија", "official_name:sv"=>"Republiken Makedonien", "official_name:tl"=>"Republika ng Masedonya", "official_name:tr"=>"Kuzey Makedonya Cumhuriyeti", "official_name:uk"=>"Республіка Македонія", "official_name:ur"=>"جمہوریہ شمالی مقدونیہ", "official_name:vi"=>"Cộng hòa Bắc Macedonia", "old_name:sr-Latn"=>"Makedonija", "official_name:sr-Latn"=>"Republika Severna Makedonija" mk 69 pg "name"=>"Papua New Guinea", "name:af"=>"Papoea-Nieu-Guinee", "name:ar"=>"بابوا نيوغينيا", "name:be"=>"Папуа-Новая Гвінея ", "name:br"=>"Papoua Ginea Nevez", "name:ca"=>"Papua Nova Guinea", "name:cy"=>"Papua Guinea Newydd", "name:da"=>"Papua Ny Guinea", "name:de"=>"Papua-Neuguinea", "name:en"=>"Papua New Guinea", "name:eo"=>"Papuo-Nov-Gvineo", "name:es"=>"Papúa Nueva Guinea", "name:et"=>"Paapua Uus-Guinea", "name:fa"=>"پاپوآ گینه نو", "name:fi"=>"Papua-Uusi-Guinea", "name:fr"=>"Papouasie-Nouvelle-Guinée", "name:fy"=>"Papoea Nij-Guinea", "name:ga"=>"Nua-Ghuine Phapua", "name:gd"=>"Papua Gini-Nuadh", "name:he"=>"פפואה גינאה החדשה", "name:hr"=>"Papua Nova Gvineja", "name:hu"=>"Pápua Új-Guinea", "name:id"=>"Papua Nugini", "name:is"=>"Papúa Nýja-Gínea", "name:it"=>"Papua Nuova Guinea", "name:la"=>"Papua Nova Guinea", "name:lb"=>"Papua-Neiguinea", "name:li"=>"Papoea-Nui-Guinea", "name:lt"=>"Papua ir Naujoji Gvinėja", "name:lv"=>"Papua-Jaungvineja", "name:mn"=>"Папуа-Шинэ Гвиней", "name:nl"=>"Papoea-Nieuw-Guinea", "name:pl"=>"Papua-Nowa Gwinea", "name:ru"=>"Папуа-Новая Гвинея", "name:sl"=>"Papua Nova Gvineja", "name:sv"=>"Papua Nya Guinea", "name:th"=>"ประเทศปาปัวนิวกินี", "name:tr"=>"Papua -Yeni Gine", "name:uk"=>"Папуа-Нова Гвінея", "name:zh"=>"巴布亚新几内亚", "official_name"=>"Independent State of Papua New Guinea;Independen Stet bilong Papua Niugini", "official_name:es"=>"Estado Independiente de Papúa Nueva Guínea", "official_name:et"=>"Paapua Uus-Guinea Iseseisvusriik", "official_name:lv"=>"Papua-Jaungvinejas Neatkarīgā Valsts", "official_name:pl"=>"Niezależne Państwo Papui-Nowej Gwinei", "official_name:vi"=>"Quốc gia Độc lập Papua New Guinea" \N 71 sd "name"=>"السودان ‎al-Sūdān", "name:af"=>"Soedan", "name:ar"=>"السودان", "name:be"=>"Судан", "name:br"=>"Soudan", "name:ca"=>"Sudan ", "name:cy"=>"Sudan", "name:da"=>"Sudan", "name:de"=>"Sudan", "name:el"=>"Σουδάν", "name:en"=>"Sudan", "name:eo"=>"Sudano", "name:es"=>"Sudán", "name:et"=>"Sudaan", "name:fa"=>"سودان", "name:fi"=>"Sudan", "name:fr"=>"Soudan", "name:fy"=>"Sûdan", "name:ga"=>"An tSúdáin", "name:gd"=>"Sudan", "name:he"=>"סודן", "name:hr"=>"Sudan", "name:hu"=>"Szudán", "name:id"=>"Sudan", "name:is"=>"Súdan", "name:it"=>"Sudan", "name:ja"=>"スーダン", "name:la"=>"Sudania", "name:lb"=>"Sudan", "name:li"=>"Soedaan", "name:lt"=>"Sudanas", "name:lv"=>"Sudāna", "name:mn"=>"Судан", "name:nl"=>"Soedan", "name:pl"=>"Sudan", "name:pt"=>"Sudão", "name:ru"=>"Судан", "name:sl"=>"Sudan", "name:sv"=>"Sudan", "name:th"=>"ประเทศซูดาน", "name:tr"=>"Sudan", "name:uk"=>"Судан", "name:vi"=>"Sudan", "name:zh"=>"苏丹", "name:haw"=>"Sudana", "name:zh_py"=>"Sudan", "name:zh_pyt"=>"Sūdān", "official_name"=>"جمهورية السودان", "official_name:br"=>"Republik Soudan", "official_name:el"=>"Δημοκρατία του Σουδάν", "official_name:en"=>"Republic of Sudan", "official_name:et"=>"Sudaani Vabariik", "official_name:fr"=>"République du Soudan", "official_name:id"=>"Republik Sudan", "official_name:ja"=>"スーダン共和国", "official_name:lb"=>"Republik Sudan", "official_name:pt"=>"República do Sudão", "official_name:sv"=>"Republiken Sudan", "official_name:vi"=>"Cộng hòa Sudan" \N 72 za "name"=>"South Africa", "name:af"=>"Suid-Afrika", "name:ar"=>"جنوب أفريقيا", "name:be"=>"Паўднёва-Афрыканская Рэспубліка", "name:br"=>"Suafrika", "name:ca"=>"Sud-àfrica", "name:cy"=>"De Affrica", "name:da"=>"Sydafrika", "name:de"=>"Südafrika", "name:el"=>"Νότια Αφρική", "name:en"=>"South Africa", "name:eo"=>"Sudafriko", "name:es"=>"Sudáfrica", "name:et"=>"Lõuna-Aafrika Vabariik", "name:fa"=>"آفریقای جنوبی", "name:fi"=>"Etelä-Afrikka", "name:fr"=>"Afrique du Sud", "name:fy"=>"Súd-Afrika", "name:ga"=>"An Afraic Theas", "name:gd"=>"Afraga a Deas", "name:he"=>"דרום אפריקה", "name:hr"=>"Južnoafrička Republika", "name:hu"=>"Dél-Afrikai Köztársaság", "name:id"=>"Afrika Selatan", "name:is"=>"Suður-Afríka", "name:it"=>"Sudafrica", "name:ja"=>"南アフリカ", "name:la"=>"Africa Australis", "name:lb"=>"Südafrika", "name:li"=>"Zuud-Afrika", "name:lt"=>"Pietų Afrikos Respublika", "name:mn"=>"Өмнөд Африк", "name:nl"=>"Zuid-Afrika", "name:pl"=>"Republika Południowej Afryki", "name:pt"=>"África do Sul", "name:ru"=>"Южная Африка", "name:sl"=>"Južna Afrika", "name:ss"=>"INingizimu Afrika", "name:st"=>"Afrika Borwa", "name:sv"=>"Sydafrika", "name:th"=>"ประเทศแอฟริกาใต้", "name:tn"=>"Aferika Borwa", "name:tr"=>"Güney Afrika", "name:ts"=>"Afrika-Dzonga", "name:uk"=>"Південно-Африканська Республіка", "name:ve"=>"Afurika Tshipembe", "name:vi"=>"Nam Phi", "name:xh"=>"uMzantsi Afrika", "name:zh"=>"南非", "name:zu"=>"Ningizimu Afrika", "name:haw"=>"ʻApelika Hema", "name:zh_py"=>"Nan Fei", "name:zh_pyt"=>"Nán Fēi", "official_name"=>"Republic of South Africa", "official_name:br"=>"Republik Suafrika", "official_name:en"=>"Republic of South Africa", "official_name:fr"=>"République d'Afrique du Sud", "official_name:gd"=>"Poblachd Afraga a Deas", "official_name:id"=>"Republik Afrika Selatan", "official_name:ja"=>"南アフリカ共和国", "official_name:lb"=>"Republik Südafrika", "official_name:pt"=>"República da África do Sul", "official_name:ru"=>"Южно-Африканская Республика", "official_name:sl"=>"Republika Južna Afrika", "official_name:sv"=>"Republiken Sydafrika", "official_name:ts"=>"Riphabliki ra Afrika Dzonga", "official_name:ve"=>"Riphabuḽiki ya Afurika Tshipembe", "official_name:vi"=>"Cộng hòa Nam Phi" \N 76 diff --git a/docs/admin/Deployment.md b/docs/admin/Deployment.md new file mode 100644 index 00000000..9ef7f489 --- /dev/null +++ b/docs/admin/Deployment.md @@ -0,0 +1,141 @@ +# Deploying Nominatim + +The Nominatim API is implemented as a PHP application. The `website/` directory +in the build directory contains the configured website. You can serve this +in a production environment with any web server that is capable to run +PHP scripts. + +This section gives a quick overview on how to configure Apache and Nginx to +serve Nominatim. It is not meant as a full system administration guide on how +to run a web service. Please refer to the documentation of +[Apache](http://httpd.apache.org/docs/current/) and +[Nginx](https://nginx.org/en/docs/) +for background information on configuring the services. + +!!! Note + Throughout this page, we assume that your Nominatim build directory is + located in `/srv/nominatim/build` and the source code in + `/srv/nominatim/Nominatim`. If you have put it somewhere else, you + need to adjust the commands and configuration accordingly. + + We further assume that your web server runs as user `www-data`. Older + versions of CentOS may still use the user name `apache`. You also need + to adapt the instructions in this case. + +## Making the website directory accessible + +You need to make sure that the `website` directory is accessible for the +web server user. You can check that the permissions are correct by accessing +on of the php files as the web server user: + +``` sh +sudo -u www-data head -n 1 /srv/nominatim/build/website/search.php +``` + +If this shows a permission error, then you need to adapt the permissions of +each directory in the path so that it is executable for `www-data`. + +If you have SELinux enabled, further adjustments may be necessary to give the +web server access. At a minimum the following SELinux labelling should be done +for Nominatim: + +``` sh +sudo semanage fcontext -a -t httpd_sys_content_t "/srv/nominatim/Nominatim/(website|lib|settings)(/.*)?" +sudo semanage fcontext -a -t httpd_sys_content_t "/srv/nominatim/build/(website|settings)(/.*)?" +sudo semanage fcontext -a -t lib_t "/srv/nominatim/build/module/nominatim.so" +sudo restorecon -R -v /srv/nominatim/Nominatim +sudo restorecon -R -v /srv/nominatim/build +``` + +## Nominatim with Apache + +### Installing the required packages + +With Apache you can use the PHP module to run Nominatim. + +Under Ubuntu/Debian install them with: + +``` sh +sudo apt install apache2 libapache2-mod-php +``` + +### Configuring Apache + +Make sure your Apache configuration contains the required permissions for the +directory and create an alias: + +``` apache + + Options FollowSymLinks MultiViews + AddType text/html .php + DirectoryIndex search.php + Require all granted + +Alias /nominatim /srv/nominatim/build/website +``` + +After making changes in the apache config you need to restart apache. +The website should now be available on `http://localhost/nominatim`. + +## Nominatim with Nginx + +### Installing the required packages + +Nginx has no built-in PHP interpreter. You need to use php-fpm as a deamon for +serving PHP cgi. + +On Ubuntu/Debian install nginx and php-fpm with: + +``` sh +sudo apt install nginx php-fpm +``` + +### Configure php-fpm and Nginx + +By default php-fpm listens on a network socket. If you want it to listen to a +Unix socket instead, change the pool configuration +(`/etc/php//fpm/pool.d/www.conf`) as follows: + +``` ini +; Replace the tcp listener and add the unix socket +listen = /var/run/php-fpm.sock + +; Ensure that the daemon runs as the correct user +listen.owner = www-data +listen.group = www-data +listen.mode = 0666 +``` + +Tell nginx that php files are special and to fastcgi_pass to the php-fpm +unix socket by adding the location definition to the default configuration. + +``` nginx +root /srv/nominatim/build/website; +index search.php; +location / { + try_files $uri $uri/ @php; +} + +location @php { + fastcgi_param SCRIPT_FILENAME "$document_root$uri.php"; + fastcgi_param PATH_TRANSLATED "$document_root$uri.php"; + fastcgi_param QUERY_STRING $args; + fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; +} + +location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_index search.php; + include fastcgi.conf; +} +``` + +Restart the nginx and php-fpm services and the website should now be available +at `http://localhost/`. + diff --git a/docs/admin/Import.md b/docs/admin/Import.md index ded69293..334c1b75 100644 --- a/docs/admin/Import.md +++ b/docs/admin/Import.md @@ -187,7 +187,7 @@ 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. -### Verify import finished +### Verify the import Run this script to verify all required tables and indices got created successfully. @@ -197,9 +197,8 @@ Run this script to verify all required tables and indices got created successful ### Setting up the website -Run the following command to set up the `website/settings-frontend.php`. -These settings are used in website/*.php files. You can use the website only after this -step is completed. +Run the following command to set up the configuration file for the website +`settings/settings-frontend.php`. These settings are used in website/*.php files. ```sh ./utils/setup.php --setup-website @@ -207,6 +206,20 @@ step is completed. !!! Note This step is not necessary if you use `--all` option while setting up the DB. +Now you can try out your installation by running: + +```sh +make serve +``` + +This runs a small test server normally used for development. You can use it +to verify that your installation is working. Go to +`http://localhost:8088/status.php` and you should see the message `OK`. +You can also run a search query, e.g. `http://localhost:8088/search.php?q=Berlin`. + +To run Nominatim via webservers like Apache or nginx, please read the +[Deployment chapter](Deployment.md). + ## Tuning the database Accurate word frequency information for search terms helps PostgreSQL's query @@ -247,8 +260,6 @@ entire US adds about 10GB to your database. wget https://nominatim.org/data/tiger2019-nominatim-preprocessed.tar.gz tar xf tiger2019-nominatim-preprocessed.tar.gz - `data-source/overview.md` explains how the data got preprocessed. - 2. Import the data into your Nominatim database: ./utils/setup.php --import-tiger-data @@ -264,3 +275,6 @@ entire US adds about 10GB to your database. ``` +See the [developer's guide](../develop/data-sources.md#us-census-tiger) for more +information on how the data got preprocessed. + diff --git a/docs/admin/Installation.md b/docs/admin/Installation.md index bc97212e..b9705eb5 100644 --- a/docs/admin/Installation.md +++ b/docs/admin/Installation.md @@ -43,17 +43,13 @@ For running Nominatim: * [PHP](https://php.net) (7.0 or later) * PHP-pgsql * PHP-intl (bundled with PHP) - * a webserver (apache or nginx are recommended) For running continuous updates: * [pyosmium](https://osmcode.org/pyosmium/) (with Python 3) -For running tests: - - * [behave](http://pythonhosted.org/behave/) - * [nose](https://nose.readthedocs.io) - * [phpunit](https://phpunit.de) >= 7.3 +For dependencies for running tests and building documentation, see +the [Development section](../develop/Development-Environment.md). ### Hardware @@ -68,9 +64,7 @@ will help considerably to speed up import and queries. 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 - -### PostgreSQL tuning +## Tuning the PostgreSQL database 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 @@ -110,82 +104,44 @@ Don't forget to reenable them after the initial import or you risk database corruption. -### Webserver setup +## Downloading and building Nominatim -The `website/` directory in the build directory contains the configured -website. Include the directory into your webbrowser to serve php files -from there. +### Downloading the latest release -#### Configure for use with Apache +You can download the [latest release from nominatim.org](https://nominatim.org/downloads/). +The release contains all necessary files. Just unpack it. -Make sure your Apache configuration contains the required permissions for the -directory and create an alias: +### Downloading the latest development version -``` apache - - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - -Alias /nominatim /srv/nominatim/build/website +If you want to install latest development version from github, make sure to +also check out the osm2pgsql subproject: + +``` +git clone --recursive git://github.com/openstreetmap/Nominatim.git ``` -`/srv/nominatim/build` should be replaced with the location of your -build directory. - -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 - -Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx. - -By default php listens on a network socket. If you want it to listen to a -Unix socket instead, change the pool configuration (`pool.d/www.conf`) as -follows: - - ; Comment out the tcp listener and add the unix socket - ;listen = 127.0.0.1:9000 - listen = /var/run/php5-fpm.sock - - ; Ensure that the daemon runs as the correct user - listen.owner = www-data - listen.group = www-data - listen.mode = 0666 - -Tell nginx that php files are special and to fastcgi_pass to the php-fpm -unix socket by adding the location definition to the default configuration. - -``` nginx -root /srv/nominatim/build/website; -index search.php; -location / { - try_files $uri $uri/ @php; -} - -location @php { - fastcgi_param SCRIPT_FILENAME "$document_root$uri.php"; - fastcgi_param PATH_TRANSLATED "$document_root$uri.php"; - fastcgi_param QUERY_STRING $args; - fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; - fastcgi_index index.php; - include fastcgi_params; -} - -location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - fastcgi_pass unix:/var/run/php7.3-fpm.sock; - fastcgi_index search.php; - include fastcgi.conf; -} +The development version does not include the country grid. Download it separately: + +``` +wget -O Nominatim/data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz ``` -Restart the nginx and php5-fpm services and the website should now be available -at `http://localhost/`. +### Building Nominatim + +The code must be built in a separate directory. Create the directory and +change into it. +``` +mkdir build +cd build +``` + +Nominatim uses cmake and make for building. Assuming that you have created the +build at the same level as the Nominatim source directory run: + +``` +cmake ../Nominatim +make +``` Now continue with [importing the database](Import.md). diff --git a/docs/develop/Development-Environment.md b/docs/develop/Development-Environment.md new file mode 100644 index 00000000..2ebaaedc --- /dev/null +++ b/docs/develop/Development-Environment.md @@ -0,0 +1,170 @@ +# Setting up Nominatim for Development + +This chapter gives an overview how to set up Nominatim for developement +and how to run tests. + +!!! Important + This guide assumes that you develop under the latest version of Ubuntu. You + can of course also use your favourite distribution. You just might have to + adapt the commands below slightly, in particular the commands for installing + additional software. + +## Installing Nominatim + +The first step is to install Nominatim itself. Please follow the installation +instructions in the [Admin section](../admin/Installation.md). You don't need +to set up a webserver for development, the webserver that is included with PHP +is sufficient. + +If you want to run Nominatim in a VM via Vagrant, use the default `ubuntu` setup. +Vagrant's libvirt provider runs out-of-the-box under Ubuntu. You also need to +install an NFS daemon to enable directory sharing between host and guest. The +following packages should get you started: + + sudo apt install vagrant vagrant-libvirt libvirt-daemon nfs-kernel-server + +## Prerequisites for testing and documentation + +The Nominatim tests suite consists of behavioural tests (using behave) and +unit tests (using PHPUnit). It has the following additional requirements: + +* [behave test framework](https://github.com/behave/behave) >= 1.2.5 +* [nose](https://nose.readthedocs.org) +* [pytidylib](http://countergram.com/open-source/pytidylib) +* [phpunit](https://phpunit.de) >= 7.3 +* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) + +The documentation is built with mkdocs: + +* [mkdocs](https://www.mkdocs.org/) >= 1.1.2 + +### Installing prerequisites on Ubuntu/Debian + +Some of the Python packages require the newest version which is not yet +available with the current distributions. Therefore it is recommended to +install pip to get the newest versions. + +To install all necessary packages run: + +```sh +sudo apt install php-cgi phpunit php-codesniffer \ + python3-pip python3-setuptools python3-dev + +pip3 install --user behave nose mkdocs +``` + +The `mkdocs` executable will be located in `.local/bin`. You may have to add +this directory to your path, for example by running: + +``` +echo 'export PATH=~/.local/bin:$PATH' > ~/.profile +``` + +If your distribution does not have PHPUnit 7.3+, you can install it (as well +as CodeSniffer) via composer: + +``` +sudo apt-get install composer +composer global require "squizlabs/php_codesniffer=*" +composer global require "phpunit/phpunit=8.*" +``` + +The binaries are found in `.config/composer/vendor/bin`. You need to add this +to your PATH as well: + +``` +echo 'export PATH=~/.config/composer/vendor/bin:$PATH' > ~/.profile +``` + + +## Executing Tests + +All tests are located in the `\test` directory. + +### Preparing the test database + +Some of the behavioural test expect a test database to be present. You need at +least 2GB RAM and 10GB disk space to create the database. + +First create a separate directory for the test DB and Fetch the test planet +data and the Tiger data for South Dakota: + +``` +mkdir testdb +cd testdb +wget https://www.nominatim.org/data/test/nominatim-api-testdata.pbf +wget -O - https://nominatim.org/data/tiger2018-nominatim-preprocessed.tar.gz | tar xz --wildcards --no-anchored '46*' +``` + +Configure and build Nominatim in the usual way: + +``` +cmake $USERNAME/Nominatim +make +``` + +Copy the test settings: + +``` +cp $USERNAME/Nominatim/test/testdb/local.php settings/ +``` + +Inspect the file to check that all settings are correct for your local setup. + +Now you can import the test database: + +``` +dropdb --if-exists test_api_nominatim +./utils/setup.php --all --osm-file nominatim-api-testdb.pbf 2>&1 | tee import.log +./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim 2>&1 | tee -a import.log +./utils/setup.php --import-tiger-data 2>&1 | tee -a import.log +``` + +### Running the tests + +To run all tests just go to the test directory and run make: + +```sh +cd test +make +``` + +To skip tests that require the test database, run `make no-test-db` instead. + +For more information about the structure of the tests and how to change and +extend the test suite, see the [Testing chapter](Testing.md). + +## Documentation Pages + +The [Nominatim documentation](https://nominatim.org/release-docs/develop/) is +built using the [MkDocs](https://www.mkdocs.org/) static site generation +framework. The master branch is automatically deployed every night on +[https://nominatim.org/release-docs/develop/](https://nominatim.org/release-docs/develop/) + +To build the documentation, go to the build directory and run + +``` +make doc +INFO - Cleaning site directory +INFO - Building documentation to directory: /home/vagrant/build/site-html +``` + +This runs `mkdocs build` plus extra transformation of some files and adds +symlinks (see `CMakeLists.txt` for the exact steps). + +Now you can start webserver for local testing + +``` +build> mkdocs serve +[server:296] Serving on http://127.0.0.1:8000 +[handlers:62] Start watching changes +``` + +If you develop inside a Vagrant virtual machine, use a port that is forwarded +to your host: + +``` +build> mkdocs serve --dev-addr 0.0.0.0:8088 +[server:296] Serving on http://0.0.0.0:8088 +[handlers:62] Start watching changes +``` diff --git a/docs/develop/Documentation.md b/docs/develop/Documentation.md deleted file mode 100644 index 0d3c3e02..00000000 --- a/docs/develop/Documentation.md +++ /dev/null @@ -1,39 +0,0 @@ -# Documentation Pages - -The [Nominatim documentation](https://nominatim.org/release-docs/develop/) is built using the [MkDocs](https://www.mkdocs.org/) static site generation framework. The master branch is automatically deployed every night on under [https://nominatim.org/release-docs/develop/](https://nominatim.org/release-docs/develop/) - -To preview local changes, first install MkDocs - -``` -pip3 install --user mkdocs -``` - -If `mkdocs` can't be found after the installation, the $PATH might have not -been set correctly yet. Try opening a new terminal session. - - -Then go to the build directory and run - -``` -make doc -INFO - Cleaning site directory -INFO - Building documentation to directory: /home/vagrant/build/site-html -``` - -This runs `mkdocs build` plus extra transformation of some files and adds -symlinks (see `CMakeLists.txt` for the exact steps). - -Now you can start webserver for local testing - -``` -build> mkdocs serve -[server:296] Serving on http://127.0.0.1:8000 -[handlers:62] Start watching changes -``` - -If you develop inside a Vagrant virtual machine: - - * add port forwarding to your Vagrantfile, - e.g. `config.vm.network "forwarded_port", guest: 8000, host: 8000` - * use `mkdocs serve --dev-addr 0.0.0.0:8000` because the default localhost - IP does not get forwarded. diff --git a/docs/develop/Setup.md b/docs/develop/Setup.md deleted file mode 100644 index 8a73280e..00000000 --- a/docs/develop/Setup.md +++ /dev/null @@ -1,52 +0,0 @@ -# Setup Test Environment - -To test changes and contribute to Nominatim you should be able to run -the test suite(s). For many usecases it's enough to create a Vagrant -virtual machine (see `VAGRANT.md`), import one small country into the -database. - -## Prerequisites - -Nominatim supports a range of PHP versions and PHPUnit versions also -move fast. We try to test against the newest stable PHP release and -PHPUnit version even though we expect many Nominatim users will install -older version on their production servers. - - * Python 3 (https://www.python.org/) - * behave test framework >= 1.2.5 (https://github.com/behave/behave) - * nose (https://nose.readthedocs.org) - * pytidylib (http://countergram.com/open-source/pytidylib) - * psycopg2 (http://initd.org/psycopg/) - -#### Ubuntu 20 - - sudo apt-get install -y phpunit php-codesniffer php-cgi - pip3 install --user behave nose - -#### Ubuntu 18 - - pip3 install --user behave nose - - sudo apt-get install -y composer php-cgi php-cli php-mbstring php-xml zip unzip - - composer global require "squizlabs/php_codesniffer=*" - sudo ln -s ~/.config/composer/vendor/bin/phpcs /usr/bin/ - - composer global require "phpunit/phpunit=8.*" - sudo ln -s ~/.config/composer/vendor/bin/phpunit /usr/bin/ - - -#### CentOS 7 or 8 - - sudo dnf install -y php-dom php-mbstring - pip3 install --user behave nose - - composer global require "squizlabs/php_codesniffer=*" - sudo ln -s ~/.config/composer/vendor/bin/phpcs /usr/bin/ - - composer global require "phpunit/phpunit=^7" - sudo ln -s ~/.config/composer/vendor/bin/phpunit /usr/bin/ - -## Run tests, code linter, code coverage - -See `README.md` in `test` subdirectory. diff --git a/test/README.md b/docs/develop/Testing.md similarity index 67% rename from test/README.md rename to docs/develop/Testing.md index c2dee41a..03f9574f 100644 --- a/test/README.md +++ b/docs/develop/Testing.md @@ -1,12 +1,10 @@ -This directory contains functional and unit tests for the Nominatim API. +# Nominatim Test Suite -Prerequisites -============= +This chapter describes the tests in the `/test` directory, how they are +structured and how to extend them. For a quick introduction on how to run +the tests, see the [Development setup chapter](Development-Environment.md). -See `docs/develop/Setup.md` - -Overall structure -================= +## Overall structure There are two kind of tests in this test suite. There are functional tests which test the API interface using a BDD test framework and there are unit @@ -27,8 +25,7 @@ This test directory is sturctured as follows: +- testdb Base data for generating API test database ``` -PHP Unit Tests -============== +## PHP Unit Tests (`test/php`) Unit tests can be found in the php/ directory and tests selected php functions. Very low coverage. @@ -44,14 +41,19 @@ strip and set other parameters. It will use (and destroy) a local database 'nominatim_unit_tests'. You can set a different connection string with e.g. UNIT_TEST_DSN='pgsql:dbname=foo_unit_tests'. -BDD Functional Tests -==================== +## BDD Functional Tests (`test/bdd`) Functional tests are written as BDD instructions. For more information on -the philosophy of BDD testing, see http://pythonhosted.org/behave/philosophy.html +the philosophy of BDD testing, see the +[Behave manual](http://pythonhosted.org/behave/philosophy.html). + +The following explanation assume that the reader is familiar with the BDD +notations of features, scenarios and steps. -Usage ------ +All possible steps can be found in the `steps` directory and should ideally +be documented. + +### General Usage To run the functional tests, do @@ -81,62 +83,29 @@ The tests can be configured with a set of environment variables (`behave -D key= run, otherwise the result is undefined. Logging can be defined through command line parameters of behave itself. Check -out `behave --help` for details. Also keep an eye out for the 'work-in-progress' +out `behave --help` for details. Also have a look at the 'work-in-progress' feature of behave which comes in handy when writing new tests. -Writing Tests -------------- - -The following explanation assume that the reader is familiar with the BDD -notations of features, scenarios and steps. - -All possible steps can be found in the `steps` directory and should ideally -be documented. - ### API Tests (`test/bdd/api`) These tests are meant to test the different API endpoints and their parameters. -They require a to import several datasets into a test database. You need at -least 2GB RAM and 10GB discspace. - - -1. Fetch the OSM planet extract (200MB). See end of document how it got created. +They require a to import several datasets into a test database. +See the [Development Setup chapter](Development-Environment.md#preparing-the-test-database) +for instructions on how to set up this database. - ``` - cd Nominatim/data - mkdir testdb - cd testdb - wget https://www.nominatim.org/data/test/nominatim-api-testdata.pbf - ``` - -2. Fetch `46*` (South Dakota) Tiger data - - ``` - cd Nominatim/data/testdb - wget https://nominatim.org/data/tiger2018-nominatim-preprocessed.tar.gz - tar xvf tiger2018-nominatim-preprocessed.tar.gz --wildcards --no-anchored '46*' - rm tiger2018-nominatim-preprocessed.tar.gz - ``` - -3. Adapt build/settings/local.php settings: - - ``` - @define('CONST_Database_DSN', 'pgsql:dbname=test_api_nominatim'); - @define('CONST_Use_US_Tiger_Data', true); - @define('CONST_Tiger_Data_Path', CONST_ExtraDataPath.'/testdb'); - @define('CONST_Wikipedia_Data_Path', CONST_BasePath.'/test/testdb'); - ``` +The official test dataset was derived from the 180924 planet (note: such +file no longer exists at https://planet.openstreetmap.org/planet/2018/). +Newer planets are likely to work as well but you may see isolated test +failures where the data has changed. -4. Import +The official test dataset can always be downloaded from +[nominatim.org](https://www.nominatim.org/data/test/nominatim-api-testdata.pbf) +To recreate the input data for the test database run: - ``` - LOGFILE=/tmp/nominatim-testdb.$$.log - dropdb --if-exists test_api_nominatim - ./utils/setup.php --all --osm-file ../Nominatim/data/testdb/nominatim-api-testdb.pbf 2>&1 | tee $LOGFILE - ./utils/specialphrases.php --wiki-import > specialphrases.sql - psql -d test_api_nominatim -f specialphrases.sql 2>&1 | tee -a $LOGFILE - ./utils/setup.php --import-tiger-data 2>&1 | tee -a $LOGFILE - ``` +``` +wget https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/pbf/planet-180924.osm.pbf +osmconvert planet-180924.osm.pbf -B=test/testdb/testdb.polys -o=testdb.pbf +``` #### Code Coverage @@ -146,7 +115,7 @@ On Debian/Ubuntu run: apt-get install php-codecoverage php-xdebug -The run the API tests as follows: +Then run the API tests as follows: behave api -DPHPCOV= @@ -155,7 +124,7 @@ the [phpcov](https://github.com/sebastianbergmann/phpcov) tool: phpcov merge --html= -### Indexing Tests (`test/bdd/db`) +### DB Creation Tests (`test/bdd/db`) These tests check the import and update of the Nominatim database. They do not test the correctness of osm2pgsql. Each test will write some data into the `place` @@ -171,16 +140,3 @@ needs superuser rights for postgres. These tests check that data is imported correctly into the place table. They use the same template database as the Indexing tests, so the same remarks apply. - - - -How the test database extract was generated -------------------------------------------- -The official test dataset was derived from the 180924 planet (note: such -file no longer exists at https://planet.openstreetmap.org/planet/2018/). -Newer planets are likely to work as well but you may see isolated test -failures where the data has changed. To recreate the input data -for the test database run: - - wget https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/pbf/planet-180924.osm.pbf - osmconvert planet-180924.osm.pbf -B=test/testdb/testdb.polys -o=testdb.pbf diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 4b097c8c..b055e9f0 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -16,19 +16,20 @@ pages: - 'FAQ': 'api/Faq.md' - 'Administration Guide': - 'Basic Installation': 'admin/Installation.md' - - 'Importing' : 'admin/Import.md' - - 'Updating' : 'admin/Update.md' + - 'Import' : 'admin/Import.md' + - 'Update' : 'admin/Update.md' + - 'Deploy' : 'admin/Deployment.md' - 'Nominatim UI' : 'admin/Setup-Nominatim-UI.md' - 'Advanced Installations' : 'admin/Advanced-Installations.md' - 'Migration from older Versions' : 'admin/Migration.md' - 'Troubleshooting' : 'admin/Faq.md' - 'Developers Guide': - - 'Overview' : 'develop/overview.md' + - 'Setup for Development' : 'develop/Development-Environment.md' + - 'Architecture Overview' : 'develop/overview.md' - 'OSM Data Import' : 'develop/Import.md' - 'Place Ranking' : 'develop/Ranking.md' - 'Postcodes' : 'develop/Postcodes.md' - - 'Setup Test Environment' : 'develop/Setup.md' - - 'Building Documentation' : 'develop/Documentation.md' + - 'Testing' : 'develop/Testing.md' - 'External Data Sources': 'develop/data-sources.md' - 'Appendix': - 'Installation on CentOS 7' : 'appendix/Install-on-Centos-7.md' diff --git a/lib/ClassTypes.php b/lib/ClassTypes.php index 4077d211..f2c1ab84 100644 --- a/lib/ClassTypes.php +++ b/lib/ClassTypes.php @@ -18,6 +18,8 @@ function getLabelTag($aPlace, $sCountry = null) $sLabel = $aPlace['place_type']; } elseif ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') { $sLabel = getBoundaryLabel($iRank/2, $sCountry); + } elseif ($aPlace['type'] == 'postal_code') { + $sLabel = 'postcode'; } elseif ($iRank < 26) { $sLabel = $aPlace['type']; } elseif ($iRank < 28) { diff --git a/lib/init.php b/lib/init.php index 0bd23e31..082d1bf5 100644 --- a/lib/init.php +++ b/lib/init.php @@ -2,8 +2,3 @@ require_once(CONST_BasePath.'/lib/lib.php'); require_once(CONST_BasePath.'/lib/DB.php'); - -if (get_magic_quotes_gpc()) { - echo "Please disable magic quotes in your php.ini configuration\n"; - exit; -} diff --git a/settings/defaults.php b/settings/defaults.php index 7a7a1e6f..02b11237 100644 --- a/settings/defaults.php +++ b/settings/defaults.php @@ -85,7 +85,7 @@ if (file_exists(CONST_InstallPath.'/settings/local.php')) require_once(CONST_Ins // Website settings @define('CONST_NoAccessControl', true); -@define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/'); +@define('CONST_Website_BaseURL', '/'); // Language to assume when none is supplied with the query. // When set to false, the local language (i.e. the name tag without suffix) // will be used. diff --git a/settings/import-address.style b/settings/import-address.style index bff9fa65..16f2e929 100644 --- a/settings/import-address.style +++ b/settings/import-address.style @@ -44,7 +44,8 @@ { "keys" : ["boundary"], "values" : { - "administrative" : "main" + "administrative" : "main", + "postal_code" : "main" } }, { diff --git a/settings/import-extratags.style b/settings/import-extratags.style index 184650f3..b90a07b1 100644 --- a/settings/import-extratags.style +++ b/settings/import-extratags.style @@ -125,6 +125,7 @@ "keys" : ["boundary"], "values" : { "place" : "skip", + "postal_code" : "main", "" : "main,with_name" } }, diff --git a/settings/import-full.style b/settings/import-full.style index 0c49f23d..c57c2c3a 100644 --- a/settings/import-full.style +++ b/settings/import-full.style @@ -125,6 +125,7 @@ "keys" : ["boundary"], "values" : { "place" : "skip", + "postal_code" : "main", "" : "main,with_name" } }, diff --git a/sql/functions/address_lookup.sql b/sql/functions/address_lookup.sql index 88b3a741..196fb434 100644 --- a/sql/functions/address_lookup.sql +++ b/sql/functions/address_lookup.sql @@ -180,6 +180,7 @@ BEGIN -- Return the record for the base entry. FOR location IN SELECT placex.place_id, osm_type, osm_id, name, + coalesce(extratags->'linked_place', extratags->'place') as place_type, class, type, admin_level, type not in ('postcode', 'postal_code') as isaddress, CASE WHEN rank_address = 0 THEN 100 @@ -198,7 +199,8 @@ BEGIN searchcountrycode := NULL; END IF; countrylocation := ROW(location.place_id, location.osm_type, location.osm_id, - location.name, location.class, location.type, NULL, + location.name, location.class, location.type, + location.place_type, location.admin_level, true, location.isaddress, location.rank_address, location.distance)::addressline; RETURN NEXT countrylocation; diff --git a/sql/functions/normalization.sql b/sql/functions/normalization.sql index 1a8bbd84..08087172 100644 --- a/sql/functions/normalization.sql +++ b/sql/functions/normalization.sql @@ -81,7 +81,8 @@ BEGIN lookup_word := upper(trim(postcode)); lookup_token := ' ' || make_standard_name(lookup_word); SELECT min(word_id) FROM word - WHERE word_token = lookup_token and class='place' and type='postcode' + WHERE word_token = lookup_token and word = lookup_word + and class='place' and type='postcode' INTO return_word_id; IF return_word_id IS NULL THEN return_word_id := nextval('seq_word'); diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql index 3ddb97c0..a935b75a 100644 --- a/sql/functions/placex_triggers.sql +++ b/sql/functions/placex_triggers.sql @@ -581,6 +581,15 @@ BEGIN RETURN NEW; END IF; + -- Postcodes are just here to compute the centroids. They are not searchable + -- unless they are a boundary=postal_code. + -- There was an error in the style so that boundary=postal_code used to be + -- imported as place=postcode. That's why relations are allowed to pass here. + -- This can go away in a couple of versions. + IF NEW.class = 'place' and NEW.type = 'postcode' and NEW.osm_type != 'R' THEN + RETURN NEW; + END IF; + -- Speed up searches - just use the centroid of the feature -- cheaper but less acurate NEW.centroid := ST_PointOnSurface(NEW.geometry); @@ -694,7 +703,7 @@ BEGIN -- --------------------------------------------------------------------------- -- For low level elements we inherit from our parent road - IF (NEW.rank_search > 27 OR (NEW.type = 'postcode' AND NEW.rank_search = 25)) THEN + IF NEW.rank_search > 27 THEN --DEBUG: RAISE WARNING 'finding street for % %', NEW.osm_type, NEW.osm_id; NEW.parent_place_id := null; @@ -757,11 +766,6 @@ BEGIN -- Performance, it would be more acurate to do all the rest of the import -- process but it takes too long -- Just be happy with inheriting from parent road only - IF NEW.rank_search <= 25 and NEW.rank_address > 0 THEN - result := add_location(NEW.place_id, NEW.country_code, NEW.partition, name_vector, NEW.rank_search, NEW.rank_address, upper(trim(NEW.address->'postcode')), NEW.geometry); - --DEBUG: RAISE WARNING 'Place added to location table'; - END IF; - result := insertSearchName(NEW.partition, NEW.place_id, name_vector, NEW.rank_search, NEW.rank_address, NEW.geometry); diff --git a/sql/functions/ranking.sql b/sql/functions/ranking.sql index 98e70a42..0c8f4c49 100644 --- a/sql/functions/ranking.sql +++ b/sql/functions/ranking.sql @@ -145,10 +145,6 @@ BEGIN THEN SELECT * INTO search_rank, address_rank FROM get_postcode_rank(country, postcode); - - IF NOT extended_type = 'A' THEN - address_rank := 0; - END IF; ELSEIF extended_type = 'N' AND place_class = 'highway' THEN search_rank = 30; address_rank = 0; diff --git a/test/Makefile b/test/Makefile index 0355a170..b65e465d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,14 @@ all: bdd php +no-test-db: bdd-no-test-db php bdd: cd bdd && behave -DREMOVE_TEMPLATE=1 +bdd-no-test-db: + cd bdd && behave -DREMOVE_TEMPLATE=1 db osm2pgsql + php: cd php && phpunit ./ -.PHONY: bdd php + +.PHONY: bdd php no-test-db diff --git a/test/bdd/api/search/queries.feature b/test/bdd/api/search/queries.feature index b521c171..e5040f1e 100644 --- a/test/bdd/api/search/queries.feature +++ b/test/bdd/api/search/queries.feature @@ -182,3 +182,11 @@ Feature: Search queries Then results contain | class | type | | highway | residential | + + + # github #1949 + Scenario: Addressdetails always return the place type + When sending json search query "Rotherbaum" with address + Then result addresses contain + | ID | suburb | + | 0 | Rotherbaum | diff --git a/test/bdd/api/search/structured.feature b/test/bdd/api/search/structured.feature index ec7eb1be..e94cd4cc 100644 --- a/test/bdd/api/search/structured.feature +++ b/test/bdd/api/search/structured.feature @@ -18,7 +18,7 @@ Feature: Structured search queries | 22547 | Then results contain | type | - | postcode | + | ^post(al_)?code | And result addresses contain | postcode | | 22547 | diff --git a/test/bdd/db/import/addressing.feature b/test/bdd/db/import/addressing.feature index 2fdd2812..0d4798e8 100644 --- a/test/bdd/db/import/addressing.feature +++ b/test/bdd/db/import/addressing.feature @@ -139,8 +139,8 @@ Feature: Address computation | R1 | boundary | administrative | 6 | 112 | :b0 | | R34 | boundary | administrative | 8 | 112 DE | :b1:E | And the places - | osm | class | type | addr+postcode | geometry | - | R4 | place | postcode | 112 DE 34 | :b2:N | + | osm | class | type | addr+postcode | geometry | + | R4 | boundary | postal_code | 112 DE 34 | :b2:N | And the named places | osm | class | type | geometry | | W93 | highway | residential | :w2N | diff --git a/test/bdd/db/import/placex.feature b/test/bdd/db/import/placex.feature index 2b7c8cd8..1a62638d 100644 --- a/test/bdd/db/import/placex.feature +++ b/test/bdd/db/import/placex.feature @@ -69,10 +69,10 @@ Feature: Import into placex | N3 | place | postcode | Y45 | country:gb | When importing Then placex contains - | object | postcode | country_code | rank_search | rank_address | - | N1 | E45 2CD | gb | 25 | 0 | - | N2 | E45 2 | gb | 23 | 0 | - | N3 | Y45 | gb | 21 | 0 | + | object | addr+postcode | country_code | rank_search | rank_address | + | N1 | E45 2CD | gb | 25 | 5 | + | N2 | E45 2 | gb | 23 | 5 | + | N3 | Y45 | gb | 21 | 5 | Scenario: wrongly formatted GB postcodes are down-ranked Given the places @@ -82,8 +82,8 @@ Feature: Import into placex When importing Then placex contains | object | country_code | rank_search | rank_address | - | N1 | gb | 30 | 0 | - | N2 | gb | 30 | 0 | + | N1 | gb | 30 | 30 | + | N2 | gb | 30 | 30 | Scenario: search and address rank for DE postcodes correctly assigned Given the places @@ -95,10 +95,10 @@ Feature: Import into placex When importing Then placex contains | object | country_code | rank_search | rank_address | - | N1 | de | 21 | 0 | - | N2 | de | 30 | 0 | - | N3 | de | 30 | 0 | - | N4 | de | 30 | 0 | + | N1 | de | 21 | 11 | + | N2 | de | 30 | 30 | + | N3 | de | 30 | 30 | + | N4 | de | 30 | 30 | Scenario: search and address rank for other postcodes are correctly assigned Given the places @@ -115,15 +115,15 @@ Feature: Import into placex When importing Then placex contains | object | country_code | rank_search | rank_address | - | N1 | ca | 21 | 0 | - | N2 | ca | 21 | 0 | - | N3 | ca | 21 | 0 | - | N4 | ca | 21 | 0 | - | N5 | ca | 21 | 0 | - | N6 | ca | 21 | 0 | - | N7 | ca | 25 | 0 | - | N8 | ca | 25 | 0 | - | N9 | ca | 25 | 0 | + | N1 | ca | 21 | 11 | + | N2 | ca | 21 | 11 | + | N3 | ca | 21 | 11 | + | N4 | ca | 21 | 11 | + | N5 | ca | 21 | 11 | + | N6 | ca | 21 | 11 | + | N7 | ca | 25 | 11 | + | N8 | ca | 25 | 11 | + | N9 | ca | 25 | 11 | Scenario: search and address ranks for boundaries are correctly assigned Given the named places diff --git a/test/bdd/db/import/postcodes.feature b/test/bdd/db/import/postcodes.feature index 863a9b3a..3d1dc489 100644 --- a/test/bdd/db/import/postcodes.feature +++ b/test/bdd/db/import/postcodes.feature @@ -137,3 +137,22 @@ Feature: Import of postcodes And word contains | word | class | type | | 01982 | place | postcode | + + Scenario: Different postcodes with the same normalization can both be found + Given the places + | osm | class | type | addr+postcode | addr+housenumber | geometry | + | N34 | place | house | EH4 7EA | 111 | country:gb | + | N35 | place | house | E4 7EA | 111 | country:gb | + When importing + Then location_postcode contains exactly + | country | postcode | geometry | + | gb | EH4 7EA | country:gb | + | gb | E4 7EA | country:gb | + When searching for "EH4 7EA" + Then results contain + | type | placename | + | postcode | EH4 7EA | + When searching for "E4 7EA" + Then results contain + | type | placename | + | postcode | E4 7EA | diff --git a/vagrant/install-on-travis-ci.sh b/vagrant/Install-on-Travis-CI.sh similarity index 57% rename from vagrant/install-on-travis-ci.sh rename to vagrant/Install-on-Travis-CI.sh index 3b8ed190..9c1fe367 100755 --- a/vagrant/install-on-travis-ci.sh +++ b/vagrant/Install-on-Travis-CI.sh @@ -1,26 +1,30 @@ #!/bin/bash # This script runs in a travis-ci.org virtual machine -# https://docs.travis-ci.com/user/reference/xenial/ -# Ubuntu 16 (xenial) +# https://docs.travis-ci.com/user/reference/focal/ +# Ubuntu 20 (focal) # user 'travis' # $TRAVIS_BUILD_DIR is /home/travis/build/openstreetmap/Nominatim/, for others see # https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables -# Postgres 9.6 installed and started. role 'travis' already superuser -# Python 3.6 +# Postgres 12 installed and started. role 'travis' already superuser +# Python 3.8 # Travis has a 4 MB, 10000 line output limit, so where possible we run script --quiet sudo apt-get update -qq -sudo apt-get install -y -qq libboost-dev libboost-system-dev \ - libboost-filesystem-dev libexpat1-dev zlib1g-dev\ + +sudo apt-get install -y -qq build-essential cmake g++ libboost-dev libboost-system-dev \ + libboost-filesystem-dev libexpat1-dev zlib1g-dev \ libbz2-dev libpq-dev libproj-dev \ - postgresql-server-dev-9.6 postgresql-9.6-postgis-2.4 postgresql-contrib-9.6 \ - apache2 php php-pgsql php-intl + postgresql-server-dev-12 postgresql-12-postgis-3 \ + postgresql-contrib postgresql-12-postgis-3-scripts \ + php php-pgsql \ + php-intl python3-setuptools python3-dev python3-pip \ + python3-psycopg2 python3-tidylib git -sudo apt-get install -y -qq python3-dev python3-pip php-cgi +sudo apt-get install -y -qq php-cgi -pip3 install --quiet behave nose pytidylib psycopg2-binary osmium +pip3 install --quiet behave nose osmium # https://github.com/squizlabs/PHP_CodeSniffer composer global require "squizlabs/php_codesniffer=*" @@ -35,22 +39,6 @@ sudo -u postgres createuser -S www-data chmod a+x $HOME chmod a+x $TRAVIS_BUILD_DIR - -sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF > /dev/null - - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - - - Alias /nominatim $TRAVIS_BUILD_DIR/build/website -EOFAPACHECONF - - -sudo a2enconf nominatim -sudo service apache2 restart - wget -O $TRAVIS_BUILD_DIR/data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz mkdir build @@ -61,7 +49,6 @@ make tee settings/local.php << EOF #DOCS: - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - - -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 # ==================== @@ -143,12 +113,53 @@ 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 + cd $USERHOME mkdir build cd build cmake $USERHOME/Nominatim make + +# Nominatim is now ready to use. You can continue with +# [importing a database from OSM data](../admin/Import.md). If you want to set up +# a webserver first, continue reading. +# +# Setting up a webserver +# ====================== +# +# Option 1: Using Apache +# ---------------------- +# +if [ "x$2" == "xinstall-apache" ]; then #DOCS: +# +# Apache has a PHP module that can be used to serve Nominatim. To install them +# run: + + sudo apt install -y apache2 libapache2-mod-php + +# 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 + + Options FollowSymLinks MultiViews + AddType text/html .php + DirectoryIndex search.php + Require all granted + + +Alias /nominatim $USERHOME/build/website +EOFAPACHECONF +#DOCS:``` + +# +# Then enable the configuration and restart apache +# + + sudo a2enconf nominatim + sudo systemctl restart apache2 + # You need to create a minimal configuration file that tells nominatim # where it is located on the webserver: @@ -159,6 +170,88 @@ tee settings/local.php << EOF EOF #DOCS:``` +# The Nominatim API is now available at `http://localhost/nominatim/`. + +fi #DOCS: + +# +# Option 2: Using nginx +# --------------------- +# +if [ "x$2" == "xinstall-nginx" ]; then #DOCS: + +# Nginx has no native support for php scripts. You need to set up php-fpm for +# this purpose. First install nginx and php-fpm: + + sudo apt install -y nginx php-fpm + +# You need to configure php-fpm to listen on a Unix socket. + +#DOCS:```sh +sudo tee /etc/php/7.2/fpm/pool.d/www.conf << EOF_PHP_FPM_CONF +[www] +; Replace the tcp listener and add the unix socket +listen = /var/run/php7.2-fpm.sock + +; Ensure that the daemon runs as the correct user +listen.owner = www-data +listen.group = www-data +listen.mode = 0666 + +; Unix user of FPM processes +user = www-data +group = www-data + +; Choose process manager type (static, dynamic, ondemand) +pm = ondemand +pm.max_children = 5 +EOF_PHP_FPM_CONF +#DOCS:``` + +# Then create a Nginx configuration to forward http requests to that socket. + +#DOCS:```sh +sudo tee /etc/nginx/sites-available/default << EOF_NGINX_CONF +server { + listen 80 default_server; + listen [::]:80 default_server; + + root $USERHOME/build/website; + index search.php index.html; + location / { + try_files \$uri \$uri/ @php; + } + + location @php { + fastcgi_param SCRIPT_FILENAME "\$document_root\$uri.php"; + fastcgi_param PATH_TRANSLATED "\$document_root\$uri.php"; + fastcgi_param QUERY_STRING \$args; + fastcgi_pass unix:/var/run/php7.2-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f \$document_root\$fastcgi_script_name) { + return 404; + } + fastcgi_pass unix:/var/run/php7.2-fpm.sock; + fastcgi_index search.php; + include fastcgi.conf; + } +} +EOF_NGINX_CONF +#DOCS:``` + +# +# Enable the configuration and restart Nginx +# + + sudo systemctl restart php7.2-fpm nginx + +# The Nominatim API is now available at `http://localhost/`. + + -# Nominatim is now ready to use. Continue with -# [importing a database from OSM data](../admin/Import.md). +fi #DOCS: diff --git a/vagrant/Install-on-Ubuntu-20.sh b/vagrant/Install-on-Ubuntu-20.sh index a7029be2..b182ecfd 100644 --- a/vagrant/Install-on-Ubuntu-20.sh +++ b/vagrant/Install-on-Ubuntu-20.sh @@ -22,18 +22,18 @@ export DEBIAN_FRONTEND=noninteractive #DOCS: -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" \ #DOCS: --allow-downgrades --allow-remove-essential --allow-change-held-packages \ #DOCS: -fuy install grub-pc #DOCS: - sudo apt-get update -qq + sudo apt 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 \ - libbz2-dev libpq-dev libproj-dev \ - postgresql-server-dev-12 postgresql-12-postgis-3 \ - postgresql-contrib postgresql-12-postgis-3-scripts \ - apache2 php php-pgsql libapache2-mod-php \ - php-intl python3-setuptools python3-dev python3-pip \ - python3-psycopg2 python3-tidylib git + sudo apt install -y php-cgi + sudo apt install -y build-essential cmake g++ libboost-dev libboost-system-dev \ + libboost-filesystem-dev libexpat1-dev zlib1g-dev \ + libbz2-dev libpq-dev libproj-dev \ + postgresql-server-dev-12 postgresql-12-postgis-3 \ + postgresql-contrib postgresql-12-postgis-3-scripts \ + php php-pgsql php-intl \ + python3-psycopg2 git # # System Configuration @@ -88,35 +88,6 @@ export DEBIAN_FRONTEND=noninteractive #DOCS: 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 - #DOCS: - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - - -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 # ==================== @@ -144,12 +115,52 @@ 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 + cd $USERHOME mkdir build cd build cmake $USERHOME/Nominatim make +# Nominatim is now ready to use. You can continue with +# [importing a database from OSM data](../admin/Import.md). If you want to set up +# a webserver first, continue reading. +# +# Setting up a webserver +# ====================== +# +# Option 1: Using Apache +# ---------------------- +# +if [ "x$2" == "xinstall-apache" ]; then #DOCS: +# +# Apache has a PHP module that can be used to serve Nominatim. To install them +# run: + + sudo apt install -y apache2 libapache2-mod-php + +# 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 + + Options FollowSymLinks MultiViews + AddType text/html .php + DirectoryIndex search.php + Require all granted + + +Alias /nominatim $USERHOME/build/website +EOFAPACHECONF +#DOCS:``` + +# +# Then enable the configuration and restart apache +# + + sudo a2enconf nominatim + sudo systemctl restart apache2 + # You need to create a minimal configuration file that tells nominatim # where it is located on the webserver: @@ -160,6 +171,88 @@ tee settings/local.php << EOF EOF #DOCS:``` +# The Nominatim API is now available at `http://localhost/nominatim/`. + +fi #DOCS: + +# +# Option 2: Using nginx +# --------------------- +# +if [ "x$2" == "xinstall-nginx" ]; then #DOCS: + +# Nginx has no native support for php scripts. You need to set up php-fpm for +# this purpose. First install nginx and php-fpm: + + sudo apt install -y nginx php-fpm + +# You need to configure php-fpm to listen on a Unix socket. + +#DOCS:```sh +sudo tee /etc/php/7.4/fpm/pool.d/www.conf << EOF_PHP_FPM_CONF +[www] +; Replace the tcp listener and add the unix socket +listen = /var/run/php7.4-fpm.sock + +; Ensure that the daemon runs as the correct user +listen.owner = www-data +listen.group = www-data +listen.mode = 0666 + +; Unix user of FPM processes +user = www-data +group = www-data + +; Choose process manager type (static, dynamic, ondemand) +pm = ondemand +pm.max_children = 5 +EOF_PHP_FPM_CONF +#DOCS:``` + +# Then create a Nginx configuration to forward http requests to that socket. + +#DOCS:```sh +sudo tee /etc/nginx/sites-available/default << EOF_NGINX_CONF +server { + listen 80 default_server; + listen [::]:80 default_server; + + root $USERHOME/build/website; + index search.php index.html; + location / { + try_files \$uri \$uri/ @php; + } + + location @php { + fastcgi_param SCRIPT_FILENAME "\$document_root\$uri.php"; + fastcgi_param PATH_TRANSLATED "\$document_root\$uri.php"; + fastcgi_param QUERY_STRING \$args; + fastcgi_pass unix:/var/run/php7.4-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f \$document_root\$fastcgi_script_name) { + return 404; + } + fastcgi_pass unix:/var/run/php7.4-fpm.sock; + fastcgi_index search.php; + include fastcgi.conf; + } +} +EOF_NGINX_CONF +#DOCS:``` + +# +# Enable the configuration and restart Nginx +# + + sudo systemctl restart php7.4-fpm nginx + +# The Nominatim API is now available at `http://localhost/`. + + -# Nominatim is now ready to use. Continue with -# [importing a database from OSM data](../admin/Import.md). +fi #DOCS: