mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
Compare commits
1298 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9426fc2fee | ||
|
|
9f4596156d | ||
|
|
3a1714e7e2 | ||
|
|
f845605cf7 | ||
|
|
51c3a00d70 | ||
|
|
b51efd876f | ||
|
|
405279dae3 | ||
|
|
3dd223dfa3 | ||
|
|
7e6125ada5 | ||
|
|
93b72e4e9b | ||
|
|
3bf57e6d2a | ||
|
|
e9ce5714a7 | ||
|
|
ff1a49a0f8 | ||
|
|
ec2873fbf6 | ||
|
|
5dee3cf7f7 | ||
|
|
341cb55690 | ||
|
|
055b5a46ba | ||
|
|
6e8d4c0dac | ||
|
|
baf684195b | ||
|
|
b0832669a3 | ||
|
|
243394b1c2 | ||
|
|
0f14851c98 | ||
|
|
b15a687564 | ||
|
|
0289d125da | ||
|
|
76ee6959c1 | ||
|
|
74c74dde07 | ||
|
|
f7e4bfa980 | ||
|
|
4a6e9ba187 | ||
|
|
10d99893f9 | ||
|
|
b7a5a8b5f7 | ||
|
|
6ed495bfc2 | ||
|
|
cd7c841f5b | ||
|
|
8f9c10c762 | ||
|
|
492186716f | ||
|
|
07fda48cee | ||
|
|
4b31be5203 | ||
|
|
5d69c7ade1 | ||
|
|
96b0699621 | ||
|
|
6cbef84cad | ||
|
|
55fcc44c8c | ||
|
|
16a66b5326 | ||
|
|
3590e76a1c | ||
|
|
0ec3fdd3ba | ||
|
|
c0f0b66509 | ||
|
|
0f9df32d11 | ||
|
|
a370c8be4b | ||
|
|
d6e0bc698e | ||
|
|
8d8b1d4307 | ||
|
|
8dbfdd59b0 | ||
|
|
cd03882536 | ||
|
|
0b154a2a1a | ||
|
|
e82de99e5a | ||
|
|
27b379c1e3 | ||
|
|
f9517e9143 | ||
|
|
e05dee6df5 | ||
|
|
3fad492c6f | ||
|
|
b7d6ae93e3 | ||
|
|
21b1b75b08 | ||
|
|
bbe0353b23 | ||
|
|
51e2654cd2 | ||
|
|
09b2510219 | ||
|
|
57ce75eb67 | ||
|
|
cde9389e75 | ||
|
|
2c19bd5ea3 | ||
|
|
ff34198569 | ||
|
|
919469c8fe | ||
|
|
1ce8b530cd | ||
|
|
2fb6018078 | ||
|
|
6d56cbb3e8 | ||
|
|
1a93319093 | ||
|
|
28b4fb12b6 | ||
|
|
5dabc0aca8 | ||
|
|
4f1bdde32e | ||
|
|
a08ca5b1b5 | ||
|
|
87d5883ddb | ||
|
|
d5acade4db | ||
|
|
9d1c23e4f5 | ||
|
|
17cb59efbd | ||
|
|
118befd7d7 | ||
|
|
0d9fe6e49c | ||
|
|
ebae3553e0 | ||
|
|
d3ff831b8a | ||
|
|
4d7c5ec089 | ||
|
|
81a6b746b8 | ||
|
|
f356a75a24 | ||
|
|
7212fa8630 | ||
|
|
6cabc44841 | ||
|
|
b108bd1c1e | ||
|
|
077a8c1f95 | ||
|
|
7a874d5b97 | ||
|
|
9086a794a1 | ||
|
|
6dd2b9c2ec | ||
|
|
3fbe4511f9 | ||
|
|
3933fc3ad3 | ||
|
|
00b05e2394 | ||
|
|
d5e8c5e975 | ||
|
|
478dfb0639 | ||
|
|
f498e40208 | ||
|
|
182f5f5d7b | ||
|
|
e5719de657 | ||
|
|
8486a83cf5 | ||
|
|
ccfad57fca | ||
|
|
64128b699a | ||
|
|
4080fbb95c | ||
|
|
14ec83c886 | ||
|
|
122c4618b9 | ||
|
|
2af82975cd | ||
|
|
35f4695b67 | ||
|
|
3c9e09545e | ||
|
|
764a41b973 | ||
|
|
9d103503f7 | ||
|
|
09f4d767e4 | ||
|
|
dd301cf5ac | ||
|
|
eacabb0e96 | ||
|
|
6cda021d9b | ||
|
|
d2bd6aa78d | ||
|
|
6b306f30b6 | ||
|
|
c48fd18344 | ||
|
|
8ea7e04363 | ||
|
|
32c2d2b248 | ||
|
|
111cca8c9a | ||
|
|
7ae9c3a9f0 | ||
|
|
bf4320a7d6 | ||
|
|
3a0a4b9175 | ||
|
|
4faefe156c | ||
|
|
86273f5e2a | ||
|
|
b4f64aa770 | ||
|
|
976c5e9121 | ||
|
|
db663dd92f | ||
|
|
90a5d23016 | ||
|
|
99e35d256a | ||
|
|
e14e7c6235 | ||
|
|
b46adbad22 | ||
|
|
afabbeb546 | ||
|
|
d14a3df10f | ||
|
|
9feb84e426 | ||
|
|
c7f40e3cee | ||
|
|
dd03aeb966 | ||
|
|
15b5906790 | ||
|
|
3ee8d9fa75 | ||
|
|
57db5819ef | ||
|
|
3c186f8030 | ||
|
|
db5e78c879 | ||
|
|
c7fd0a7af4 | ||
|
|
32683f73c7 | ||
|
|
7222235579 | ||
|
|
f6e894a53a | ||
|
|
b93ec2522e | ||
|
|
af7226393a | ||
|
|
e520613362 | ||
|
|
204fe20b4b | ||
|
|
a1f0fc1a10 | ||
|
|
68c3862270 | ||
|
|
5b7483ada5 | ||
|
|
72b01148d2 | ||
|
|
971df231b0 | ||
|
|
4b32cbe518 | ||
|
|
f08078ccca | ||
|
|
389138abfe | ||
|
|
a0ae4945cd | ||
|
|
b169e4c88c | ||
|
|
a60c34bded | ||
|
|
153dbb71b8 | ||
|
|
101a1f895d | ||
|
|
bd27310c68 | ||
|
|
42ecd535b3 | ||
|
|
c9838a02ce | ||
|
|
7ebcf602ac | ||
|
|
8eb85f1340 | ||
|
|
2a8e3741fa | ||
|
|
684378722c | ||
|
|
286a686f88 | ||
|
|
7360e6c5df | ||
|
|
fbe7be760b | ||
|
|
a3ce89aeff | ||
|
|
6a7e0d652b | ||
|
|
7cc4c53adb | ||
|
|
24b13a7a87 | ||
|
|
b6c2dbf69c | ||
|
|
0e0e9a6809 | ||
|
|
ed60154552 | ||
|
|
85589cf7dc | ||
|
|
99dcd10d3f | ||
|
|
745ae02f47 | ||
|
|
b6bd11f292 | ||
|
|
c60a0784ea | ||
|
|
3cb6f3e460 | ||
|
|
de37dc9300 | ||
|
|
8ffd7d9243 | ||
|
|
298ed11261 | ||
|
|
b9517c99ae | ||
|
|
db3ced17bb | ||
|
|
248b4cddab | ||
|
|
d81e152804 | ||
|
|
0cbf98c020 | ||
|
|
195f9f5ef3 | ||
|
|
a759c5b75b | ||
|
|
7dfe645b5f | ||
|
|
ca3283cbaa | ||
|
|
861e67dfe8 | ||
|
|
82ef02cd1a | ||
|
|
948217d5e9 | ||
|
|
6cc06828db | ||
|
|
0b2abfb115 | ||
|
|
b2f8fb6201 | ||
|
|
e2329c03fe | ||
|
|
9bca670b4e | ||
|
|
cb06d1f4ca | ||
|
|
36447c488a | ||
|
|
69092030cd | ||
|
|
109aa9c428 | ||
|
|
1d97816c53 | ||
|
|
7591c4fb42 | ||
|
|
60cbeb165e | ||
|
|
bddfc109f8 | ||
|
|
b05c379b39 | ||
|
|
7ba5283fe8 | ||
|
|
98fe5af07d | ||
|
|
59cb1d6c27 | ||
|
|
0ad1b28497 | ||
|
|
5f63d4ca1f | ||
|
|
90aaab77fc | ||
|
|
7158433cd3 | ||
|
|
e629a175ed | ||
|
|
45ea73913f | ||
|
|
01e0fd7e13 | ||
|
|
4cb6dc01f3 | ||
|
|
8f0885f6cb | ||
|
|
beb0fa0727 | ||
|
|
436cb9229b | ||
|
|
d78f0ba804 | ||
|
|
5b46fcad8e | ||
|
|
94fa7162be | ||
|
|
e6c2842b66 | ||
|
|
e6d9485c4a | ||
|
|
30cd2f2280 | ||
|
|
2c909c1f0c | ||
|
|
063a4cb403 | ||
|
|
42ec67f63c | ||
|
|
8c02786820 | ||
|
|
c26f323bf5 | ||
|
|
041ae67fd9 | ||
|
|
bfa6580ad5 | ||
|
|
52b76d1d01 | ||
|
|
a3767f9142 | ||
|
|
f62c784102 | ||
|
|
ffc221a87f | ||
|
|
8cf54a1317 | ||
|
|
77e287f669 | ||
|
|
5d95a72758 | ||
|
|
3475e1dfd6 | ||
|
|
504922ffbe | ||
|
|
c77877a934 | ||
|
|
27977411e9 | ||
|
|
b79c79fa73 | ||
|
|
cd0001b55a | ||
|
|
340e7f7210 | ||
|
|
f9c43137c9 | ||
|
|
171ed36e36 | ||
|
|
c6c907d451 | ||
|
|
19ab038724 | ||
|
|
1c26fd489d | ||
|
|
e8cfba1b10 | ||
|
|
496a3d29db | ||
|
|
438ed431dd | ||
|
|
f1f0032758 | ||
|
|
eb3b789855 | ||
|
|
c077050855 | ||
|
|
d9998bfab3 | ||
|
|
7cf9d459d6 | ||
|
|
de724aa576 | ||
|
|
8e53f63036 | ||
|
|
565356613a | ||
|
|
eda0900c8e | ||
|
|
3dd67083b2 | ||
|
|
2f73bb3643 | ||
|
|
9348fc5e15 | ||
|
|
97710ee9d1 | ||
|
|
9619cb3fe5 | ||
|
|
1c1e951826 | ||
|
|
88c57b4dc8 | ||
|
|
ba13cfd9ff | ||
|
|
1ff8751caa | ||
|
|
98dbc84836 | ||
|
|
0847964a27 | ||
|
|
bc09d7aedb | ||
|
|
04690ad8c4 | ||
|
|
ec636111ba | ||
|
|
e467b956ff | ||
|
|
ff5a237200 | ||
|
|
d6bcb7c8b7 | ||
|
|
57f5e6d898 | ||
|
|
612fd50612 | ||
|
|
a74e736283 | ||
|
|
86cd5ddd65 | ||
|
|
812de0545d | ||
|
|
3bed5516da | ||
|
|
0495dbe756 | ||
|
|
5d656891ba | ||
|
|
74122dc965 | ||
|
|
ee18a511c6 | ||
|
|
da20881096 | ||
|
|
aaabb46f20 | ||
|
|
49142eb6e5 | ||
|
|
73cbb6eb9a | ||
|
|
1f29475fa5 | ||
|
|
d586b95ff1 | ||
|
|
25557e5f14 | ||
|
|
197870e67a | ||
|
|
b8e39d2dde | ||
|
|
5dfa76a610 | ||
|
|
58c471c627 | ||
|
|
213bf7d19d | ||
|
|
12ae8a4ed3 | ||
|
|
8a93f8ed94 | ||
|
|
2712c5f90e | ||
|
|
72587b08fa | ||
|
|
faa85ded50 | ||
|
|
14e5bc7a17 | ||
|
|
f727620859 | ||
|
|
843d3a137c | ||
|
|
e4691005e2 | ||
|
|
4aba70caee | ||
|
|
5e989b9296 | ||
|
|
cba2d252c8 | ||
|
|
2ecec19df0 | ||
|
|
4ca7197826 | ||
|
|
a8ec250993 | ||
|
|
f3e0e401fd | ||
|
|
d60f89867b | ||
|
|
b133f2bc4c | ||
|
|
301fd7f7e8 | ||
|
|
45148c7078 | ||
|
|
3c75194448 | ||
|
|
f218e20522 | ||
|
|
33b038ce6f | ||
|
|
f62c65e9d9 | ||
|
|
867baab3d1 | ||
|
|
63ad0cb498 | ||
|
|
433017b990 | ||
|
|
d97aed8741 | ||
|
|
06d89e1d47 | ||
|
|
8676e45d88 | ||
|
|
992d3faac8 | ||
|
|
0947b61808 | ||
|
|
d43f30903c | ||
|
|
15a1666f8a | ||
|
|
25bdd7c6d9 | ||
|
|
ac116980ac | ||
|
|
b5480f6e36 | ||
|
|
17a8cc5e29 | ||
|
|
aeeee0d5da | ||
|
|
de03a0f924 | ||
|
|
5528918d5d | ||
|
|
9e0d5cb669 | ||
|
|
11622b2863 | ||
|
|
9610664fc5 | ||
|
|
eed2e3f2a8 | ||
|
|
1b62162e08 | ||
|
|
5cf573c340 | ||
|
|
76cd8bf258 | ||
|
|
31ba7e7cf0 | ||
|
|
a338ba695b | ||
|
|
9f6e2de4ed | ||
|
|
1b3acc4f8f | ||
|
|
56cf3b362e | ||
|
|
b59d01fe85 | ||
|
|
65d8770b28 | ||
|
|
38582c3e52 | ||
|
|
5f6fe6cab7 | ||
|
|
34f8e6ddf7 | ||
|
|
603367dced | ||
|
|
eaee87e73d | ||
|
|
ea844db847 | ||
|
|
3ca8cc0344 | ||
|
|
f67c06f128 | ||
|
|
7889509856 | ||
|
|
67c995aef6 | ||
|
|
e20defeebd | ||
|
|
cca646a19e | ||
|
|
ddc2b4b806 | ||
|
|
0334915067 | ||
|
|
987d60ccda | ||
|
|
7d520bf448 | ||
|
|
dc53288e6b | ||
|
|
db02673b60 | ||
|
|
cf9b248f29 | ||
|
|
df12954312 | ||
|
|
a9357b4dce | ||
|
|
63544db8f9 | ||
|
|
7295cad715 | ||
|
|
ff85da0a31 | ||
|
|
75b2d7ca99 | ||
|
|
3c9eeb11fa | ||
|
|
63bacaee2e | ||
|
|
5016eace34 | ||
|
|
2e5c8b5cd3 | ||
|
|
bf0f81adcb | ||
|
|
2db751700e | ||
|
|
62bee4ed37 | ||
|
|
1f07d63dc5 | ||
|
|
cc1af99dbd | ||
|
|
c5d98effc0 | ||
|
|
b68b2ff6b8 | ||
|
|
57f0d55c2e | ||
|
|
3cf763475f | ||
|
|
0f87da017f | ||
|
|
22800d7d59 | ||
|
|
f21853ea9d | ||
|
|
1e76d668bd | ||
|
|
b4b50eef15 | ||
|
|
a9ad390b9e | ||
|
|
2e9e961fff | ||
|
|
13180989d9 | ||
|
|
a4f1e40b72 | ||
|
|
04d485c550 | ||
|
|
a92bd1e2db | ||
|
|
f89e71a861 | ||
|
|
dcc075b34b | ||
|
|
49083c2597 | ||
|
|
29785ba166 | ||
|
|
ffb2c93ba3 | ||
|
|
30a6b6bdac | ||
|
|
cc345f531a | ||
|
|
9ede048769 | ||
|
|
d23bf6e659 | ||
|
|
6b60f0ab03 | ||
|
|
aa9923bf07 | ||
|
|
9160cce6d8 | ||
|
|
885dc0a8e1 | ||
|
|
7324431b12 | ||
|
|
021f2bef4c | ||
|
|
6260fef2e8 | ||
|
|
c7472662a6 | ||
|
|
fecfe62fc6 | ||
|
|
21b0430e46 | ||
|
|
66595c2d2b | ||
|
|
4ac29fb525 | ||
|
|
04d50a271d | ||
|
|
cbbda1ddf0 | ||
|
|
928c6245c9 | ||
|
|
ac9be161f6 | ||
|
|
33378dcf6e | ||
|
|
e31a1f7ef1 | ||
|
|
fa574ae9fd | ||
|
|
b2ebf4b4b7 | ||
|
|
0f5615b618 | ||
|
|
f050f898bc | ||
|
|
ce1c3bab6d | ||
|
|
5cdabc5173 | ||
|
|
42775f959b | ||
|
|
7f55dcef3a | ||
|
|
ba8accf4bb | ||
|
|
e62db51b06 | ||
|
|
b81894d3d5 | ||
|
|
d86cf6801f | ||
|
|
c0d21d0bd3 | ||
|
|
b838f66dd7 | ||
|
|
db9cc270b3 | ||
|
|
4147e04319 | ||
|
|
a888f6ff93 | ||
|
|
bd04c49bc1 | ||
|
|
5872b81232 | ||
|
|
abd20d3ca6 | ||
|
|
95f83b90d2 | ||
|
|
7a16909219 | ||
|
|
ee4684e6a9 | ||
|
|
a2b1a1eb33 | ||
|
|
7bc0fc9611 | ||
|
|
e0e18e2b6f | ||
|
|
788ba6d985 | ||
|
|
b012e15245 | ||
|
|
ba31456278 | ||
|
|
b661c66c00 | ||
|
|
f0372736aa | ||
|
|
e286d3f23d | ||
|
|
6c8a7b0a1a | ||
|
|
3107dc208a | ||
|
|
bf4d75458c | ||
|
|
3604d0d913 | ||
|
|
dd06638dec | ||
|
|
73a0ec22a3 | ||
|
|
b0ef84caae | ||
|
|
64899ef54b | ||
|
|
1064a9264e | ||
|
|
acfa7bec9c | ||
|
|
62b94e838b | ||
|
|
5236e7a03e | ||
|
|
7e9412a044 | ||
|
|
e47c19beb9 | ||
|
|
2fe3c654fc | ||
|
|
5ec48c66cb | ||
|
|
4e7ec92d6f | ||
|
|
e115de47fc | ||
|
|
bb5ffd3904 | ||
|
|
887ae7fcab | ||
|
|
abaaf942cb | ||
|
|
ff47f6f65d | ||
|
|
ca680fc9fc | ||
|
|
b04463bb2d | ||
|
|
c66f701232 | ||
|
|
3b23144ae6 | ||
|
|
f7a9462337 | ||
|
|
17f24d0061 | ||
|
|
eb8bce22b8 | ||
|
|
6a31691121 | ||
|
|
25c4bf6ed4 | ||
|
|
ec5743bcc0 | ||
|
|
7cd330ee55 | ||
|
|
7d2b6879c8 | ||
|
|
a40684162a | ||
|
|
cd997ff058 | ||
|
|
5391bb6cf7 | ||
|
|
6b8ce1ee74 | ||
|
|
a37d46ec25 | ||
|
|
b5c8237118 | ||
|
|
eeffe2caf4 | ||
|
|
c5c7a6a453 | ||
|
|
b969392f40 | ||
|
|
40bc1752c2 | ||
|
|
851c3779b5 | ||
|
|
2a717da850 | ||
|
|
f8694da3c9 | ||
|
|
eeb2b1f998 | ||
|
|
1db8f7e353 | ||
|
|
6625e93be6 | ||
|
|
56053988bf | ||
|
|
d9325dc11a | ||
|
|
d3ca9dd3f7 | ||
|
|
e552f6bce5 | ||
|
|
cf23e10382 | ||
|
|
c84e7e72f1 | ||
|
|
f2ff351da4 | ||
|
|
c5c242d193 | ||
|
|
72193a1c23 | ||
|
|
248d6b413a | ||
|
|
d04e87fb80 | ||
|
|
cc61b74cde | ||
|
|
915d362b11 | ||
|
|
f8a5f2964f | ||
|
|
a8dfbcef44 | ||
|
|
caea14d035 | ||
|
|
c5fc12e04b | ||
|
|
731c620e31 | ||
|
|
0dad470eb9 | ||
|
|
6947ab3a65 | ||
|
|
b219374d36 | ||
|
|
576ee5aaab | ||
|
|
4c9cfe2532 | ||
|
|
7fb62ea904 | ||
|
|
fe250d3ee8 | ||
|
|
6f55c67d16 | ||
|
|
3aa6e6a365 | ||
|
|
b8ced5d96b | ||
|
|
9e21c6a862 | ||
|
|
fe8566928e | ||
|
|
3600709116 | ||
|
|
df115c73b2 | ||
|
|
dbe025fe40 | ||
|
|
2b11a47a2f | ||
|
|
fb63a7418e | ||
|
|
2029931b95 | ||
|
|
91219bb3dd | ||
|
|
ab4fe4d58a | ||
|
|
8ff1f16b7f | ||
|
|
cf4f62c82c | ||
|
|
1d2f4264a2 | ||
|
|
9d506a4afa | ||
|
|
7ac22e9227 | ||
|
|
47f2fe724f | ||
|
|
130571fb29 | ||
|
|
da7218350b | ||
|
|
b6078de6f8 | ||
|
|
07430b0194 | ||
|
|
fae02fab00 | ||
|
|
a68cdc40be | ||
|
|
76b307f42a | ||
|
|
6e4b7eb966 | ||
|
|
770754ae2c | ||
|
|
a932855f6f | ||
|
|
72ee1abc90 | ||
|
|
9e1909643c | ||
|
|
77a1329285 | ||
|
|
be6ecc388c | ||
|
|
13dba94307 | ||
|
|
d51440bb5d | ||
|
|
d730e179bf | ||
|
|
559fe513fa | ||
|
|
5b20fa7e38 | ||
|
|
d16e75de91 | ||
|
|
6fd9994590 | ||
|
|
b9729f3b66 | ||
|
|
d6ff7475f1 | ||
|
|
984979d9bf | ||
|
|
73c449b97b | ||
|
|
1529666232 | ||
|
|
3816b86a9e | ||
|
|
a4b30fc649 | ||
|
|
fc50eb8688 | ||
|
|
071db1fae7 | ||
|
|
a163ea63c5 | ||
|
|
e21a707166 | ||
|
|
1b484fa90d | ||
|
|
06aa0f0b76 | ||
|
|
fb8bb30144 | ||
|
|
7429a33818 | ||
|
|
5b9f61cff8 | ||
|
|
4ff0e20e1f | ||
|
|
a692bfa8f9 | ||
|
|
49dd927406 | ||
|
|
4b21cc1737 | ||
|
|
7ae16f7302 | ||
|
|
73566a9f15 | ||
|
|
fbdf205ab4 | ||
|
|
83b2b4970d | ||
|
|
f29dc7d7ac | ||
|
|
4d5db74c18 | ||
|
|
8c7d285e03 | ||
|
|
1347abb1e7 | ||
|
|
2cb85e48b4 | ||
|
|
5be084e0f5 | ||
|
|
2323923bec | ||
|
|
0f54d42863 | ||
|
|
8201c7f46c | ||
|
|
ed22d640f4 | ||
|
|
01b009ff24 | ||
|
|
665b90bf5a | ||
|
|
4e1f245331 | ||
|
|
f8e1d39208 | ||
|
|
955dae5d4b | ||
|
|
b78cd3f4c9 | ||
|
|
6a3eb7edf2 | ||
|
|
0a710c0762 | ||
|
|
9a204f6284 | ||
|
|
7837970303 | ||
|
|
8cd9550295 | ||
|
|
840c692d5b | ||
|
|
05e0d3e2d4 | ||
|
|
7429ff9dce | ||
|
|
29602fe0cf | ||
|
|
1b95ec5591 | ||
|
|
3efe0dc8dc | ||
|
|
241e4af1b0 | ||
|
|
cac8a8df18 | ||
|
|
1181ceb735 | ||
|
|
f376f45277 | ||
|
|
d364afdf3b | ||
|
|
7ecfcf7eaa | ||
|
|
709c9bbe88 | ||
|
|
db175f606e | ||
|
|
3a664dc676 | ||
|
|
5f8d5f10a6 | ||
|
|
f02d4d9677 | ||
|
|
1889643eca | ||
|
|
4fc5c2024b | ||
|
|
354487d7f4 | ||
|
|
6478058946 | ||
|
|
8b8dcea3de | ||
|
|
64ace51e02 | ||
|
|
4cb5c67a44 | ||
|
|
2edefd9e80 | ||
|
|
fa8b16e7e7 | ||
|
|
2a953700e2 | ||
|
|
c1dc835b5c | ||
|
|
214f92c428 | ||
|
|
95fc680af9 | ||
|
|
22d0c6b5e1 | ||
|
|
ff1be13d0e | ||
|
|
a3201be7e7 | ||
|
|
37f0b51dff | ||
|
|
95d2dd74ad | ||
|
|
a175a25e6c | ||
|
|
6c406124dd | ||
|
|
0f17529486 | ||
|
|
dd10c867db | ||
|
|
8335dd3aa5 | ||
|
|
cd73ac7038 | ||
|
|
7cc33a839c | ||
|
|
828da6a425 | ||
|
|
2e5bdb8794 | ||
|
|
f56bac350b | ||
|
|
d373f16c81 | ||
|
|
ebffa15c7c | ||
|
|
6e4ee160ee | ||
|
|
a5697c5279 | ||
|
|
5abec720d8 | ||
|
|
84403b47cb | ||
|
|
4342a539af | ||
|
|
f4e744ade5 | ||
|
|
155d4c5591 | ||
|
|
f5cbe0e6ba | ||
|
|
a0e7d80daf | ||
|
|
d7e2f61e13 | ||
|
|
96ed4b02d7 | ||
|
|
cffc7c0121 | ||
|
|
d89000cc3d | ||
|
|
3661c75b39 | ||
|
|
3b20b11a9f | ||
|
|
cca366196d | ||
|
|
e09d444068 | ||
|
|
4956f5e710 | ||
|
|
5bebdfa434 | ||
|
|
aea915aa8d | ||
|
|
e0d29f398e | ||
|
|
c43b39bd88 | ||
|
|
8218da27b3 | ||
|
|
aa4bd00631 | ||
|
|
af6b9fdb39 | ||
|
|
c1b6493373 | ||
|
|
c386cca73f | ||
|
|
cadbdaff18 | ||
|
|
57510f517a | ||
|
|
3a2ddbe2e0 | ||
|
|
859347523f | ||
|
|
528fe6553f | ||
|
|
1faa0f4d41 | ||
|
|
82a11cae2d | ||
|
|
431948d768 | ||
|
|
f69c3d2b66 | ||
|
|
08b05964fa | ||
|
|
bd7f597682 | ||
|
|
6d4fbc9d32 | ||
|
|
124410a17b | ||
|
|
a543d57cbd | ||
|
|
8c3a0efe8b | ||
|
|
9e2841ad44 | ||
|
|
233e5f7c0e | ||
|
|
d5d9445cfd | ||
|
|
7be7417b5b | ||
|
|
0a14142156 | ||
|
|
a5e3785843 | ||
|
|
fc19ebb218 | ||
|
|
b45411f988 | ||
|
|
42f6371e47 | ||
|
|
be2aa6ab3a | ||
|
|
6e39ed9573 | ||
|
|
daf45a2993 | ||
|
|
d351b10fde | ||
|
|
0b21050904 | ||
|
|
644a7f524c | ||
|
|
53949ace36 | ||
|
|
14dba39157 | ||
|
|
43fd2a7423 | ||
|
|
4b0ac5356e | ||
|
|
c2f0d8e5ba | ||
|
|
0fb93b1e8a | ||
|
|
f94828c3f4 | ||
|
|
0e1e7c7df2 | ||
|
|
06110ba358 | ||
|
|
bae69f0102 | ||
|
|
77e7f4696b | ||
|
|
47fb2c9126 | ||
|
|
2ab9e4acd3 | ||
|
|
65ee7a8002 | ||
|
|
a5d0657d9b | ||
|
|
b8f01f91ca | ||
|
|
6cc6cf950c | ||
|
|
0b0349f746 | ||
|
|
2740974a13 | ||
|
|
97a9a262bb | ||
|
|
207efe700f | ||
|
|
e33315eaa6 | ||
|
|
5469d02d03 | ||
|
|
42c80893cb | ||
|
|
5c56ea3198 | ||
|
|
42f86329a9 | ||
|
|
08e273c0c7 | ||
|
|
5f8f98fa03 | ||
|
|
08c53ae27d | ||
|
|
f4f369895c | ||
|
|
38c21de0ee | ||
|
|
43cf36e0c7 | ||
|
|
9a9ff95989 | ||
|
|
fc40939775 | ||
|
|
553d8a828c | ||
|
|
80f7392fb1 | ||
|
|
61535c9972 | ||
|
|
b443c92a7a | ||
|
|
22da6c541d | ||
|
|
cd96354bc7 | ||
|
|
c6d859a08a | ||
|
|
ef47515420 | ||
|
|
a471a3d1b0 | ||
|
|
79a68fc2db | ||
|
|
93ddd46231 | ||
|
|
f5f0c197be | ||
|
|
4a30ec28b9 | ||
|
|
37ef9bb3d3 | ||
|
|
3e1d4a87fa | ||
|
|
320d46cc96 | ||
|
|
a06ceeef4c | ||
|
|
def573d7b4 | ||
|
|
7f7d29fdd1 | ||
|
|
c611d49941 | ||
|
|
11cd648699 | ||
|
|
98be5bf637 | ||
|
|
29df9771bb | ||
|
|
e68c1132da | ||
|
|
1047b1c191 | ||
|
|
9431e80eb4 | ||
|
|
178501de61 | ||
|
|
81c7f618fb | ||
|
|
eb2d816f2a | ||
|
|
244cb0e98c | ||
|
|
300ac4b77b | ||
|
|
0d189ac5df | ||
|
|
fed2c307a7 | ||
|
|
7aa2df5389 | ||
|
|
975ef0b305 | ||
|
|
e59146a733 | ||
|
|
8150c3602b | ||
|
|
ca8d776724 | ||
|
|
fdc40d5169 | ||
|
|
d0a97056c4 | ||
|
|
e98619f801 | ||
|
|
86eebc4305 | ||
|
|
4930f776fe | ||
|
|
19948c378a | ||
|
|
b3215b802d | ||
|
|
ed16d5b6aa | ||
|
|
7a94872413 | ||
|
|
98750922eb | ||
|
|
60c4c9ef2c | ||
|
|
101f04bbf2 | ||
|
|
4c593fa859 | ||
|
|
6603ad4006 | ||
|
|
d56c69dd01 | ||
|
|
e26a300c2f | ||
|
|
405482ede4 | ||
|
|
3db2b05069 | ||
|
|
ce5870223a | ||
|
|
9c1bb87493 | ||
|
|
1f7394dd54 | ||
|
|
bb569aa484 | ||
|
|
b0a350db37 | ||
|
|
78526a33b4 | ||
|
|
ab997b7fb1 | ||
|
|
6d431aebb7 | ||
|
|
a00ea23847 | ||
|
|
53ca751a02 | ||
|
|
8c444378bc | ||
|
|
55fdf0abda | ||
|
|
acd8ca2ebd | ||
|
|
06fdfad89e | ||
|
|
00ca493f33 | ||
|
|
b00d16fd7d | ||
|
|
03c373a4b3 | ||
|
|
bdaa39573f | ||
|
|
8a4c7f6e2b | ||
|
|
84ea0753d8 | ||
|
|
c1ef56c870 | ||
|
|
0e3252f045 | ||
|
|
65df218f91 | ||
|
|
5220a92be4 | ||
|
|
d643ca8dee | ||
|
|
de45152028 | ||
|
|
7fd9d0eeef | ||
|
|
d35a0b392e | ||
|
|
cbddfcde5b | ||
|
|
02ffa752ea | ||
|
|
6189e0c79b | ||
|
|
6ed6a0d447 | ||
|
|
484892ae97 | ||
|
|
027d9e938c | ||
|
|
e171f90d81 | ||
|
|
92c5d3b720 | ||
|
|
2a6e8ad68e | ||
|
|
55c8a0ac08 | ||
|
|
6073d948e6 | ||
|
|
b9171dd10b | ||
|
|
97b892fac2 | ||
|
|
b3fdf19b85 | ||
|
|
8c89e16ad2 | ||
|
|
960409c701 | ||
|
|
d1eeaa59a6 | ||
|
|
882f496e0a | ||
|
|
8b8aa1b4e6 | ||
|
|
932ac23f18 | ||
|
|
6c6560ca53 | ||
|
|
0698757e6e | ||
|
|
3a3f9b3496 | ||
|
|
97d87895bf | ||
|
|
c36fd72f99 | ||
|
|
57ae3d03a1 | ||
|
|
3737712044 | ||
|
|
8531339b4e | ||
|
|
540b12537a | ||
|
|
9e2fb45783 | ||
|
|
e7c128b973 | ||
|
|
d4a3470c9e | ||
|
|
4165b8c011 | ||
|
|
357ba2f64d | ||
|
|
3ce8818045 | ||
|
|
76082ac7cb | ||
|
|
4a451671d3 | ||
|
|
a3728b7188 | ||
|
|
a8711ab013 | ||
|
|
3e4754febd | ||
|
|
da1d661fa0 | ||
|
|
1801db523b | ||
|
|
2979c39628 | ||
|
|
bb9bb40287 | ||
|
|
8f6fdfeb0b | ||
|
|
b4e6d72fde | ||
|
|
a338ebfce0 | ||
|
|
4144364a15 | ||
|
|
11c0dd235b | ||
|
|
4a9502bf88 | ||
|
|
6c0d6d3178 | ||
|
|
0a26ca7104 | ||
|
|
2a15b2522f | ||
|
|
c11d1d78e9 | ||
|
|
7e51aa4cef | ||
|
|
9abb96fa6b | ||
|
|
879aafc916 | ||
|
|
5ec25122f6 | ||
|
|
9371b1aeb9 | ||
|
|
6f6d116451 | ||
|
|
3ff6eccfd7 | ||
|
|
5d1fa597ea | ||
|
|
3b6c2c9155 | ||
|
|
f863040b38 | ||
|
|
1033f8bce7 | ||
|
|
cf4dbbd681 | ||
|
|
6dccc693d0 | ||
|
|
c3dc66ce9c | ||
|
|
4856f56d61 | ||
|
|
2edc15dfb8 | ||
|
|
69e31baf68 | ||
|
|
586ff0c364 | ||
|
|
f3ba358d50 | ||
|
|
54bf4c3339 | ||
|
|
acda4344de | ||
|
|
6b0afd5d9b | ||
|
|
850910ed9e | ||
|
|
4ffa11a26c | ||
|
|
f5e60f8c40 | ||
|
|
ddaf1b79d4 | ||
|
|
d732dc3bb2 | ||
|
|
f0af5c5643 | ||
|
|
7a194789bc | ||
|
|
827d7a9a62 | ||
|
|
dae2761137 | ||
|
|
4304c1a7bb | ||
|
|
c537ea18a4 | ||
|
|
28fa7be75a | ||
|
|
f1a5862f3d | ||
|
|
4088e4e371 | ||
|
|
0ef6425847 | ||
|
|
7489deb1b7 | ||
|
|
2059e18e8b | ||
|
|
d11ee4c6d9 | ||
|
|
c74cbde329 | ||
|
|
20d541af06 | ||
|
|
2c163b3959 | ||
|
|
c6a7ef5574 | ||
|
|
7005c6af12 | ||
|
|
256986f01f | ||
|
|
33d322df9d | ||
|
|
631013be02 | ||
|
|
89a990e000 | ||
|
|
ccddd9d1de | ||
|
|
9587fc9909 | ||
|
|
22b7aed769 | ||
|
|
7db0da40ad | ||
|
|
2be70b2c36 | ||
|
|
0e03668cf2 | ||
|
|
28b89daa22 | ||
|
|
2bfa2f4292 | ||
|
|
3b22b9911b | ||
|
|
bc68ff1e43 | ||
|
|
f59af7483b | ||
|
|
394f85a96b | ||
|
|
626e3238f2 | ||
|
|
2051a84a09 | ||
|
|
f8bd4f5133 | ||
|
|
a4e514033d | ||
|
|
95f20ed7ab | ||
|
|
bfe92ea191 | ||
|
|
d3bacf475a | ||
|
|
3474464894 | ||
|
|
5b25bff2d8 | ||
|
|
c36896c524 | ||
|
|
d9fe25ac2e | ||
|
|
0bd006eef8 | ||
|
|
081d1f9779 | ||
|
|
546c975e28 | ||
|
|
05fb037edb | ||
|
|
5cdc196df1 | ||
|
|
0896c07972 | ||
|
|
be9f54d0a9 | ||
|
|
88fab44006 | ||
|
|
000fe3ddff | ||
|
|
f180f99a95 | ||
|
|
8d9aa9bf33 | ||
|
|
9fed91a47f | ||
|
|
12f830fbbb | ||
|
|
6d764a05b0 | ||
|
|
cd3ddec746 | ||
|
|
e4555a208d | ||
|
|
d53af96aa4 | ||
|
|
d1a9dc0f24 | ||
|
|
a1bcb28cea | ||
|
|
3fbba8b9db | ||
|
|
5fb850982a | ||
|
|
6f2e767c77 | ||
|
|
1ead5b0f3f | ||
|
|
eb6681d486 | ||
|
|
7503987630 | ||
|
|
1d337e8a76 | ||
|
|
f42e40712e | ||
|
|
b5fb8608ba | ||
|
|
dea1d67d03 | ||
|
|
9e6fc8f073 | ||
|
|
db6da75683 | ||
|
|
9cfd891fb9 | ||
|
|
f985680d2c | ||
|
|
8ae317e002 | ||
|
|
36e99c43ce | ||
|
|
eeb26aaa6f | ||
|
|
260dbe302a | ||
|
|
c297584726 | ||
|
|
5930383404 | ||
|
|
7395eb9791 | ||
|
|
e0de838b13 | ||
|
|
5292239714 | ||
|
|
b54fca4f7e | ||
|
|
26f47d2eb7 | ||
|
|
233e064f0b | ||
|
|
72c0898409 | ||
|
|
92d1f5122b | ||
|
|
314de3c3c0 | ||
|
|
544db43026 | ||
|
|
4aca3700b2 | ||
|
|
af833ff042 | ||
|
|
96c1a0a101 | ||
|
|
203e210d3a | ||
|
|
ff1c78fef5 | ||
|
|
d3a731dae4 | ||
|
|
73a4433d8e | ||
|
|
3b4ffea690 | ||
|
|
05d7f91392 | ||
|
|
e3e9f69654 | ||
|
|
34a4a9b08f | ||
|
|
e0836664e5 | ||
|
|
8d7499342f | ||
|
|
a7b24627b5 | ||
|
|
452324cf01 | ||
|
|
15c5c8db24 | ||
|
|
423efd54e4 | ||
|
|
5e45e0b3d7 | ||
|
|
a60e7f2376 | ||
|
|
ac7f0f7581 | ||
|
|
9c872345d6 | ||
|
|
bd312fa747 | ||
|
|
573fba55af | ||
|
|
39787f7d62 | ||
|
|
f4c067d527 | ||
|
|
8d3595c3e2 | ||
|
|
b81a57f1e4 | ||
|
|
a624f8b599 | ||
|
|
74f49a9d89 | ||
|
|
b7b89b30ea | ||
|
|
fb012504b2 | ||
|
|
7ed9ecf350 | ||
|
|
3af1520461 | ||
|
|
a7edda32ba | ||
|
|
7b09e320a8 | ||
|
|
46e077c40b | ||
|
|
7753ba6019 | ||
|
|
511204c158 | ||
|
|
65daef70c1 | ||
|
|
7ab373e86d | ||
|
|
79b81d39d8 | ||
|
|
2bbe5017d4 | ||
|
|
765a932561 | ||
|
|
4a2c9431ee | ||
|
|
de15d10f86 | ||
|
|
55d414bd72 | ||
|
|
1560685020 | ||
|
|
0e44659033 | ||
|
|
3b39cfb1cf | ||
|
|
15bca71b0d | ||
|
|
3c12455c5b | ||
|
|
927b4c928e | ||
|
|
be47cd2549 | ||
|
|
a4a17f93f5 | ||
|
|
745e52b798 | ||
|
|
bbc2da2a4b | ||
|
|
4c1793b4e3 | ||
|
|
d1ca73f813 | ||
|
|
cdc7d0fe0e | ||
|
|
a27a271034 | ||
|
|
6c097d24b1 | ||
|
|
0115b655bd | ||
|
|
e8f1463cc2 | ||
|
|
e164d53fcc | ||
|
|
b8f7b3cc8d | ||
|
|
b0e6fb73c6 | ||
|
|
dd50f1737b | ||
|
|
38a99856c0 | ||
|
|
09e7f0d013 | ||
|
|
e05e413cc4 | ||
|
|
2c21cbb5e6 | ||
|
|
3bc4b4bf9f | ||
|
|
a09f2a6987 | ||
|
|
1f57d730df | ||
|
|
eebc72b2bc | ||
|
|
2f3cf19afa | ||
|
|
10fbda702b | ||
|
|
17f130550e | ||
|
|
251f335fe3 | ||
|
|
ed2fb84e82 | ||
|
|
634684236c | ||
|
|
11e0d9ec14 | ||
|
|
5fd8f5aa27 | ||
|
|
c05ddb6119 | ||
|
|
ec86a972a2 | ||
|
|
62da8a34f3 | ||
|
|
6511ec3aa8 | ||
|
|
1707157c4d | ||
|
|
ee49ab84a4 | ||
|
|
b92a55f5fe | ||
|
|
7d3b16f24c | ||
|
|
b612b99421 | ||
|
|
5a5b3de79a | ||
|
|
0862e21a1b | ||
|
|
c148b768f4 | ||
|
|
fab9f684af | ||
|
|
0af48fe802 | ||
|
|
a9ae2c7457 | ||
|
|
87c0049e75 | ||
|
|
e5eb7ecdc1 | ||
|
|
a7e7823535 | ||
|
|
33ff96fd83 | ||
|
|
58852b3eeb | ||
|
|
403ee260f6 | ||
|
|
84149f26df | ||
|
|
2ab836c11c | ||
|
|
7d9dbd62c7 | ||
|
|
c9a6350894 | ||
|
|
2a4198f94d | ||
|
|
850ab6999c | ||
|
|
2946e81995 | ||
|
|
c78a64ec9b | ||
|
|
61386c5b4d | ||
|
|
279eae4b92 | ||
|
|
37f7af56e4 | ||
|
|
ec2d491dc8 | ||
|
|
890d415e1f | ||
|
|
75f951d254 | ||
|
|
d4b633bfc5 | ||
|
|
b20a534e0c | ||
|
|
64f7b13888 | ||
|
|
7523359aba | ||
|
|
eae9e1cbfa | ||
|
|
178cb98795 | ||
|
|
8f0c628310 | ||
|
|
16794a84de | ||
|
|
189da9afb3 | ||
|
|
af97682cca | ||
|
|
bdd64093e5 | ||
|
|
1dc5a6e5f8 | ||
|
|
89a888de76 | ||
|
|
3be797c759 | ||
|
|
ad585771e7 | ||
|
|
853b536394 | ||
|
|
bfb20aaa47 | ||
|
|
cf4dcb12ed | ||
|
|
3811d916b9 | ||
|
|
db6d3ba486 | ||
|
|
dd5315cbaa | ||
|
|
f8ac0ef0b9 | ||
|
|
b56f7e8ad2 | ||
|
|
57ca1e0cf6 | ||
|
|
d9e0ef0ebf | ||
|
|
8237aba840 | ||
|
|
63781c4953 | ||
|
|
c822012aad | ||
|
|
7d192ace6d | ||
|
|
58e461e4c7 | ||
|
|
5dc10bd5a2 | ||
|
|
f9a098743b | ||
|
|
f1fe70656f | ||
|
|
e24ea7c1bb | ||
|
|
8e2e852b89 | ||
|
|
4c10294a29 | ||
|
|
31bf7443a6 | ||
|
|
e6d18fc948 | ||
|
|
a90ace7fa1 | ||
|
|
caa8210112 | ||
|
|
1c85edbda9 | ||
|
|
72d19cd523 | ||
|
|
cc17aa8d6b | ||
|
|
181e238b55 | ||
|
|
7d74bf781c | ||
|
|
a0fde50c08 | ||
|
|
8224cc34ea | ||
|
|
411f361fcb | ||
|
|
e080bdff0f | ||
|
|
fae8da2bcb | ||
|
|
2d1337e190 | ||
|
|
ec4e3c36af | ||
|
|
1489e6c00e | ||
|
|
61769a1bad | ||
|
|
56839ba50f | ||
|
|
fe6a2e9f14 | ||
|
|
11c91e3b8d | ||
|
|
e70f405abd | ||
|
|
8b8ee00725 | ||
|
|
121126cb50 | ||
|
|
9a13086122 | ||
|
|
c68833cd7f | ||
|
|
d4fa528d5c | ||
|
|
8e19336f49 | ||
|
|
52178caa98 | ||
|
|
e5cb5d439d | ||
|
|
e28fa6c787 | ||
|
|
313574ce97 | ||
|
|
96a84294f4 | ||
|
|
7611aa2f65 | ||
|
|
97fa7e0817 | ||
|
|
417b5b031b | ||
|
|
a7e26e8f59 | ||
|
|
7665e5a035 | ||
|
|
c9a553fdb4 | ||
|
|
5e072dabc3 | ||
|
|
e5b7424592 | ||
|
|
e99dc2a3da | ||
|
|
211214a8d3 | ||
|
|
e10d11c6c7 | ||
|
|
f0088ca2be | ||
|
|
3cd3d1f5ae | ||
|
|
14cef94e61 | ||
|
|
71ef94dae6 | ||
|
|
fc99954b2e | ||
|
|
1526501ed7 | ||
|
|
5d98c09ee9 | ||
|
|
7da5196bac | ||
|
|
7fd40cb0e6 | ||
|
|
b6b1c23575 | ||
|
|
409ded385f | ||
|
|
e2d0c9f3c1 | ||
|
|
9cf85f90fb | ||
|
|
fb796d14ec | ||
|
|
43c2eb383e | ||
|
|
2bc46b8f21 | ||
|
|
c84648c157 | ||
|
|
b15441df1c | ||
|
|
85f32d6c0f | ||
|
|
9908c93d4c | ||
|
|
388c7f706d | ||
|
|
36398eedca | ||
|
|
aa41b813b8 | ||
|
|
4e2fe6427c | ||
|
|
7f0a0ce5e5 | ||
|
|
2a39bc6e68 | ||
|
|
07c47eed54 | ||
|
|
a165072915 | ||
|
|
c5109d39d0 | ||
|
|
e4a51e460e | ||
|
|
2467e9996e | ||
|
|
3afd12f977 | ||
|
|
f45b3fa3f2 | ||
|
|
fc6b08c8ab | ||
|
|
441cd27a53 | ||
|
|
c73737f77f | ||
|
|
ecd92d5e71 | ||
|
|
d1143b4580 | ||
|
|
09595697cc | ||
|
|
1f887a6ca0 | ||
|
|
eba6e46c74 | ||
|
|
f0daf11375 | ||
|
|
71341a623a | ||
|
|
e2a7a795d4 | ||
|
|
ed7d7a9ad9 | ||
|
|
9b69bde613 | ||
|
|
119ffbab40 | ||
|
|
e92b54b869 | ||
|
|
0273e128f4 | ||
|
|
a948050015 | ||
|
|
a0dbeabed1 | ||
|
|
eb615347d2 | ||
|
|
2d4063234a | ||
|
|
4fcb66df92 | ||
|
|
a9bdac836c | ||
|
|
bb696f3fd0 | ||
|
|
bc26244114 | ||
|
|
08c2f03ccc | ||
|
|
9e35e5c2b0 | ||
|
|
d10f63b666 | ||
|
|
aa6ac5a751 | ||
|
|
42e79bfab9 | ||
|
|
a3b4f80c99 | ||
|
|
b2f3cfde0b | ||
|
|
c036480ce2 | ||
|
|
043f9d8298 | ||
|
|
14aca11dcd |
4
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
4
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
contact_links:
|
||||
- name: Nominatim Discussions
|
||||
url: https://github.com/osm-search/Nominatim/discussions
|
||||
about: Ask questions, get support, share ideas and discuss with community members.
|
||||
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Before opening a new feature request, please search through the open issue to check that your request hasn't been reported already. -->
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||
|
||||
**Describe the solution you'd like**
|
||||
<!-- A clear and concise description of what you want to happen. -->
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||
|
||||
**Additional context**
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
37
.github/ISSUE_TEMPLATE/report-issues-with-search-results.md
vendored
Normal file
37
.github/ISSUE_TEMPLATE/report-issues-with-search-results.md
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: Report issues with search results
|
||||
about: You have searched something with Nominatim and did not get the expected result.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## What did you search for?
|
||||
|
||||
<!-- Please try to provide a link to your search. You can go to https://nominatim.openstreetmap.org and repeat your search there. If you originally found the issue somewhere else, please tell us what software/website you were using. -->
|
||||
|
||||
## What result did you get?
|
||||
|
||||
## What result did you expect?
|
||||
|
||||
**Is the result in the right place and just named wrongly?**
|
||||
|
||||
<!-- Please tell us the display name you expected. -->
|
||||
|
||||
**Is the result missing completely?**
|
||||
|
||||
<!-- Make sure that the data you are looking for is in OpenStreetMap. Provide a link to the OpenStreetMap object or if you cannot get it, a link to the map on https://openstreetmap.org where you expect the result to be.
|
||||
|
||||
To get the link to the OSM object, you can try the following:
|
||||
|
||||
* Go to [https://openstreetmap.org](https://openstreetmap.org).
|
||||
* Move to the area of the map where you expect the result and then zoom in as much as possible.
|
||||
* Click on the question mark on the right side of the map. You get a question cursor. Use it to click on the map where your object is located.
|
||||
* Find the object of interest in the list that appears on the left side.
|
||||
* Click on the object and report back the URL that the browser shows.
|
||||
-->
|
||||
|
||||
## Further details
|
||||
|
||||
<!-- Anything else we should know about the search. Particularities with addresses in the area etc. -->
|
||||
36
.github/ISSUE_TEMPLATE/report-problems-with-the-software.md
vendored
Normal file
36
.github/ISSUE_TEMPLATE/report-problems-with-the-software.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: Report problems with the software
|
||||
about: You have your own installation of Nominatim and found a bug.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Note: if you are installing Nominatim through a docker image, you should report issues with the installation process with the docker repository first. -->
|
||||
|
||||
**Describe the bug**
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
**To Reproduce**
|
||||
<!-- Please describe what you did to get to the issue. -->
|
||||
|
||||
**Software Environment (please complete the following information):**
|
||||
- Nominatim version:
|
||||
- Postgresql version:
|
||||
- Postgis version:
|
||||
- OS:
|
||||
|
||||
**Hardware Configuration (please complete the following information):**
|
||||
- RAM:
|
||||
- number of CPUs:
|
||||
- type and size of disks:
|
||||
- bare metal/AWS/other cloud service:
|
||||
|
||||
**Postgresql Configuration:**
|
||||
|
||||
<!-- List any configuration items you changed in your postgresql configuration. -->
|
||||
|
||||
**Additional context**
|
||||
|
||||
<!-- Add any other context about the problem here. -->
|
||||
29
.github/actions/build-nominatim/action.yml
vendored
Normal file
29
.github/actions/build-nominatim/action.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: 'Build Nominatim'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
||||
steps:
|
||||
- name: Install prerequisites
|
||||
run: |
|
||||
sudo apt-get install -y -qq libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libproj-dev libicu-dev python3-psycopg2 python3-pyosmium python3-dotenv python3-psutil python3-jinja2 python3-icu
|
||||
shell: bash
|
||||
|
||||
- name: Download dependencies
|
||||
run: |
|
||||
if [ ! -f country_grid.sql.gz ]; then
|
||||
wget --no-verbose https://www.nominatim.org/data/country_grid.sql.gz
|
||||
fi
|
||||
cp country_grid.sql.gz Nominatim/data/country_osm_grid.sql.gz
|
||||
shell: bash
|
||||
|
||||
- name: Configure
|
||||
run: mkdir build && cd build && cmake ../Nominatim
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make -j2 all
|
||||
sudo make install
|
||||
shell: bash
|
||||
working-directory: build
|
||||
47
.github/actions/setup-postgresql/action.yml
vendored
Normal file
47
.github/actions/setup-postgresql/action.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: 'Setup Postgresql and Postgis'
|
||||
|
||||
inputs:
|
||||
postgresql-version:
|
||||
description: 'Version of PostgreSQL to install'
|
||||
required: true
|
||||
postgis-version:
|
||||
description: 'Version of Postgis to install'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
||||
steps:
|
||||
- name: Remove existing PostgreSQL
|
||||
run: |
|
||||
sudo apt-get purge -yq postgresql*
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo apt-get update -qq
|
||||
|
||||
shell: bash
|
||||
|
||||
- name: Install PostgreSQL
|
||||
run: |
|
||||
sudo apt-get install -y -qq --no-install-suggests --no-install-recommends postgresql-client-${PGVER} postgresql-${PGVER}-postgis-${POSTGISVER} postgresql-${PGVER}-postgis-${POSTGISVER}-scripts postgresql-contrib-${PGVER} postgresql-${PGVER} postgresql-server-dev-${PGVER}
|
||||
shell: bash
|
||||
env:
|
||||
PGVER: ${{ inputs.postgresql-version }}
|
||||
POSTGISVER: ${{ inputs.postgis-version }}
|
||||
|
||||
- name: Adapt postgresql configuration
|
||||
run: |
|
||||
echo 'fsync = off' | sudo tee /etc/postgresql/${PGVER}/main/conf.d/local.conf
|
||||
echo 'synchronous_commit = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
|
||||
echo 'full_page_writes = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
|
||||
echo 'shared_buffers = 1GB' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
|
||||
echo 'port = 5432' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
|
||||
shell: bash
|
||||
env:
|
||||
PGVER: ${{ inputs.postgresql-version }}
|
||||
|
||||
- name: Setup database
|
||||
run: |
|
||||
sudo systemctl restart postgresql
|
||||
sudo -u postgres createuser -S www-data
|
||||
sudo -u postgres createuser -s runner
|
||||
shell: bash
|
||||
171
.github/workflows/ci-tests.yml
vendored
Normal file
171
.github/workflows/ci-tests.yml
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
name: CI Tests
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
postgresql: [9.5, 13]
|
||||
include:
|
||||
- postgresql: 9.5
|
||||
postgis: 2.5
|
||||
- postgresql: 13
|
||||
postgis: 3
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
path: Nominatim
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
tools: phpunit, phpcs
|
||||
|
||||
- name: Get Date
|
||||
id: get-date
|
||||
run: |
|
||||
echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
|
||||
shell: bash
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
country_grid.sql.gz
|
||||
key: nominatim-country-data-${{ steps.get-date.outputs.date }}
|
||||
|
||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||
with:
|
||||
postgresql-version: ${{ matrix.postgresql }}
|
||||
postgis-version: ${{ matrix.postgis }}
|
||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||
|
||||
- name: Install test prerequsites
|
||||
run: sudo apt-get install -y -qq php-codesniffer pylint python3-pytest python3-behave
|
||||
|
||||
- name: PHP linting
|
||||
run: phpcs --report-width=120 .
|
||||
working-directory: Nominatim
|
||||
|
||||
- name: Python linting
|
||||
run: pylint --extension-pkg-whitelist=osmium nominatim
|
||||
working-directory: Nominatim
|
||||
|
||||
- name: PHP unit tests
|
||||
run: phpunit ./
|
||||
working-directory: Nominatim/test/php
|
||||
|
||||
- name: Python unit tests
|
||||
run: py.test-3 test/python
|
||||
working-directory: Nominatim
|
||||
|
||||
- name: BDD tests
|
||||
run: behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
|
||||
working-directory: Nominatim/test/bdd
|
||||
|
||||
import:
|
||||
strategy:
|
||||
matrix:
|
||||
ubuntu: [18, 20]
|
||||
include:
|
||||
- ubuntu: 18
|
||||
postgresql: 9.5
|
||||
postgis: 2.5
|
||||
- ubuntu: 20
|
||||
postgresql: 13
|
||||
postgis: 3
|
||||
|
||||
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
path: Nominatim
|
||||
|
||||
- name: Get Date
|
||||
id: get-date
|
||||
run: |
|
||||
echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
|
||||
shell: bash
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
country_grid.sql.gz
|
||||
key: nominatim-country-data-${{ steps.get-date.outputs.date }}
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
monaco-latest.osm.pbf
|
||||
key: nominatim-test-data-${{ steps.get-date.outputs.date }}
|
||||
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.5
|
||||
if: matrix.ubuntu == 18
|
||||
|
||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||
with:
|
||||
postgresql-version: ${{ matrix.postgresql }}
|
||||
postgis-version: ${{ matrix.postgis }}
|
||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||
|
||||
- name: Install extra dependencies for Ubuntu 18
|
||||
run: |
|
||||
sudo apt-get install libicu-dev
|
||||
pip3 install python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu osmium
|
||||
shell: bash
|
||||
if: matrix.ubuntu == 18
|
||||
|
||||
- name: Clean installation
|
||||
run: rm -rf Nominatim build
|
||||
shell: bash
|
||||
|
||||
- name: Prepare import environment
|
||||
run: |
|
||||
if [ ! -f monaco-latest.osm.pbf ]; then
|
||||
wget --no-verbose https://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
||||
fi
|
||||
mkdir data-env
|
||||
cd data-env
|
||||
shell: bash
|
||||
|
||||
- name: Import
|
||||
run: nominatim import --osm-file ../monaco-latest.osm.pbf
|
||||
shell: bash
|
||||
working-directory: data-env
|
||||
|
||||
- name: Import special phrases
|
||||
run: nominatim special-phrases --import-from-wiki
|
||||
working-directory: data-env
|
||||
|
||||
- name: Check full import
|
||||
run: nominatim admin --check-database
|
||||
working-directory: data-env
|
||||
|
||||
- name: Warm up database
|
||||
run: nominatim admin --warm
|
||||
working-directory: data-env
|
||||
|
||||
- name: Run update
|
||||
run: |
|
||||
nominatim replication --init
|
||||
nominatim replication --once
|
||||
working-directory: data-env
|
||||
|
||||
- name: Run reverse-only import
|
||||
run : nominatim import --osm-file ../monaco-latest.osm.pbf --reverse-only --no-updates
|
||||
working-directory: data-env
|
||||
env:
|
||||
NOMINATIM_DATABASE_DSN: pgsql:dbname=reverse
|
||||
|
||||
- name: Check reverse import
|
||||
run: nominatim admin --check-database
|
||||
working-directory: data-env
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ data/wiki_specialphrases.sql
|
||||
data/osmosischange.osc
|
||||
|
||||
.vagrant
|
||||
data/country_osm_grid.sql.gz
|
||||
|
||||
12
.pylintrc
Normal file
12
.pylintrc
Normal file
@@ -0,0 +1,12 @@
|
||||
[MASTER]
|
||||
|
||||
extension-pkg-whitelist=osmium
|
||||
ignored-modules=icu
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# closing added here because it sometimes triggers a false positive with
|
||||
# 'with' statements.
|
||||
ignored-classes=NominatimArgs,closing
|
||||
32
.travis.yml
32
.travis.yml
@@ -1,32 +0,0 @@
|
||||
---
|
||||
sudo: required
|
||||
dist: trusty
|
||||
language: python
|
||||
python:
|
||||
- "3.6"
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
git:
|
||||
depth: 3
|
||||
env:
|
||||
- TEST_SUITE=tests
|
||||
- TEST_SUITE=monaco
|
||||
install:
|
||||
- vagrant/install-on-travis-ci.sh
|
||||
before_script:
|
||||
- psql -U postgres -c "create extension postgis"
|
||||
script:
|
||||
- cd $TRAVIS_BUILD_DIR/
|
||||
- if [[ $TEST_SUITE == "tests" ]]; then phpcs --report-width=120 . ; fi
|
||||
- cd $TRAVIS_BUILD_DIR/test/php
|
||||
- if [[ $TEST_SUITE == "tests" ]]; then phpunit ./ ; fi
|
||||
- cd $TRAVIS_BUILD_DIR/test/bdd
|
||||
- # behave --format=progress3 api
|
||||
- if [[ $TEST_SUITE == "tests" ]]; then behave --format=progress3 db ; fi
|
||||
- if [[ $TEST_SUITE == "tests" ]]; then behave --format=progress3 osm2pgsql ; fi
|
||||
- cd $TRAVIS_BUILD_DIR/build
|
||||
- if [[ $TEST_SUITE == "monaco" ]]; then wget --no-verbose --output-document=../data/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf; fi
|
||||
- if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/setup.php --osm-file ../data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | grep -v 'ETA (seconds)'; fi
|
||||
- if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim >/dev/null; fi
|
||||
notifications:
|
||||
email: false
|
||||
330
CMakeLists.txt
330
CMakeLists.txt
@@ -6,7 +6,7 @@
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
project(nominatim)
|
||||
|
||||
set(NOMINATIM_VERSION_MAJOR 3)
|
||||
set(NOMINATIM_VERSION_MINOR 2)
|
||||
set(NOMINATIM_VERSION_PATCH 0)
|
||||
set(NOMINATIM_VERSION_MINOR 7)
|
||||
set(NOMINATIM_VERSION_PATCH 3)
|
||||
|
||||
set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
|
||||
|
||||
@@ -28,135 +28,249 @@ add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Find external dependencies
|
||||
#
|
||||
# Configuration
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(BUILD_TESTS off CACHE BOOL "Build test suite" FORCE)
|
||||
set(WITH_LUA off CACHE BOOL "Build with lua support" FORCE)
|
||||
set(BUILD_IMPORTER on CACHE BOOL "Build everything for importing/updating the database")
|
||||
set(BUILD_API on CACHE BOOL "Build everything for the API server")
|
||||
set(BUILD_MODULE on CACHE BOOL "Build PostgreSQL module")
|
||||
set(BUILD_TESTS on CACHE BOOL "Build test suite")
|
||||
set(BUILD_DOCS on CACHE BOOL "Build documentation")
|
||||
set(BUILD_MANPAGE on CACHE BOOL "Build Manual Page")
|
||||
set(BUILD_OSM2PGSQL on CACHE BOOL "Build osm2pgsql (expert only)")
|
||||
|
||||
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/osm2pgsql/CMakeLists.txt")
|
||||
message(FATAL_ERROR "The osm2pgsql directory is empty.\
|
||||
Did you forget to check out Nominatim recursively?\
|
||||
\nTry updating submodules with: git submodule update --init")
|
||||
endif()
|
||||
add_subdirectory(osm2pgsql)
|
||||
#-----------------------------------------------------------------------------
|
||||
# osm2pgsql (imports/updates only)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
unset(PostgreSQL_TYPE_INCLUDE_DIR CACHE)
|
||||
set(PostgreSQL_TYPE_INCLUDE_DIR "/usr/include/")
|
||||
find_package(PostgreSQL REQUIRED)
|
||||
include_directories(${PostgreSQL_INCLUDE_DIRS})
|
||||
link_directories(${PostgreSQL_LIBRARY_DIRS})
|
||||
|
||||
find_program(PYOSMIUM pyosmium-get-changes)
|
||||
if (NOT EXISTS "${PYOSMIUM}")
|
||||
set(PYOSMIUM_PATH "")
|
||||
message(WARNING "pyosmium-get-changes not found (required for updates)")
|
||||
else()
|
||||
set(PYOSMIUM_PATH "${PYOSMIUM}")
|
||||
message(STATUS "Using pyosmium-get-changes at ${PYOSMIUM_PATH}")
|
||||
if (BUILD_IMPORTER AND BUILD_OSM2PGSQL)
|
||||
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/osm2pgsql/CMakeLists.txt")
|
||||
message(FATAL_ERROR "The osm2pgsql directory is empty.\
|
||||
Did you forget to check out Nominatim recursively?\
|
||||
\nTry updating submodules with: git submodule update --init")
|
||||
endif()
|
||||
set(BUILD_TESTS_SAVED "${BUILD_TESTS}")
|
||||
set(BUILD_TESTS off)
|
||||
set(WITH_LUA off CACHE BOOL "")
|
||||
add_subdirectory(osm2pgsql)
|
||||
set(BUILD_TESTS ${BUILD_TESTS_SAVED})
|
||||
endif()
|
||||
|
||||
|
||||
find_program(PG_CONFIG pg_config)
|
||||
execute_process(COMMAND ${PG_CONFIG} --pgxs
|
||||
OUTPUT_VARIABLE PGXS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
#-----------------------------------------------------------------------------
|
||||
# python (imports/updates only)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (NOT EXISTS "${PGXS}")
|
||||
message(FATAL_ERROR "Postgresql server package not found.")
|
||||
if (BUILD_IMPORTER)
|
||||
find_package(PythonInterp 3.5 REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
find_package(BZip2 REQUIRED)
|
||||
|
||||
find_package(LibXml2 REQUIRED)
|
||||
include_directories(${LIBXML2_INCLUDE_DIR})
|
||||
#-----------------------------------------------------------------------------
|
||||
# PHP
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Setting PHP binary variable as to command line (prevailing) or auto detect
|
||||
if (NOT PHP_BIN)
|
||||
find_program (PHP_BIN php)
|
||||
|
||||
if (BUILD_API OR BUILD_IMPORTER)
|
||||
if (NOT PHP_BIN)
|
||||
find_program (PHP_BIN php)
|
||||
endif()
|
||||
# sanity check if PHP binary exists
|
||||
if (NOT EXISTS ${PHP_BIN})
|
||||
message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
|
||||
else()
|
||||
message (STATUS "Using PHP binary " ${PHP_BIN})
|
||||
endif()
|
||||
if (NOT PHPCGI_BIN)
|
||||
find_program (PHPCGI_BIN php-cgi)
|
||||
endif()
|
||||
# sanity check if PHP binary exists
|
||||
if (NOT EXISTS ${PHPCGI_BIN})
|
||||
message(WARNING "php-cgi binary not found. nominatim tool will not provide query functions.")
|
||||
set (PHPCGI_BIN "")
|
||||
else()
|
||||
message (STATUS "Using php-cgi binary " ${PHPCGI_BIN})
|
||||
endif()
|
||||
endif()
|
||||
# sanity check if PHP binary exists
|
||||
if (NOT EXISTS ${PHP_BIN})
|
||||
message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# import scripts and utilities (importer only)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (BUILD_IMPORTER)
|
||||
find_file(COUNTRY_GRID_FILE country_osm_grid.sql.gz
|
||||
PATHS ${PROJECT_SOURCE_DIR}/data
|
||||
NO_DEFAULT_PATH
|
||||
DOC "Location of the country grid file."
|
||||
)
|
||||
|
||||
if (NOT COUNTRY_GRID_FILE)
|
||||
message(FATAL_ERROR "\nYou need to download the country_osm_grid first:\n"
|
||||
" wget -O ${PROJECT_SOURCE_DIR}/data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz")
|
||||
endif()
|
||||
|
||||
set(CUSTOMSCRIPTS
|
||||
check_import_finished.php
|
||||
country_languages.php
|
||||
export.php
|
||||
query.php
|
||||
setup.php
|
||||
update.php
|
||||
warm.php
|
||||
)
|
||||
|
||||
foreach (script_source ${CUSTOMSCRIPTS})
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
|
||||
${PROJECT_BINARY_DIR}/utils/${script_source})
|
||||
endforeach()
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/tool.tmpl
|
||||
${PROJECT_BINARY_DIR}/nominatim)
|
||||
endif()
|
||||
message (STATUS "Using PHP binary " ${PHP_BIN})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Setup settings and paths
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(CUSTOMFILES
|
||||
settings/phrase_settings.php
|
||||
website/deletable.php
|
||||
website/details.php
|
||||
website/hierarchy.php
|
||||
website/lookup.php
|
||||
website/polygons.php
|
||||
website/reverse.php
|
||||
website/search.php
|
||||
website/status.php
|
||||
utils/blocks.php
|
||||
utils/country_languages.php
|
||||
utils/imports.php
|
||||
utils/importWikipedia.php
|
||||
utils/export.php
|
||||
utils/query.php
|
||||
utils/server_compare.php
|
||||
utils/setup.php
|
||||
utils/specialphrases.php
|
||||
utils/update.php
|
||||
utils/warm.php
|
||||
)
|
||||
|
||||
foreach (cfile ${CUSTOMFILES})
|
||||
configure_file(${PROJECT_SOURCE_DIR}/${cfile} ${PROJECT_BINARY_DIR}/${cfile})
|
||||
endforeach()
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/settings/defaults.php ${PROJECT_BINARY_DIR}/settings/settings.php)
|
||||
|
||||
set(WEBPATHS css images js)
|
||||
|
||||
foreach (wp ${WEBPATHS})
|
||||
execute_process(
|
||||
COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
include(CTest)
|
||||
if (BUILD_TESTS)
|
||||
include(CTest)
|
||||
|
||||
set(TEST_BDD db osm2pgsql api)
|
||||
set(TEST_BDD db osm2pgsql api)
|
||||
|
||||
foreach (test ${TEST_BDD})
|
||||
add_test(NAME bdd_${test}
|
||||
COMMAND lettuce features/${test}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
|
||||
set_tests_properties(bdd_${test}
|
||||
PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
|
||||
endforeach()
|
||||
find_program(PYTHON_BEHAVE behave)
|
||||
find_program(PYLINT NAMES pylint3 pylint)
|
||||
find_program(PYTEST NAMES pytest py.test-3 py.test)
|
||||
find_program(PHPCS phpcs)
|
||||
find_program(PHPUNIT phpunit)
|
||||
|
||||
add_test(NAME php
|
||||
COMMAND phpunit ./
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
|
||||
if (PYTHON_BEHAVE)
|
||||
message(STATUS "Using Python behave binary ${PYTHON_BEHAVE}")
|
||||
foreach (test ${TEST_BDD})
|
||||
add_test(NAME bdd_${test}
|
||||
COMMAND ${PYTHON_BEHAVE} ${test}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/bdd)
|
||||
set_tests_properties(bdd_${test}
|
||||
PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
|
||||
endforeach()
|
||||
else()
|
||||
message(WARNING "behave not found. BDD tests disabled." )
|
||||
endif()
|
||||
|
||||
if (PHPUNIT)
|
||||
message(STATUS "Using phpunit binary ${PHPUNIT}")
|
||||
add_test(NAME php
|
||||
COMMAND ${PHPUNIT} ./
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/php)
|
||||
else()
|
||||
message(WARNING "phpunit not found. PHP unit tests disabled." )
|
||||
endif()
|
||||
|
||||
if (PHPCS)
|
||||
message(STATUS "Using phpcs binary ${PHPCS}")
|
||||
add_test(NAME phpcs
|
||||
COMMAND ${PHPCS} --report-width=120 --colors lib website utils
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
else()
|
||||
message(WARNING "phpcs not found. PHP linting tests disabled." )
|
||||
endif()
|
||||
|
||||
if (PYLINT)
|
||||
message(STATUS "Using pylint binary ${PYLINT}")
|
||||
add_test(NAME pylint
|
||||
COMMAND ${PYLINT} nominatim
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
else()
|
||||
message(WARNING "pylint not found. Python linting tests disabled.")
|
||||
endif()
|
||||
|
||||
if (PYTEST)
|
||||
message(STATUS "Using pytest binary ${PYTEST}")
|
||||
add_test(NAME pytest
|
||||
COMMAND ${PYTEST} test/python
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
else()
|
||||
message(WARNING "pytest not found. Python tests disabled." )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Postgres module
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(module)
|
||||
add_subdirectory(nominatim)
|
||||
add_subdirectory(docs)
|
||||
if (BUILD_MODULE)
|
||||
add_subdirectory(module)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Documentation
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (BUILD_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Manual page
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (BUILD_MANPAGE)
|
||||
add_subdirectory(manual)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Installation
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
set(NOMINATIM_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME})
|
||||
set(NOMINATIM_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME})
|
||||
set(NOMINATIM_CONFIGDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME})
|
||||
|
||||
if (BUILD_IMPORTER)
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/tool-installed.tmpl installed.bin)
|
||||
install(PROGRAMS ${PROJECT_BINARY_DIR}/installed.bin
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
RENAME nominatim)
|
||||
|
||||
install(DIRECTORY nominatim
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
||||
FILES_MATCHING PATTERN "*.py"
|
||||
PATTERN __pycache__ EXCLUDE)
|
||||
install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
|
||||
|
||||
install(FILES data/country_name.sql
|
||||
${COUNTRY_GRID_FILE}
|
||||
data/words.sql
|
||||
DESTINATION ${NOMINATIM_DATADIR})
|
||||
endif()
|
||||
|
||||
if (BUILD_OSM2PGSQL)
|
||||
if (${CMAKE_VERSION} VERSION_LESS 3.13)
|
||||
# Installation of subdirectory targets was only introduced in 3.13.
|
||||
# So just copy the osm2pgsql file for older versions.
|
||||
install(PROGRAMS ${PROJECT_BINARY_DIR}/osm2pgsql/osm2pgsql
|
||||
DESTINATION ${NOMINATIM_LIBDIR})
|
||||
else()
|
||||
install(TARGETS osm2pgsql RUNTIME DESTINATION ${NOMINATIM_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_MODULE)
|
||||
install(PROGRAMS ${PROJECT_BINARY_DIR}/module/nominatim.so
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/module)
|
||||
endif()
|
||||
|
||||
if (BUILD_API)
|
||||
install(DIRECTORY lib-php DESTINATION ${NOMINATIM_LIBDIR})
|
||||
endif()
|
||||
|
||||
install(FILES settings/env.defaults
|
||||
settings/address-levels.json
|
||||
settings/phrase-settings.json
|
||||
settings/import-admin.style
|
||||
settings/import-street.style
|
||||
settings/import-address.style
|
||||
settings/import-full.style
|
||||
settings/import-extratags.style
|
||||
DESTINATION ${NOMINATIM_CONFIGDIR})
|
||||
|
||||
@@ -7,38 +7,6 @@ Please always open a separate issue for each problem. In particular, do
|
||||
not add your bugs to closed issues. They may looks similar to you but
|
||||
often are completely different from the maintainer's point of view.
|
||||
|
||||
### When Reporting Bad Search Results...
|
||||
|
||||
Please make sure to add the following information:
|
||||
|
||||
* the URL of the query that produces the bad result
|
||||
* the result you are getting
|
||||
* the expected result, preferably a link to the OSM object you want to find,
|
||||
otherwise an address that is as precise as possible
|
||||
|
||||
To get the link to the OSM object, you can try the following:
|
||||
|
||||
* go to https://openstreetmap.org
|
||||
* zoom to the area of the map where you expect the result and
|
||||
zoom in as much as possible
|
||||
* click on the question mark on the right side of the map,
|
||||
then with the queston cursor on the map where your object is located
|
||||
* find the object of interest in the list that appears on the left side
|
||||
* click on the object and report the URL back that the browser shows
|
||||
|
||||
### When Reporting Problems with your Installation...
|
||||
|
||||
Please add the following information to your issue:
|
||||
|
||||
* hardware configuration: RAM size, CPUs, kind and size of disks
|
||||
* Operating system (also mention if you are running on a cloud service)
|
||||
* Postgres and Postgis version
|
||||
* list of settings you changed in your Postgres configuration
|
||||
* Nominatim version (release version or,
|
||||
if you run from the git repo, the output of `git rev-parse HEAD`)
|
||||
* (if applicable) exact command line of the command that was causing the issue
|
||||
|
||||
|
||||
## Workflow for Pull Requests
|
||||
|
||||
We love to get pull requests from you. We operate the "Fork & Pull" model
|
||||
@@ -81,22 +49,18 @@ are in process of consolidating the style. The following rules apply:
|
||||
* for PHP variables use CamelCase with a prefixing letter indicating the type
|
||||
(i - integer, f - float, a - array, s - string, o - object)
|
||||
|
||||
The coding style is enforced with PHPCS and can be tested with:
|
||||
The coding style is enforced with PHPCS and pylint. It can be tested with:
|
||||
|
||||
```
|
||||
phpcs --report-width=120 --colors .
|
||||
phpcs --report-width=120 --colors .
|
||||
pylint3 --extension-pkg-whitelist=osmium nominatim
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Before submitting a pull request make sure that the following tests pass:
|
||||
Before submitting a pull request make sure that the tests pass:
|
||||
|
||||
```
|
||||
cd test/bdd
|
||||
behave -DBUILDDIR=<builddir> db osm2pgsql
|
||||
```
|
||||
|
||||
```
|
||||
cd test/php
|
||||
phpunit ./
|
||||
cd build
|
||||
make test
|
||||
```
|
||||
|
||||
172
ChangeLog
172
ChangeLog
@@ -1,3 +1,175 @@
|
||||
3.7.3
|
||||
|
||||
* fix XSS vulnerability in debug view
|
||||
|
||||
3.7.2
|
||||
|
||||
* fix database check for reverse-only imports
|
||||
* do not error out in status API result when import date is missing
|
||||
* add array_key_last function for PHP < 7.3 (thanks to @woodpack)
|
||||
* fix more url when server name is unknown (thanks to @mogita)
|
||||
* commit changes to replication log table
|
||||
|
||||
3.7.1
|
||||
|
||||
* fix smaller issues with special phrases import
|
||||
* add index to speed up continued indexing during import
|
||||
* fix index on location_property_tiger(parent_place_id)
|
||||
* make sure Python code is backward-compatible with Python 3.5
|
||||
* various documentation fixes
|
||||
|
||||
3.7.0
|
||||
|
||||
* switch to dotenv for configuration file
|
||||
* introduce 'make install' (reorganising most of the code)
|
||||
* introduce nominatim tool as replacement for various php scripts
|
||||
* introduce project directories and allow multiple installations from same build
|
||||
* clean up BDD tests: drop nose, reorganise step code
|
||||
* simplify test database for API BDD tests and autoinstall database
|
||||
* port most of the code for command-line tools to Python
|
||||
(thanks to @darkshredder and @AntoJvlt)
|
||||
* add tests for all tooling
|
||||
* replace pyosmium-get-changes with custom internal implementation using
|
||||
pyosmium
|
||||
* improve search for queries with housenumber and partial terms
|
||||
* add database versioning
|
||||
* use jinja2 for preprocessing SQL files
|
||||
* introduce automatic migrations
|
||||
* reverse fix preference of interpolations over housenumbers
|
||||
* parallelize indexing of postcodes
|
||||
* add non-key indexes to speed up housenumber + street searches
|
||||
* switch housenumber field in placex to save transliterated names
|
||||
|
||||
|
||||
3.6.0
|
||||
|
||||
* add full support for searching by and displaying of addr:* tags
|
||||
* improve address output for large-area objects
|
||||
* better use of country names from OSM data for search and display
|
||||
* better debug output for reverse call
|
||||
* add support for addr:place links without an place equivalent in OSM
|
||||
* improve finding postcodes with normalisation artefacts
|
||||
* batch object to index for rank 30, avoiding a wrap-around of transaction
|
||||
IDs in PostgreSQL
|
||||
* introduce dynamic address rank computation for administrative boundaries
|
||||
depending on linked objects and their place in the admin level hierarchy
|
||||
* add country-specific address ranking for Indonesia, Russia, Belgium and
|
||||
the Netherlands (thanks @hendrikmoree)
|
||||
* make sure wikidata/wikipedia tags are imported for all styles
|
||||
* make POIs searchable by name and housenumber (thanks @joy-yyd)
|
||||
* reverse geocoding now ignores places without an address rank (rivers etc.)
|
||||
* installation of a webserver is no longer mandatory, for development
|
||||
use the php internal webserver via 'make serve
|
||||
* reduce the influence of place nodes in addresses
|
||||
* drop support for the unspecific is_in tag
|
||||
* various minor tweaks to supplied styles
|
||||
* move HTML web frontend into its own project
|
||||
* move scripts for processing external data sources into separate directories
|
||||
* introduce separate configuration for website (thanks @krahulreddy)
|
||||
* update documentation, in particular, clean up development docs
|
||||
* update osm2pgsql to 1.4.0
|
||||
|
||||
3.5.2
|
||||
|
||||
* ensure that wikipedia tags are imported for all styles
|
||||
* reinstate verbosity for indexing during updates
|
||||
* make house number reappear in display name on named POIs
|
||||
* introduce batch processing in indexer to avoid transaction ID overrun
|
||||
* increase splitting for large geometries to improve indexing speed
|
||||
* remove deprecated get_magic_quotes_gpc() function
|
||||
* make sure that all postcodes have an entry in word and are thus searchable
|
||||
* remove use of ST_Covers in conjunction woth ST_Intersects,
|
||||
causes bad query planning and slow updates in Postgis3
|
||||
* update osm2pgsql
|
||||
|
||||
3.5.1
|
||||
|
||||
* disable jit and parallel processing in PostgreSQL for osm2pgsql
|
||||
* update libosmium to 2.15.6 (fixes an issue with processing hanging
|
||||
on large multipolygons)
|
||||
|
||||
3.5.0
|
||||
|
||||
* structured select on HTML search page
|
||||
* new PHP Nominatim\Shell class to wrap shell escaping
|
||||
* remove polygon parameter from all API calls
|
||||
* improve handling of postcode areas
|
||||
* reorganise place linking algorithm, now using wikidata tag as well
|
||||
* remove linkees from search_name and larger_area tables
|
||||
* introduce country-specific address ranks
|
||||
* reorganise rank address computation
|
||||
* cleanup of partition function
|
||||
* improve parenting for large POIs
|
||||
* add support for Postgresql 12 and Postgis 3
|
||||
* add earlier cleanup when --drop is given, to reduce memory usage
|
||||
* remove use of place_id in URLs
|
||||
* replace C nominatim indexer with a simpler Python implementation
|
||||
* split up the huge sql/functions.sql file
|
||||
* move osm2pgsql tests to osm2pgsql
|
||||
* add new extratags style which imports all tags from OSM
|
||||
* add new script for checking the import after completion
|
||||
* update osm2pgsql, reducing memory usage
|
||||
* use new wikipedia importance and add processing of wikidata tags
|
||||
* add search form for details page
|
||||
* use ExtraDataPath for country_grid table
|
||||
* remove short_name from list of names to be displayed
|
||||
* split up CMakeFile, so that all parts can be built separately
|
||||
* update installation instructions for CentOS and Ubuntu
|
||||
* add script for importing/updating multiple country extracts
|
||||
* various documentation improvements
|
||||
|
||||
3.4.2
|
||||
|
||||
* fix security bug in /details endpoint where user input was not
|
||||
properly sanitized
|
||||
|
||||
3.4.1
|
||||
|
||||
* update osm2pgsql to fix hans during updates and lost address numbers
|
||||
during updates
|
||||
|
||||
3.4.0
|
||||
|
||||
* increase required version for PostgreSQL(9.3), PostGIS(2.2) and PHP(7.0)
|
||||
* better error reporting for out-of-memory errors
|
||||
* exclude postcode ranges separated by colon from centre point calculation
|
||||
* update osm2pgsql, better handling of imports without flatnode file
|
||||
* switch to more efficient algorithm for word set computation
|
||||
* use only boundries for country and state parts of addresses
|
||||
* improve updates of addresses with housenumbers and interpolations
|
||||
* remove country from place_addressline table and use country_code instead
|
||||
* optimise indexes on search_name partition tables
|
||||
* improve searching of attached streets for large objects like airports
|
||||
* drop support for python 2
|
||||
* new scripts for importing Wikidata for importance
|
||||
* create and drop indexes concurrently to not clash with auto vacuum
|
||||
* various documentation improvements
|
||||
|
||||
|
||||
3.3.0
|
||||
|
||||
* zoom 17 in reverse now zooms in on minor streets
|
||||
* fix use of postcode relations in address
|
||||
* support for housenumber 0 on interpolations
|
||||
* replace database abstraction DB with PDO and switch to using exceptions
|
||||
* exclude line features at rank 30 from reverse geocoding
|
||||
* remove self-reference and country from place_addressline
|
||||
* make json output more readable (less escaping)
|
||||
* update conversion scripts for postcodes
|
||||
* scripts in utils/ are no longer executable (always use scripts in build dir)
|
||||
* remove Natural Earth country fallback (OSM is complete enough)
|
||||
* make rank assignments configurable
|
||||
* allow accept languages with underscore
|
||||
* new reverse-only import mode (without search index table)
|
||||
* rely on boundaries only for states and countries
|
||||
* update osm2pgsql, now using a configurable style
|
||||
* provide multiple import styles
|
||||
* improve search when house number and postcodes are dropped
|
||||
* overhaul of setup code
|
||||
* add support for PHPUnit 6
|
||||
* update test database
|
||||
* various documentation improvements
|
||||
|
||||
3.2.0
|
||||
|
||||
* complete rewrite of reverse search algorithm
|
||||
|
||||
47
README.md
47
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://travis-ci.org/openstreetmap/Nominatim)
|
||||
[](https://github.com/osm-search/Nominatim/actions?query=workflow%3A%22CI+Tests%22)
|
||||
|
||||
Nominatim
|
||||
=========
|
||||
@@ -19,12 +19,19 @@ https://nominatim.org/release-docs/develop/ .
|
||||
Installation
|
||||
============
|
||||
|
||||
The latest stable release can be downloaded from https://nominatim.org.
|
||||
There you can also find [installation instructions for the release](https://nominatim.org/release-docs/latest/admin/Installation).
|
||||
**Nominatim is a complex piece of software and runs in a complex environment.
|
||||
Installing and running Nominatim is something for experienced system
|
||||
administrators only who can do some trouble-shooting themselves. We are sorry,
|
||||
but we can not provide installation support. We are all doing this in our free
|
||||
time and there is just so much of that time to go around. Do not open issues in
|
||||
our bug tracker if you need help. Use the discussions forum
|
||||
or ask for help on [help.openstreetmap.org](https://help.openstreetmap.org/).**
|
||||
|
||||
Detailed installation instructions for the development version can be
|
||||
found at [nominatim.org](https://nominatim.org/release-docs/develop/admin/Installation)
|
||||
as well.
|
||||
The latest stable release can be downloaded from https://nominatim.org.
|
||||
There you can also find [installation instructions for the release](https://nominatim.org/release-docs/latest/admin/Installation), as well as an extensive [Troubleshooting/FAQ section](https://nominatim.org/release-docs/latest/admin/Faq/).
|
||||
|
||||
[Detailed installation instructions for current master](https://nominatim.org/release-docs/develop/admin/Installation)
|
||||
can be found at nominatim.org as well.
|
||||
|
||||
A quick summary of the necessary steps:
|
||||
|
||||
@@ -34,12 +41,15 @@ A quick summary of the necessary steps:
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
sudo make install
|
||||
|
||||
2. Get OSM data and import:
|
||||
2. Create a project directory, get OSM data and import:
|
||||
|
||||
./build/utils/setup.php --osm-file <your planet file> --all
|
||||
mkdir nominatim-project
|
||||
cd nominatim-project
|
||||
nominatim import --osm-file <your planet file>
|
||||
|
||||
3. Point your webserver to the ./build/website directory.
|
||||
3. Point your webserver to the nominatim-project/website directory.
|
||||
|
||||
|
||||
License
|
||||
@@ -47,11 +57,18 @@ License
|
||||
|
||||
The source code is available under a GPLv2 license.
|
||||
|
||||
Contact and Bug reports
|
||||
======================
|
||||
|
||||
For questions you can join the geocoding mailinglist, see
|
||||
https://lists.openstreetmap.org/listinfo/geocoding
|
||||
Contributing
|
||||
============
|
||||
|
||||
Bugs may be reported on the github project site:
|
||||
https://github.com/openstreetmap/Nominatim
|
||||
Contributions, bugreport and pull requests are welcome.
|
||||
For details see [contribution guide](CONTRIBUTING.md).
|
||||
|
||||
|
||||
Questions and help
|
||||
==================
|
||||
|
||||
For questions, community help and discussions you can use the
|
||||
[Github discussions forum](https://github.com/osm-search/Nominatim/discussions)
|
||||
or join the
|
||||
[geocoding mailing list](https://lists.openstreetmap.org/listinfo/geocoding).
|
||||
|
||||
@@ -141,7 +141,7 @@ No. Long running Nominatim installations will differ once new import features (o
|
||||
bug fixes) get added since those usually only get applied to new/changed data.
|
||||
|
||||
Also this document skips the optional Wikipedia data import which affects ranking
|
||||
of search results. See [Nominatim installation](http://nominatim.org/release-docs/latest/Installation) for details.
|
||||
of search results. See [Nominatim installation](https://nominatim.org/release-docs/latest/admin/Installation) for details.
|
||||
|
||||
##### Why Ubuntu? Can I test CentOS/Fedora/CoreOS/FreeBSD?
|
||||
|
||||
@@ -160,9 +160,9 @@ You can configure/download other Vagrant boxes from [https://app.vagrantup.com/b
|
||||
|
||||
Let's say you have a Postgres database named `nominatim_it` on server `your-server.com` and port `5432`. The Postgres username is `postgres`. You can edit `settings/local.php` and point Nominatim to it.
|
||||
|
||||
pgsql://postgres@your-server.com:5432/nominatim_it
|
||||
pgsql:host=your-server.com;port=5432;user=postgres;dbname=nominatim_it
|
||||
|
||||
No data import necessary or restarting necessary.
|
||||
No data import or restarting necessary.
|
||||
|
||||
If the Postgres installation is behind a firewall, you can try
|
||||
|
||||
@@ -171,7 +171,7 @@ If the Postgres installation is behind a firewall, you can try
|
||||
inside the virtual machine. It will map the port to `localhost:9999` and then
|
||||
you edit `settings/local.php` with
|
||||
|
||||
@define('CONST_Database_DSN', 'pgsql://postgres@localhost:9999/nominatim_it');
|
||||
@define('CONST_Database_DSN', 'pgsql:host=localhost;port=9999;user=postgres;dbname=nominatim_it');
|
||||
|
||||
To access postgres directly remember to specify the hostname, e.g. `psql --host localhost --port 9999 nominatim_it`
|
||||
|
||||
|
||||
89
Vagrantfile
vendored
89
Vagrantfile
vendored
@@ -4,18 +4,65 @@
|
||||
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-18.04"
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu-apache" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-apache"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu-nginx" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-nginx"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu18" do |sub|
|
||||
sub.vm.box = "generic/ubuntu1804"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||
s.privileged = false
|
||||
@@ -23,39 +70,41 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu16" do |sub|
|
||||
sub.vm.box = "bento/ubuntu-16.04"
|
||||
config.vm.define "ubuntu18-apache" 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]
|
||||
s.args = [checkout, "install-apache"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "travis" do |sub|
|
||||
sub.vm.box = "bento/ubuntu-14.04"
|
||||
config.vm.define "ubuntu18-nginx" 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, "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 = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "centos" do |sub|
|
||||
sub.vm.box = "centos/7"
|
||||
sub.vm.box = "generic/centos8"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Centos-7.sh"
|
||||
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
|
||||
|
||||
14
cmake/script.tmpl
Executable file
14
cmake/script.tmpl
Executable file
@@ -0,0 +1,14 @@
|
||||
#!@PHP_BIN@ -Cq
|
||||
<?php
|
||||
require('@CMAKE_SOURCE_DIR@/lib-php/dotenv_loader.php');
|
||||
|
||||
@define('CONST_Default_ModulePath', '@CMAKE_BINARY_DIR@/module');
|
||||
@define('CONST_Default_Osm2pgsql', '@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql');
|
||||
@define('CONST_DataDir', '@CMAKE_SOURCE_DIR@/data');
|
||||
@define('CONST_SqlDir', '@CMAKE_SOURCE_DIR@/lib-sql');
|
||||
@define('CONST_ConfigDir', '@CMAKE_SOURCE_DIR@/settings');
|
||||
|
||||
loadDotEnv();
|
||||
$_SERVER['NOMINATIM_NOMINATIM_TOOL'] = '@CMAKE_BINARY_DIR@/nominatim';
|
||||
|
||||
require_once('@CMAKE_SOURCE_DIR@/lib-php/admin/@script_source@');
|
||||
17
cmake/tool-installed.tmpl
Normal file
17
cmake/tool-installed.tmpl
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(1, '@NOMINATIM_LIBDIR@/lib-python')
|
||||
|
||||
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||
|
||||
from nominatim import cli
|
||||
|
||||
exit(cli.nominatim(module_dir='@NOMINATIM_LIBDIR@/module',
|
||||
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql',
|
||||
phplib_dir='@NOMINATIM_LIBDIR@/lib-php',
|
||||
sqllib_dir='@NOMINATIM_LIBDIR@/lib-sql',
|
||||
data_dir='@NOMINATIM_DATADIR@',
|
||||
config_dir='@NOMINATIM_CONFIGDIR@',
|
||||
phpcgi_path='@PHPCGI_BIN@'))
|
||||
17
cmake/tool.tmpl
Executable file
17
cmake/tool.tmpl
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
||||
|
||||
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||
|
||||
from nominatim import cli
|
||||
|
||||
exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
|
||||
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
|
||||
phplib_dir='@CMAKE_SOURCE_DIR@/lib-php',
|
||||
sqllib_dir='@CMAKE_SOURCE_DIR@/lib-sql',
|
||||
data_dir='@CMAKE_SOURCE_DIR@/data',
|
||||
config_dir='@CMAKE_SOURCE_DIR@/settings',
|
||||
phpcgi_path='@PHPCGI_BIN@'))
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,26 +0,0 @@
|
||||
-- This data contains Ordnance Survey data © Crown copyright and database right 2010.
|
||||
-- Code-Point Open contains Royal Mail data © Royal Mail copyright and database right 2010.
|
||||
-- OS data may be used under the terms of the OS OpenData licence:
|
||||
-- http://www.ordnancesurvey.co.uk/oswebsite/opendata/licence/docs/licence.pdf
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = off;
|
||||
SET check_function_bodies = false;
|
||||
SET client_min_messages = warning;
|
||||
SET escape_string_warning = off;
|
||||
|
||||
SET search_path = public, pg_catalog;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_with_oids = false;
|
||||
|
||||
CREATE TABLE gb_postcode (
|
||||
id integer,
|
||||
postcode character varying(9),
|
||||
geometry geometry,
|
||||
CONSTRAINT enforce_dims_geometry CHECK ((st_ndims(geometry) = 2)),
|
||||
CONSTRAINT enforce_srid_geometry CHECK ((st_srid(geometry) = 4326))
|
||||
);
|
||||
|
||||
38126
data/us_postcode.sql
38126
data/us_postcode.sql
File diff suppressed because it is too large
Load Diff
@@ -6,15 +6,26 @@
|
||||
configure_file(mkdocs.yml ../mkdocs.yml)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/appendix)
|
||||
|
||||
set (DOC_SOURCES
|
||||
admin
|
||||
develop
|
||||
api
|
||||
index.md
|
||||
extra.css
|
||||
styles.css
|
||||
)
|
||||
|
||||
foreach (src ${DOC_SOURCES})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${CMAKE_CURRENT_BINARY_DIR}/${src}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
ADD_CUSTOM_TARGET(doc
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/admin ${CMAKE_CURRENT_BINARY_DIR}/admin
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/develop ${CMAKE_CURRENT_BINARY_DIR}/develop
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/api ${CMAKE_CURRENT_BINARY_DIR}/api
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/index.md ${CMAKE_CURRENT_BINARY_DIR}/index.md
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/extra.css ${CMAKE_CURRENT_BINARY_DIR}/extra.css
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Centos-7.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Centos-7.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-16.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-16.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Centos-8.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Centos-8.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-18.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-18.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-20.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-20.md
|
||||
COMMAND mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||
)
|
||||
|
||||
|
||||
173
docs/admin/Advanced-Installations.md
Normal file
173
docs/admin/Advanced-Installations.md
Normal file
@@ -0,0 +1,173 @@
|
||||
# Advanced installations
|
||||
|
||||
This page contains instructions for setting up multiple countries in
|
||||
your Nominatim database. It is assumed that you have already successfully
|
||||
installed the Nominatim software itself, if not return to the
|
||||
[installation page](Installation.md).
|
||||
|
||||
## Importing multiple regions
|
||||
|
||||
To import multiple regions in your database, you need to configure and run `utils/import_multiple_regions.sh` file. This script will set up the update directory which has the following structure:
|
||||
|
||||
```bash
|
||||
update
|
||||
├── europe
|
||||
│ ├── andorra
|
||||
│ │ └── sequence.state
|
||||
│ └── monaco
|
||||
│ └── sequence.state
|
||||
└── tmp
|
||||
├── combined.osm.pbf
|
||||
└── europe
|
||||
├── andorra-latest.osm.pbf
|
||||
└── monaco-latest.osm.pbf
|
||||
|
||||
|
||||
```
|
||||
|
||||
The `sequence.state` files will contain the sequence ID, which will be used by pyosmium to get updates. The tmp folder is used for import dump.
|
||||
|
||||
### Configuring multiple regions
|
||||
|
||||
The file `import_multiple_regions.sh` needs to be edited as per your requirement:
|
||||
|
||||
1. List of countries. eg:
|
||||
|
||||
COUNTRIES="europe/monaco europe/andorra"
|
||||
|
||||
2. Path to Build directory. eg:
|
||||
|
||||
NOMINATIMBUILD="/srv/nominatim/build"
|
||||
|
||||
3. Path to Update directory. eg:
|
||||
|
||||
UPDATEDIR="/srv/nominatim/update"
|
||||
|
||||
4. Replication URL. eg:
|
||||
|
||||
BASEURL="https://download.geofabrik.de"
|
||||
DOWNCOUNTRYPOSTFIX="-latest.osm.pbf"
|
||||
|
||||
### Setting up multiple regions
|
||||
|
||||
!!! tip
|
||||
If your database already exists and you want to add more countries,
|
||||
replace the setting up part
|
||||
`${SETUPFILE} --osm-file ${UPDATEDIR}/tmp/combined.osm.pbf --all 2>&1`
|
||||
with `${UPDATEFILE} --import-file ${UPDATEDIR}/tmp/combined.osm.pbf --index --index-instances N 2>&1`
|
||||
where N is the numbers of CPUs in your system.
|
||||
|
||||
Run the following command from your Nominatim directory after configuring the file.
|
||||
|
||||
bash ./utils/import_multiple_regions.sh
|
||||
|
||||
!!! danger "Important"
|
||||
This file uses osmium-tool. It must be installed before executing the import script.
|
||||
Installation instructions can be found [here](https://osmcode.org/osmium-tool/manual.html#installation).
|
||||
|
||||
### Updating multiple regions
|
||||
|
||||
To import multiple regions in your database, you need to configure and run ```utils/update_database.sh```.
|
||||
This uses the update directory set up while setting up the DB.
|
||||
|
||||
### Configuring multiple regions
|
||||
|
||||
The file `update_database.sh` needs to be edited as per your requirement:
|
||||
|
||||
1. List of countries. eg:
|
||||
|
||||
COUNTRIES="europe/monaco europe/andorra"
|
||||
|
||||
2. Path to Build directory. eg:
|
||||
|
||||
NOMINATIMBUILD="/srv/nominatim/build"
|
||||
|
||||
3. Path to Update directory. eg:
|
||||
|
||||
UPDATEDIR="/srv/nominatim/update"
|
||||
|
||||
4. Replication URL. eg:
|
||||
|
||||
BASEURL="https://download.geofabrik.de"
|
||||
DOWNCOUNTRYPOSTFIX="-updates"
|
||||
|
||||
5. Followup can be set according to your installation. eg: For Photon,
|
||||
|
||||
FOLLOWUP="curl http://localhost:2322/nominatim-update"
|
||||
|
||||
will handle the indexing.
|
||||
|
||||
### Updating the database
|
||||
|
||||
Run the following command from your Nominatim directory after configuring the file.
|
||||
|
||||
bash ./utils/update_database.sh
|
||||
|
||||
This will get diffs from the replication server, import diffs and index the database. The default replication server in the script([Geofabrik](https://download.geofabrik.de)) provides daily updates.
|
||||
|
||||
## Importing Nominatim to an external PostgreSQL database
|
||||
|
||||
You can install Nominatim using a database that runs on a different server when
|
||||
you have physical access to the file system on the other server. Nominatim
|
||||
uses a custom normalization library that needs to be made accessible to the
|
||||
PostgreSQL server. This section explains how to set up the normalization
|
||||
library.
|
||||
|
||||
### Option 1: Compiling the library on the database server
|
||||
|
||||
The most sure way to get a working library is to compile it on the database
|
||||
server. From the prerequisites you need at least cmake, gcc and the
|
||||
PostgreSQL server package.
|
||||
|
||||
Clone or unpack the Nominatim source code, enter the source directory and
|
||||
create and enter a build directory.
|
||||
|
||||
```sh
|
||||
cd Nominatim
|
||||
mkdir build
|
||||
cd build
|
||||
```
|
||||
|
||||
Now configure cmake to only build the PostgreSQL module and build it:
|
||||
|
||||
```
|
||||
cmake -DBUILD_IMPORTER=off -DBUILD_API=off -DBUILD_TESTS=off -DBUILD_DOCS=off -DBUILD_OSM2PGSQL=off ..
|
||||
make
|
||||
```
|
||||
|
||||
When done, you find the normalization library in `build/module/nominatim.so`.
|
||||
Copy it to a place where it is readable and executable by the PostgreSQL server
|
||||
process.
|
||||
|
||||
### Option 2: Compiling the library on the import machine
|
||||
|
||||
You can also compile the normalization library on the machine from where you
|
||||
run the import.
|
||||
|
||||
!!! important
|
||||
You can only do this when the database server and the import machine have
|
||||
the same architecture and run the same version of Linux. Otherwise there is
|
||||
no guarantee that the compiled library is compatible with the PostgreSQL
|
||||
server running on the database server.
|
||||
|
||||
Make sure that the PostgreSQL server package is installed on the machine
|
||||
**with the same version as on the database server**. You do not need to install
|
||||
the PostgreSQL server itself.
|
||||
|
||||
Download and compile Nominatim as per standard instructions. Once done, you find
|
||||
the normalization library in `build/module/nominatim.so`. Copy the file to
|
||||
the database server at a location where it is readable and executable by the
|
||||
PostgreSQL server process.
|
||||
|
||||
### Running the import
|
||||
|
||||
On the client side you now need to configure the import to point to the
|
||||
correct location of the library **on the database server**. Add the following
|
||||
line to your your `.env` file:
|
||||
|
||||
```php
|
||||
NOMINATIM_DATABASE_MODULE_PATH="<directory on the database server where nominatim.so resides>"
|
||||
```
|
||||
|
||||
Now change the `NOMINATIM_DATABASE_DSN` to point to your remote server and continue
|
||||
to follow the [standard instructions for importing](/admin/Import).
|
||||
142
docs/admin/Deployment.md
Normal file
142
docs/admin/Deployment.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Deploying Nominatim
|
||||
|
||||
The Nominatim API is implemented as a PHP application. The `website/` directory
|
||||
in the project 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 project directory is
|
||||
located in `/srv/nominatim-project` and that you have installed Nominatim
|
||||
using the default installation prefix `/usr/local`. 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-project/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 "/usr/local/nominatim/lib/lib-php(/.*)?"
|
||||
sudo semanage fcontext -a -t httpd_sys_content_t "/srv/nominatim-project/website(/.*)?"
|
||||
sudo semanage fcontext -a -t lib_t "/srv/nominatim-project/module/nominatim.so"
|
||||
sudo restorecon -R -v /usr/local/lib/nominatim
|
||||
sudo restorecon -R -v /srv/nominatim-project
|
||||
```
|
||||
|
||||
## 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
|
||||
<Directory "/srv/nominatim-project/website">
|
||||
Options FollowSymLinks MultiViews
|
||||
AddType text/html .php
|
||||
DirectoryIndex search.php
|
||||
Require all granted
|
||||
</Directory>
|
||||
Alias /nominatim /srv/nominatim-project/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/<php version>/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-project/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/`.
|
||||
|
||||
@@ -16,27 +16,44 @@ was killed. If it looks like this:
|
||||
then you can resume with the following command:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --index --create-search-indices --create-country-names
|
||||
nominatim import --continue indexing
|
||||
```
|
||||
|
||||
If the reported rank is 26 or higher, you can also safely add `--index-noanalyse`.
|
||||
|
||||
|
||||
### PostgreSQL crashed "invalid page in block"
|
||||
|
||||
Usually serious problem, can be a hardware issue, not all data written to disc
|
||||
for example. Check PostgreSQL log file and search PostgreSQL issues/mailing
|
||||
list for hints.
|
||||
|
||||
If it happened during index creation you can try rerunning the step with
|
||||
|
||||
```sh
|
||||
nominatim import --continue indexing
|
||||
```
|
||||
|
||||
Otherwise it's best to start the full setup from the beginning.
|
||||
|
||||
|
||||
### PHP "open_basedir restriction in effect" warnings
|
||||
|
||||
`PHP Warning: file_get_contents(): open_basedir restriction in effect.`
|
||||
PHP Warning: file_get_contents(): open_basedir restriction in effect.
|
||||
|
||||
You need to adjust the [open_basedir](http://www.php.net/manual/en/ini.core.php#ini.open-basedir) setting
|
||||
in your PHP configuration (`php.ini file`). By default this setting may look like this:
|
||||
You need to adjust the
|
||||
[open_basedir](https://www.php.net/manual/en/ini.core.php#ini.open-basedir)
|
||||
setting in your PHP configuration (`php.ini` file). By default this setting may
|
||||
look like this:
|
||||
|
||||
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/
|
||||
|
||||
Either add reported directories to the list or disable this setting temporarily by
|
||||
dding ";" at the beginning of the line. Don't forget to enable this setting again
|
||||
once you are done with the PHP command line operations.
|
||||
Either add reported directories to the list or disable this setting temporarily
|
||||
by adding ";" at the beginning of the line. Don't forget to enable this setting
|
||||
again once you are done with the PHP command line operations.
|
||||
|
||||
|
||||
### PHP timzeone warnings
|
||||
### PHP timezeone warnings
|
||||
|
||||
The Apache log may contain lots of PHP warnings like this:
|
||||
`PHP Warning: date_default_timezone_set() function.`
|
||||
@@ -44,9 +61,9 @@ The Apache log may contain lots of PHP warnings like this:
|
||||
You should set the default time zone as instructed in the warning in
|
||||
your `php.ini` file. Find the entry about timezone and set it to
|
||||
something like this:
|
||||
|
||||
|
||||
; Defines the default timezone used by the date functions
|
||||
; http://php.net/date.timezone
|
||||
; https://php.net/date.timezone
|
||||
date.timezone = 'America/Denver'
|
||||
|
||||
Or
|
||||
@@ -66,11 +83,42 @@ server development libraries (`postgresql-server-dev-9.5` on Ubuntu)
|
||||
and recompile (`cmake .. && make`).
|
||||
|
||||
|
||||
### I see the error "ERROR: permission denied for language c"
|
||||
|
||||
`nominatim.so`, written in C, is required to be installed on the database
|
||||
server. Some managed database (cloud) services like Amazon RDS do not allow
|
||||
this. There is currently no work-around other than installing a database
|
||||
on a non-managed machine.
|
||||
|
||||
|
||||
### I see the error: "function transliteration(text) does not exist"
|
||||
|
||||
Reinstall the nominatim functions with `setup.php --create--functions`
|
||||
Reinstall the nominatim functions with `nominatim refresh --functions`
|
||||
and check for any errors, e.g. a missing `nominatim.so` file.
|
||||
|
||||
### I see the error: "ERROR: mmap (remap) failed"
|
||||
|
||||
This may be a simple out-of-memory error. Try reducing the memory used
|
||||
for `--osm2pgsql-cache`. Also make sure that overcommitting memory is
|
||||
allowed: `cat /proc/sys/vm/overcommit_memory` should print 0 or 1.
|
||||
|
||||
If you are using a flatnode file, then it may also be that the underlying
|
||||
filesystem does not fully support 'mmap'. A notable candidate is virtualbox's
|
||||
vboxfs.
|
||||
|
||||
### I see the error: "clang: Command not found" on CentOS
|
||||
|
||||
On CentOS 7 users reported `/opt/rh/llvm-toolset-7/root/usr/bin/clang: Command not found`.
|
||||
Double-check clang is installed. Instead of `make` try running `make CLANG=true`.
|
||||
|
||||
### nominatim UPDATE failed: ERROR: buffer 179261 is not owned by resource owner Portal
|
||||
|
||||
Several users [reported this](https://github.com/openstreetmap/Nominatim/issues/1168)
|
||||
during the initial import of the database. It's
|
||||
something PostgreSQL internal Nominatim doesn't control. And PostgreSQL forums
|
||||
suggest it's threading related but definitely some kind of crash of a process.
|
||||
Users reported either rebooting the server, different hardware or just trying
|
||||
the import again worked.
|
||||
|
||||
### The website shows: "Could not get word tokens"
|
||||
|
||||
@@ -82,10 +130,11 @@ to get the full error message.
|
||||
|
||||
`could not connect to server: No such file or directory`
|
||||
|
||||
On CentOS v7 the PostgreSQL server is started with `systemd`.
|
||||
Check if `/usr/lib/systemd/system/httpd.service` contains a line `PrivateTmp=true`.
|
||||
If so then Apache cannot see the `/tmp/.s.PGSQL.5432` file. It's a good security feature,
|
||||
so use the [preferred solution](../appendix/Install-on-Centos-7/#adding-selinux-security-settings).
|
||||
On CentOS v7 the PostgreSQL server is started with `systemd`. Check if
|
||||
`/usr/lib/systemd/system/httpd.service` contains a line `PrivateTmp=true`. If
|
||||
so then Apache cannot see the `/tmp/.s.PGSQL.5432` file. It's a good security
|
||||
feature, so use the
|
||||
[preferred solution](../appendix/Install-on-Centos-7/#adding-selinux-security-settings).
|
||||
|
||||
However, you can solve this the quick and dirty way by commenting out that line and then run
|
||||
|
||||
@@ -95,7 +144,10 @@ However, you can solve this the quick and dirty way by commenting out that line
|
||||
|
||||
### Website reports "DB Error: insufficient permissions"
|
||||
|
||||
The user the webserver, e.g. Apache, runs under needs to have access to the Nominatim database. You can find the user like [this](https://serverfault.com/questions/125865/finding-out-what-user-apache-is-running-as), for default Ubuntu operating system for example it's `www-data`.
|
||||
The user the webserver, e.g. Apache, runs under needs to have access to the
|
||||
Nominatim database. You can find the user like
|
||||
[this](https://serverfault.com/questions/125865/finding-out-what-user-apache-is-running-as),
|
||||
for default Ubuntu operating system for example it's `www-data`.
|
||||
|
||||
1. Repeat the `createuser` step of the installation instructions.
|
||||
|
||||
@@ -118,9 +170,10 @@ Example error message
|
||||
CONTEXT: PL/pgSQL function make_standard_name(text) line 5 at assignment]
|
||||
```
|
||||
|
||||
The Postgresql database, i.e. user postgres, needs to have access to that file.
|
||||
The PostgreSQL database, i.e. user `postgres`, needs to have access to that file.
|
||||
|
||||
The permission need to be read & executable by everybody, e.g.
|
||||
The permission need to be read & executable by everybody, but not writeable
|
||||
by everybody, e.g.
|
||||
|
||||
```
|
||||
-rwxr-xr-x 1 nominatim nominatim 297984 build/module/nominatim.so
|
||||
@@ -131,55 +184,31 @@ Try `chmod a+r nominatim.so; chmod a+x nominatim.so`.
|
||||
When running SELinux, make sure that the
|
||||
[context is set up correctly](../appendix/Install-on-Centos-7/#adding-selinux-security-settings).
|
||||
|
||||
When you recently updated your operating system, updated PostgreSQL to
|
||||
a new version or moved files (e.g. the build directory) you should
|
||||
recreate `nominatim.so`. Try
|
||||
|
||||
```
|
||||
cd build
|
||||
rm -r module/
|
||||
cmake $main_Nominatim_path && make
|
||||
```
|
||||
|
||||
### Setup.php fails with "DB Error: extension not found"
|
||||
|
||||
Make sure you have the Postgres extensions hstore and postgis installed.
|
||||
See the installation instruction for a full list of required packages.
|
||||
Make sure you have the PostgreSQL extensions "hstore" and "postgis" installed.
|
||||
See the installation instructions for a full list of required packages.
|
||||
|
||||
|
||||
### Setup.php reports "Cannot redeclare getDB()"
|
||||
|
||||
`Cannot redeclare getDB() (previously declared in /your/path/Nominatim/lib/db.php:4)`
|
||||
|
||||
The message is a bit misleading as PHP needs to load the file `DB.php` and
|
||||
instead re-loads Nominatim's `db.php`. To solve this make sure you
|
||||
have the [Pear module 'DB'](http://pear.php.net/package/DB/) installed.
|
||||
|
||||
sudo pear install DB
|
||||
|
||||
### I forgot to delete the flatnodes file before starting an import.
|
||||
|
||||
That's fine. For each import the flatnodes file get overwritten.
|
||||
See [https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage]()
|
||||
See [https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage](https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage)
|
||||
for more information.
|
||||
|
||||
|
||||
## Running your own instance
|
||||
|
||||
### Can I import multiple countries and keep them up to date?
|
||||
|
||||
You should use the extracts and updates from https://download.geofabrik.de.
|
||||
For the initial import, download the countries you need and merge them.
|
||||
See [OSM Help](https://help.openstreetmap.org/questions/48843/merging-two-or-more-geographical-areas-to-import-two-or-more-osm-files-in-nominatim)
|
||||
for examples how to do that. Use the resulting single osm file when
|
||||
running `setup.php`.
|
||||
|
||||
For updates you need to download the change files for each country
|
||||
once per day and apply them **separately** using
|
||||
|
||||
./utils/update.php --import-diff <filename> --index
|
||||
|
||||
See [this issue](https://github.com/openstreetmap/Nominatim/issues/60#issuecomment-18679446)
|
||||
for a script that runs the updates using osmosis.
|
||||
|
||||
### Can I import negative OSM ids into Nominatim?
|
||||
|
||||
See [this question of Stackoverflow](https://help.openstreetmap.org/questions/64662/nominatim-flatnode-with-negative-id).
|
||||
|
||||
### Missing XML or text declaration
|
||||
|
||||
The website might show: `XML Parsing Error: XML or text declaration not at start of entity Location.`
|
||||
|
||||
Make sure there are no spaces at the beginning of your `settings/local.php` file.
|
||||
|
||||
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
# Importing and Updating the Database
|
||||
|
||||
The following instructions explain how to create a Nominatim database
|
||||
from an OSM planet file and how to keep the database up to date. It
|
||||
is assumed that you have already successfully installed the Nominatim
|
||||
software itself, if not return to the [installation page](Installation.md).
|
||||
|
||||
## Configuration setup in settings/local.php
|
||||
|
||||
The Nominatim server can be customized via the file `settings/local.php`
|
||||
in the build directory. Note that this is a PHP file, so it must always
|
||||
start like this:
|
||||
|
||||
<?php
|
||||
|
||||
without any leading spaces.
|
||||
|
||||
There are lots of configuration settings you can tweak. Have a look
|
||||
at `settings/default.php` for a full list. Most should have a sensible default.
|
||||
|
||||
#### Flatnode files
|
||||
|
||||
If you plan to import a large dataset (e.g. Europe, North America, planet),
|
||||
you should also enable flatnode storage of node locations. With this
|
||||
setting enabled, node coordinates are stored in a simple file instead
|
||||
of the database. This will save you import time and disk storage.
|
||||
Add to your `settings/local.php`:
|
||||
|
||||
@define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
|
||||
|
||||
Replace the second part with a suitable path on your system and make sure
|
||||
the directory exists. There should be at least 40GB of free space.
|
||||
|
||||
## Downloading additional data
|
||||
|
||||
### Wikipedia rankings
|
||||
|
||||
Wikipedia can be used as an optional auxiliary data source to help indicate
|
||||
the importance of osm features. Nominatim will work without this information
|
||||
but it will improve the quality of the results if this is installed.
|
||||
This data is available as a binary download:
|
||||
|
||||
cd $NOMINATIM_SOURCE_DIR/data
|
||||
wget https://www.nominatim.org/data/wikipedia_article.sql.bin
|
||||
wget https://www.nominatim.org/data/wikipedia_redirect.sql.bin
|
||||
|
||||
Combined the 2 files are around 1.5GB and add around 30GB to the install
|
||||
size of nominatim. They also increase the install time by an hour or so.
|
||||
|
||||
*NOTE:* you'll need to download the Wikipedia rankings before performing
|
||||
the initial import of the data if you want the rankings applied to the
|
||||
loaded data.
|
||||
|
||||
### UK postcodes
|
||||
|
||||
Nominatim can use postcodes from an external source to improve searches that involve a UK postcode. This data can be optionally downloaded:
|
||||
|
||||
cd $NOMINATIM_SOURCE_DIR/data
|
||||
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
|
||||
|
||||
|
||||
## Initial import of the data
|
||||
|
||||
**Important:** first try the import with a small excerpt, for example from
|
||||
[Geofabrik](https://download.geofabrik.de).
|
||||
|
||||
Download the data to import and load the data with the following command:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --osm-file <data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log
|
||||
```
|
||||
|
||||
The `--osm2pgsql-cache` parameter is optional but strongly recommended for
|
||||
planet imports. It sets the node cache size for the osm2pgsql import part
|
||||
(see `-C` parameter in osm2pgsql help). As a rule of thumb, this should be
|
||||
about the same size as the file you are importing but never more than
|
||||
2/3 of RAM available. If your machine starts swapping reduce the size.
|
||||
|
||||
Computing word frequency for search terms can improve the performance of
|
||||
forward geocoding in particular under high load as it helps Postgres' query
|
||||
planner to make the right decisions. To recompute word counts run:
|
||||
|
||||
```sh
|
||||
./utils/update.php --recompute-word-counts
|
||||
```
|
||||
|
||||
This will take a couple of hours for a full planet installation. You can
|
||||
also defer that step to a later point in time when you realise that
|
||||
performance becomes an issue. Just make sure that updates are stopped before
|
||||
running this function.
|
||||
|
||||
If you want to be able to search for places by their type through
|
||||
[special key phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
||||
you also need to enable these key phrases like this:
|
||||
|
||||
./utils/specialphrases.php --wiki-import > specialphrases.sql
|
||||
psql -d nominatim -f specialphrases.sql
|
||||
|
||||
Note that this command downloads the phrases from the wiki link above.
|
||||
|
||||
|
||||
## Installing Tiger housenumber data for the US
|
||||
|
||||
Nominatim is able to use the official TIGER address set to complement the
|
||||
OSM house number data in the US. You can add TIGER data to your own Nominatim
|
||||
instance by following these steps:
|
||||
|
||||
1. Install the GDAL library and python bindings and the unzip tool
|
||||
|
||||
* Ubuntu: `sudo apt-get install python-gdal unzip`
|
||||
* CentOS: `sudo yum install gdal-python unzip`
|
||||
|
||||
2. Get preprocessed TIGER 2017 data and unpack it into the
|
||||
data directory in your Nominatim sources:
|
||||
|
||||
cd Nominatim/data
|
||||
wget https://nominatim.org/data/tiger2017-nominatim-preprocessed.tar.gz
|
||||
tar xf tiger2017-nominatim-preprocessed.tar.gz
|
||||
|
||||
3. Import the data into your Nominatim database:
|
||||
|
||||
./utils/setup.php --import-tiger-data
|
||||
|
||||
4. Enable use of the Tiger data in your `settings/local.php` by adding:
|
||||
|
||||
@define('CONST_Use_US_Tiger_Data', true);
|
||||
|
||||
5. Apply the new settings:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
|
||||
```
|
||||
|
||||
The entire US adds about 10GB to your database.
|
||||
|
||||
You can also process the data from the original TIGER data to create the
|
||||
SQL files, Nominatim needs for the import:
|
||||
|
||||
1. Get the TIGER 2017 data. You will need the EDGES files
|
||||
(3,234 zip files, 11GB total).
|
||||
|
||||
wget -r ftp://ftp2.census.gov/geo/tiger/TIGER2017/EDGES/
|
||||
|
||||
2. Convert the data into SQL statements:
|
||||
|
||||
./utils/imports.php --parse-tiger <tiger edge data directory>
|
||||
|
||||
Be warned that this can take quite a long time. After this process is finished,
|
||||
the same preprocessed files as above are available in `data/tiger`.
|
||||
|
||||
## Updates
|
||||
|
||||
There are many different possibilities to update your Nominatim database.
|
||||
The following section describes how to keep it up-to-date with Pyosmium.
|
||||
For a list of other methods see the output of `./utils/update.php --help`.
|
||||
|
||||
#### Installing the newest version of Pyosmium
|
||||
|
||||
It is recommended to install Pyosmium via pip. Run (as the same user who
|
||||
will later run the updates):
|
||||
|
||||
```sh
|
||||
pip install --user osmium
|
||||
```
|
||||
|
||||
Nominatim needs a tool called `pyosmium-get-updates`, which comes with
|
||||
Pyosmium. You need to tell Nominatim where to find it. Add the
|
||||
following line to your `settings/local.php`:
|
||||
|
||||
@define('CONST_Pyosmium_Binary', '/home/user/.local/bin/pyosmium-get-changes');
|
||||
|
||||
The path above is fine if you used the `--user` parameter with pip.
|
||||
Replace `user` with your user name.
|
||||
|
||||
#### Setting up the update process
|
||||
|
||||
Next the update needs to be initialised. By default Nominatim is configured
|
||||
to update using the global minutely diffs.
|
||||
|
||||
If you want a different update source you will need to add some settings
|
||||
to `settings/local.php`. For example, to use the daily country extracts
|
||||
diffs for Ireland from geofabrik add the following:
|
||||
|
||||
// base URL of the replication service
|
||||
@define('CONST_Replication_Url', 'https://download.geofabrik.de/europe/ireland-and-northern-ireland-updates');
|
||||
// How often upstream publishes diffs
|
||||
@define('CONST_Replication_Update_Interval', '86400');
|
||||
// How long to sleep if no update found yet
|
||||
@define('CONST_Replication_Recheck_Interval', '900');
|
||||
|
||||
To set up the update process now run the following command:
|
||||
|
||||
./utils/update.php --init-updates
|
||||
|
||||
It outputs the date where updates will start. Recheck that this date is
|
||||
what you expect.
|
||||
|
||||
The --init-updates command needs to be rerun whenever the replication service
|
||||
is changed.
|
||||
|
||||
#### Updating Nominatim
|
||||
|
||||
The following command will keep your database constantly up to date:
|
||||
|
||||
./utils/update.php --import-osmosis-all
|
||||
|
||||
(Note that even though the old name "import-osmosis-all" has been kept for compatibility reasons, Osmosis is not required to run this - it uses pyosmium behind the scenes.)
|
||||
|
||||
If you have imported multiple country extracts and want to keep them
|
||||
up-to-date, have a look at the script in
|
||||
[issue #60](https://github.com/openstreetmap/Nominatim/issues/60).
|
||||
|
||||
306
docs/admin/Import.md
Normal file
306
docs/admin/Import.md
Normal file
@@ -0,0 +1,306 @@
|
||||
# Importing the Database
|
||||
|
||||
The following instructions explain how to create a Nominatim database
|
||||
from an OSM planet file. It is assumed that you have already successfully
|
||||
installed the Nominatim software itself and the `nominatim` tool can be found
|
||||
in your `PATH`. If this is not the case, return to the
|
||||
[installation page](Installation.md).
|
||||
|
||||
## Creating the project directory
|
||||
|
||||
Before you start the import, you should create a project directory for your
|
||||
new database installation. This directory receives all data that is related
|
||||
to a single Nominatim setup: configuration, extra data, etc. Create a project
|
||||
directory apart from the Nominatim software and change into the directory:
|
||||
|
||||
```
|
||||
mkdir ~/nominatim-planet
|
||||
cd ~/nominatim-planet
|
||||
```
|
||||
|
||||
In the following, we refer to the project directory as `$PROJECT_DIR`. To be
|
||||
able to copy&paste instructions, you can export the appropriate variable:
|
||||
|
||||
```
|
||||
export PROJECT_DIR=~/nominatim-planet
|
||||
```
|
||||
|
||||
The Nominatim tool assumes per default that the current working directory is
|
||||
the project directory but you may explicitly state a different directory using
|
||||
the `--project-dir` parameter. The following instructions assume that you run
|
||||
all commands from the project directory.
|
||||
|
||||
!!! tip "Migration Tip"
|
||||
|
||||
Nominatim used to be run directly from the build directory until version 3.6.
|
||||
Essentially, the build directory functioned as the project directory
|
||||
for the database installation. This setup still works and can be useful for
|
||||
development purposes. It is not recommended anymore for production setups.
|
||||
Create a project directory that is separate from the Nominatim software.
|
||||
|
||||
### Configuration setup in `.env`
|
||||
|
||||
The Nominatim server can be customized via an `.env` configuration file in the
|
||||
project directory. This is a file in [dotenv](https://github.com/theskumar/python-dotenv)
|
||||
format which looks the same as variable settings in a standard shell environment.
|
||||
You can also set the same configuration via environment variables. All
|
||||
settings have a `NOMINATIM_` prefix to avoid conflicts with other environment
|
||||
variables.
|
||||
|
||||
There are lots of configuration settings you can tweak. Have a look
|
||||
at `settings/env.default` for a full list. Most should have a sensible default.
|
||||
|
||||
#### Flatnode files
|
||||
|
||||
If you plan to import a large dataset (e.g. Europe, North America, planet),
|
||||
you should also enable flatnode storage of node locations. With this
|
||||
setting enabled, node coordinates are stored in a simple file instead
|
||||
of the database. This will save you import time and disk storage.
|
||||
Add to your `.env`:
|
||||
|
||||
NOMINATIM_FLATNODE_FILE="/path/to/flatnode.file"
|
||||
|
||||
Replace the second part with a suitable path on your system and make sure
|
||||
the directory exists. There should be at least 75GB of free space.
|
||||
|
||||
## Downloading additional data
|
||||
|
||||
### Wikipedia/Wikidata rankings
|
||||
|
||||
Wikipedia can be used as an optional auxiliary data source to help indicate
|
||||
the importance of OSM features. Nominatim will work without this information
|
||||
but it will improve the quality of the results if this is installed.
|
||||
This data is available as a binary download. Put it into your project directory:
|
||||
|
||||
cd $PROJECT_DIR
|
||||
wget https://www.nominatim.org/data/wikimedia-importance.sql.gz
|
||||
|
||||
The file is about 400MB and adds around 4GB to the Nominatim database.
|
||||
|
||||
!!! tip
|
||||
If you forgot to download the wikipedia rankings, you can also add
|
||||
importances after the import. Download the files, then run
|
||||
`nominatim refresh --wiki-data --importance`. Updating importances for
|
||||
a planet can take a couple of hours.
|
||||
|
||||
### Great Britain, USA postcodes
|
||||
|
||||
Nominatim can use postcodes from an external source to improve searches that
|
||||
involve a GB or US postcode. This data can be optionally downloaded into the
|
||||
project directory:
|
||||
|
||||
cd $PROJECT_DIR
|
||||
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
|
||||
wget https://www.nominatim.org/data/us_postcode_data.sql.gz
|
||||
|
||||
## Choosing the data to import
|
||||
|
||||
In its default setup Nominatim is configured to import the full OSM data
|
||||
set for the entire planet. Such a setup requires a powerful machine with
|
||||
at least 64GB of RAM and around 900GB of SSD hard disks. Depending on your
|
||||
use case there are various ways to reduce the amount of data imported. This
|
||||
section discusses these methods. They can also be combined.
|
||||
|
||||
### Using an extract
|
||||
|
||||
If you only need geocoding for a smaller region, then precomputed OSM extracts
|
||||
are a good way to reduce the database size and import time.
|
||||
[Geofabrik](https://download.geofabrik.de) offers extracts for most countries.
|
||||
They even have daily updates which can be used with the update process described
|
||||
[in the next section](../Update). There are also
|
||||
[other providers for extracts](https://wiki.openstreetmap.org/wiki/Planet.osm#Downloading).
|
||||
|
||||
Please be aware that some extracts are not cut exactly along the country
|
||||
boundaries. As a result some parts of the boundary may be missing which means
|
||||
that Nominatim cannot compute the areas for some administrative areas.
|
||||
|
||||
### Dropping Data Required for Dynamic Updates
|
||||
|
||||
About half of the data in Nominatim's database is not really used for serving
|
||||
the API. It is only there to allow the data to be updated from the latest
|
||||
changes from OSM. For many uses these dynamic updates are not really required.
|
||||
If you don't plan to apply updates, you can run the import with the
|
||||
`--no-updates` parameter. This will drop the dynamic part of the database as
|
||||
soon as it is not required anymore.
|
||||
|
||||
You can also drop the dynamic part later using the following command:
|
||||
|
||||
```
|
||||
nominatim freeze
|
||||
```
|
||||
|
||||
Note that you still need to provide for sufficient disk space for the initial
|
||||
import. So this option is particularly interesting if you plan to transfer the
|
||||
database or reuse the space later.
|
||||
|
||||
### Reverse-only Imports
|
||||
|
||||
If you only want to use the Nominatim database for reverse lookups or
|
||||
if you plan to use the installation only for exports to a
|
||||
[photon](https://photon.komoot.de/) database, then you can set up a database
|
||||
without search indexes. Add `--reverse-only` to your setup command above.
|
||||
|
||||
This saves about 5% of disk space.
|
||||
|
||||
### Filtering Imported Data
|
||||
|
||||
Nominatim normally sets up a full search database containing administrative
|
||||
boundaries, places, streets, addresses and POI data. There are also other
|
||||
import styles available which only read selected data:
|
||||
|
||||
* **settings/import-admin.style**
|
||||
Only import administrative boundaries and places.
|
||||
* **settings/import-street.style**
|
||||
Like the admin style but also adds streets.
|
||||
* **settings/import-address.style**
|
||||
Import all data necessary to compute addresses down to house number level.
|
||||
* **settings/import-full.style**
|
||||
Default style that also includes points of interest.
|
||||
* **settings/import-extratags.style**
|
||||
Like the full style but also adds most of the OSM tags into the extratags
|
||||
column.
|
||||
|
||||
The style can be changed with the configuration `NOMINATIM_IMPORT_STYLE`.
|
||||
|
||||
To give you an idea of the impact of using the different styles, the table
|
||||
below gives rough estimates of the final database size after import of a
|
||||
2020 planet and after using the `--drop` option. It also shows the time
|
||||
needed for the import on a machine with 64GB RAM, 4 CPUS and NVME disks.
|
||||
Note that the given sizes are just an estimate meant for comparison of
|
||||
style requirements. Your planet import is likely to be larger as the
|
||||
OSM data grows with time.
|
||||
|
||||
style | Import time | DB size | after drop
|
||||
----------|--------------|------------|------------
|
||||
admin | 4h | 215 GB | 20 GB
|
||||
street | 22h | 440 GB | 185 GB
|
||||
address | 36h | 545 GB | 260 GB
|
||||
full | 54h | 640 GB | 330 GB
|
||||
extratags | 54h | 650 GB | 340 GB
|
||||
|
||||
You can also customize the styles further.
|
||||
A [description of the style format](../develop/Import.md#configuring-the-import)
|
||||
can be found in the development section.
|
||||
|
||||
## Initial import of the data
|
||||
|
||||
!!! danger "Important"
|
||||
First try the import with a small extract, for example from
|
||||
[Geofabrik](https://download.geofabrik.de).
|
||||
|
||||
Download the data to import. Then issue the following command
|
||||
from the **build directory** to start the import:
|
||||
|
||||
```sh
|
||||
nominatim import --osm-file <data file> 2>&1 | tee setup.log
|
||||
```
|
||||
|
||||
### Notes on full planet imports
|
||||
|
||||
Even on a perfectly configured machine
|
||||
the import of a full planet takes around 2 days. Once you see messages
|
||||
with `Rank .. ETA` appear, the indexing process has started. This part takes
|
||||
the most time. There are 30 ranks to process. Rank 26 and 30 are the most complex.
|
||||
They take each about a third of the total import time. If you have not reached
|
||||
rank 26 after two days of import, it is worth revisiting your system
|
||||
configuration as it may not be optimal for the import.
|
||||
|
||||
### Notes on memory usage
|
||||
|
||||
In the first step of the import Nominatim uses [osm2pgsql](https://osm2pgsql.org)
|
||||
to load the OSM data into the PostgreSQL database. This step is very demanding
|
||||
in terms of RAM usage. osm2pgsql and PostgreSQL are running in parallel at
|
||||
this point. PostgreSQL blocks at least the part of RAM that has been configured
|
||||
with the `shared_buffers` parameter during
|
||||
[PostgreSQL tuning](Installation#postgresql-tuning)
|
||||
and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
|
||||
its internal data structures, potentially more when it has to process very large
|
||||
relations. In addition it needs to maintain a cache for node locations. The size
|
||||
of this cache can be configured with the parameter `--osm2pgsql-cache`.
|
||||
|
||||
When importing with a flatnode file, it is best to disable the node cache
|
||||
completely and leave the memory for the flatnode file. Nominatim will do this
|
||||
by default, so you do not need to configure anything in this case.
|
||||
|
||||
For imports without a flatnode file, set `--osm2pgsql-cache` approximately to
|
||||
the size of the OSM pbf file you are importing. The size needs to be given in
|
||||
MB. Make sure you leave enough RAM for PostgreSQL and osm2pgsql as mentioned
|
||||
above. If the system starts swapping or you are getting out-of-memory errors,
|
||||
reduce the cache size or even consider using a flatnode file.
|
||||
|
||||
|
||||
### Testing the installation
|
||||
|
||||
Run this script to verify all required tables and indices got created successfully.
|
||||
|
||||
```sh
|
||||
nominatim admin --check-database
|
||||
```
|
||||
|
||||
Now you can try out your installation by running:
|
||||
|
||||
```sh
|
||||
nominatim 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
|
||||
planner to make the right decisions. Recomputing them can improve the performance
|
||||
of forward geocoding in particular under high load. To recompute word counts run:
|
||||
|
||||
```sh
|
||||
nominatim refresh --word-counts
|
||||
```
|
||||
|
||||
This will take a couple of hours for a full planet installation. You can
|
||||
also defer that step to a later point in time when you realise that
|
||||
performance becomes an issue. Just make sure that updates are stopped before
|
||||
running this function.
|
||||
|
||||
If you want to be able to search for places by their type through
|
||||
[special key phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
||||
you also need to import these key phrases like this:
|
||||
|
||||
nominatim special-phrases --import-from-wiki
|
||||
|
||||
Note that this command downloads the phrases from the wiki link above. You
|
||||
need internet access for the step.
|
||||
|
||||
|
||||
## Installing Tiger housenumber data for the US
|
||||
|
||||
Nominatim is able to use the official [TIGER](https://www.census.gov/geographies/mapping-files/time-series/geo/tiger-line-file.html)
|
||||
address set to complement the OSM house number data in the US. You can add
|
||||
TIGER data to your own Nominatim instance by following these steps. The
|
||||
entire US adds about 10GB to your database.
|
||||
|
||||
1. Get preprocessed TIGER 2020 data:
|
||||
|
||||
cd $PROJECT_DIR
|
||||
wget https://nominatim.org/data/tiger2020-nominatim-preprocessed.tar.gz
|
||||
|
||||
2. Import the data into your Nominatim database:
|
||||
|
||||
nominatim add-data --tiger-data tiger2020-nominatim-preprocessed.tar.gz
|
||||
|
||||
3. Enable use of the Tiger data in your `.env` by adding:
|
||||
|
||||
echo NOMINATIM_USE_US_TIGER_DATA=yes >> .env
|
||||
|
||||
4. Apply the new settings:
|
||||
|
||||
nominatim refresh --functions
|
||||
|
||||
|
||||
See the [developer's guide](../develop/data-sources.md#us-census-tiger) for more
|
||||
information on how the data got preprocessed.
|
||||
|
||||
@@ -4,8 +4,9 @@ This page contains generic installation instructions for Nominatim and its
|
||||
prerequisites. There are also step-by-step instructions available for
|
||||
the following operating systems:
|
||||
|
||||
* [Ubuntu 20.04](../appendix/Install-on-Ubuntu-20.md)
|
||||
* [Ubuntu 18.04](../appendix/Install-on-Ubuntu-18.md)
|
||||
* [Ubuntu 16.04](../appendix/Install-on-Ubuntu-16.md)
|
||||
* [CentOS 8](../appendix/Install-on-Centos-8.md)
|
||||
* [CentOS 7.2](../appendix/Install-on-Centos-7.md)
|
||||
|
||||
These OS-specific instructions can also be found in executable form
|
||||
@@ -25,65 +26,80 @@ and can't offer support.
|
||||
For compiling:
|
||||
|
||||
* [cmake](https://cmake.org/)
|
||||
* [libxml2](http://xmlsoft.org/)
|
||||
* a recent C++ compiler
|
||||
|
||||
Nominatim comes with its own version of osm2pgsql. See the
|
||||
osm2pgsql README for additional dependencies required for compiling osm2pgsql.
|
||||
|
||||
For running tests:
|
||||
|
||||
* [behave](http://pythonhosted.org/behave/)
|
||||
* [Psycopg2](http://initd.org/psycopg)
|
||||
* [nose](https://nose.readthedocs.io)
|
||||
* [phpunit](https://phpunit.de)
|
||||
* [expat](https://libexpat.github.io/)
|
||||
* [proj](https://proj.org/)
|
||||
* [bzip2](http://www.bzip.org/)
|
||||
* [zlib](https://www.zlib.net/)
|
||||
* [ICU](http://site.icu-project.org/)
|
||||
* [Boost libraries](https://www.boost.org/), including system and filesystem
|
||||
* PostgreSQL client libraries
|
||||
* a recent C++ compiler (gcc 5+ or Clang 3.8+)
|
||||
|
||||
For running Nominatim:
|
||||
|
||||
* [PostgreSQL](http://www.postgresql.org) (9.1 or later)
|
||||
* [PostGIS](http://postgis.refractions.net) (2.0 or later)
|
||||
* [PHP](http://php.net) (5.4 or later)
|
||||
* [PostgreSQL](https://www.postgresql.org) (9.3+ will work, 11+ strongly recommended)
|
||||
* [PostGIS](https://postgis.net) (2.2+)
|
||||
* [Python 3](https://www.python.org/) (3.5+)
|
||||
* [Psycopg2](https://www.psycopg.org) (2.7+)
|
||||
* [Python Dotenv](https://github.com/theskumar/python-dotenv)
|
||||
* [psutil](https://github.com/giampaolo/psutil)
|
||||
* [Jinja2](https://palletsprojects.com/p/jinja/)
|
||||
* [PyICU](https://pypi.org/project/PyICU/)
|
||||
* [PHP](https://php.net) (7.0 or later)
|
||||
* PHP-pgsql
|
||||
* PHP-intl (bundled with PHP)
|
||||
* [PEAR::DB](http://pear.php.net/package/DB)
|
||||
* a webserver (apache or nginx are recommended)
|
||||
* PHP-cgi (for running queries from the command line)
|
||||
|
||||
For running continuous updates:
|
||||
|
||||
* [pyosmium](http://osmcode.org/pyosmium/)
|
||||
* [pyosmium](https://osmcode.org/pyosmium/)
|
||||
|
||||
For dependencies for running tests and building documentation, see
|
||||
the [Development section](../develop/Development-Environment.md).
|
||||
|
||||
### Hardware
|
||||
|
||||
A minimum of 2GB of RAM is required or installation will fail. For a full
|
||||
planet import 32GB of RAM or more strongly are recommended.
|
||||
planet import 64GB of RAM or more are strongly recommended. Do not report
|
||||
out of memory problems if you have less than 64GB RAM.
|
||||
|
||||
For a full planet install you will need at least 700GB of hard disk space
|
||||
(take into account that the OSM database is growing fast). SSD disks
|
||||
will help considerably to speed up import and queries.
|
||||
For a full planet install you will need at least 900GB of hard disk space.
|
||||
Take into account that the OSM database is growing fast.
|
||||
Fast disks are essential. Using NVME disks is recommended.
|
||||
|
||||
On a 6-core machine with 32GB RAM and SSDs the import of a full planet takes
|
||||
a bit more than 2 days. Without SSDs 7-8 days are more realistic.
|
||||
Even on a well configured machine the import of a full planet takes
|
||||
around 2 days. On traditional spinning disks, 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
|
||||
your `postgresql.conf` file.
|
||||
|
||||
shared_buffers (2GB)
|
||||
maintenance_work_mem (10GB)
|
||||
work_mem (50MB)
|
||||
effective_cache_size (24GB)
|
||||
shared_buffers = 2GB
|
||||
maintenance_work_mem = (10GB)
|
||||
autovacuum_work_mem = 2GB
|
||||
work_mem = (50MB)
|
||||
effective_cache_size = (24GB)
|
||||
synchronous_commit = off
|
||||
checkpoint_segments = 100 # only for postgresql <= 9.4
|
||||
max_wal_size = 1GB # postgresql > 9.4
|
||||
checkpoint_timeout = 10min
|
||||
checkpoint_completion_target = 0.9
|
||||
|
||||
The numbers in brackets behind some parameters seem to work fine for
|
||||
32GB RAM machine. Adjust to your setup.
|
||||
64GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
|
||||
means that PostgreSQL needs to run checkpoints less often but it does require
|
||||
the additional space on your disk.
|
||||
|
||||
Autovacuum must not be switched off because it ensures that the
|
||||
tables are frequently analysed. If your machine has very little memory,
|
||||
you might consider setting:
|
||||
|
||||
autovacuum_max_workers = 1
|
||||
|
||||
and even reduce `autovacuum_work_mem` further. This will reduce the amount
|
||||
of memory that autovacuum takes away from the import process.
|
||||
|
||||
For the initial import, you should also set:
|
||||
|
||||
@@ -91,68 +107,57 @@ For the initial import, you should also set:
|
||||
full_page_writes = off
|
||||
|
||||
Don't forget to reenable them after the initial import or you risk database
|
||||
corruption. Autovacuum must not be switched off because it ensures that the
|
||||
tables are frequently analysed.
|
||||
|
||||
### Webserver setup
|
||||
|
||||
The `website/` directory in the build directory contains the configured
|
||||
website. Include the directory into your webbrowser to serve php files
|
||||
from there.
|
||||
|
||||
#### Configure for use with Apache
|
||||
|
||||
Make sure your Apache configuration contains the required permissions for the
|
||||
directory and create an alias:
|
||||
|
||||
<Directory "/srv/nominatim/build/website">
|
||||
Options FollowSymLinks MultiViews
|
||||
AddType text/html .php
|
||||
DirectoryIndex search.php
|
||||
Require all granted
|
||||
</Directory>
|
||||
Alias /nominatim /srv/nominatim/build/website
|
||||
|
||||
`/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.
|
||||
|
||||
root /srv/nominatim/build/website;
|
||||
index search.php index.html;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
if (!-f $document_root$fastcgi_script_name) {
|
||||
return 404;
|
||||
}
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_index search.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
|
||||
Restart the nginx and php5-fpm services and the website should now be available
|
||||
at `http://localhost/`.
|
||||
corruption.
|
||||
|
||||
|
||||
Now continue with [importing the database](Import-and-Update.md).
|
||||
## Downloading and building Nominatim
|
||||
|
||||
### Downloading the latest release
|
||||
|
||||
You can download the [latest release from nominatim.org](https://nominatim.org/downloads/).
|
||||
The release contains all necessary files. Just unpack it.
|
||||
|
||||
### Downloading the latest development version
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
### 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
|
||||
sudo make install
|
||||
```
|
||||
|
||||
Nominatim installs itself into `/usr/local` per default. To choose a different
|
||||
installation directory add `-DCMAKE_INSTALL_PREFIX=<install root>` to the
|
||||
cmake command. Make sure that the `bin` directory is available in your path
|
||||
in that case, e.g.
|
||||
|
||||
```
|
||||
export PATH=<install root>/bin:$PATH
|
||||
```
|
||||
|
||||
Now continue with [importing the database](Import.md).
|
||||
|
||||
@@ -1,10 +1,212 @@
|
||||
# Database Migrations
|
||||
|
||||
This page describes database migrations necessary to update existing databases
|
||||
to newer versions of Nominatim.
|
||||
Since version 3.7.0 Nominatim offers automatic migrations. Please follow
|
||||
the following steps:
|
||||
|
||||
SQL statements should be executed from the postgres commandline. Execute
|
||||
`psql nominiatim` to enter command line mode.
|
||||
* stop any updates that are potentially running
|
||||
* update Nominatim to the newer version
|
||||
* go to your project directory and run `nominatim admin --migrate`
|
||||
* (optionally) restart updates
|
||||
|
||||
Below you find additional migrations and hints about other structural and
|
||||
breaking changes. **Please read them before running the migration.**
|
||||
|
||||
!!! note
|
||||
If you are migrating from a version <3.6, then you still have to follow
|
||||
the manual migration steps up to 3.6.
|
||||
|
||||
## 3.6.0 -> 3.7.0
|
||||
|
||||
### New location for data files
|
||||
|
||||
External data files for Wikipedia importance, postcodes etc. are no longer
|
||||
expected to reside in the source tree by default. Instead they will be searched
|
||||
in the project directory. If you have an automated setup script you must
|
||||
either adapt the download location or explicitly set the location of the
|
||||
files to the old place in your `.env`.
|
||||
|
||||
### Introducing `nominatim` command line tool
|
||||
|
||||
The various php utilities have been replaced with a single `nominatim`
|
||||
command line tool. Make sure to adapt any scripts. There is no direct 1:1
|
||||
matching between the old utilities and the commands of nominatim CLI. The
|
||||
following list gives you a list of nominatim sub-commands that contain
|
||||
functionality of each script:
|
||||
|
||||
* ./utils/setup.php: `import`, `freeze`, `refresh`
|
||||
* ./utils/update.php: `replication`, `add-data`, `index`, `refresh`
|
||||
* ./utils/specialphrases.php: `special-phrases`
|
||||
* ./utils/check_import_finished.php: `admin`
|
||||
* ./utils/warm.php: `admin`
|
||||
* ./utils/export.php: `export`
|
||||
|
||||
Try `nominatim <command> --help` for more information about each subcommand.
|
||||
|
||||
`./utils/query.php` no longer exists in its old form. `nominatim search`
|
||||
provides a replacement but returns different output.
|
||||
|
||||
### Switch to normalized house numbers
|
||||
|
||||
The housenumber column in the placex table uses now normalized version.
|
||||
The automatic migration step will convert the column but this may take a
|
||||
very long time. It is advisable to take the machine offline while doing that.
|
||||
|
||||
## 3.5.0 -> 3.6.0
|
||||
|
||||
### Change of layout of search_name_* tables
|
||||
|
||||
The table need a different index for nearest place lookup. Recreate the
|
||||
indexes using the following shell script:
|
||||
|
||||
```bash
|
||||
for table in `psql -d nominatim -c "SELECT tablename FROM pg_tables WHERE tablename LIKE 'search_name_%'" -tA | grep -v search_name_blank`;
|
||||
do
|
||||
psql -d nominatim -c "DROP INDEX idx_${table}_centroid_place; CREATE INDEX idx_${table}_centroid_place ON ${table} USING gist (centroid) WHERE ((address_rank >= 2) AND (address_rank <= 25)); DROP INDEX idx_${table}_centroid_street; CREATE INDEX idx_${table}_centroid_street ON ${table} USING gist (centroid) WHERE ((address_rank >= 26) AND (address_rank <= 27))";
|
||||
done
|
||||
```
|
||||
|
||||
### Removal of html output
|
||||
|
||||
The debugging UI is no longer directly provided with Nominatim. Instead we
|
||||
now provide a simple Javascript application. Please refer to
|
||||
[Setting up the Nominatim UI](../Setup-Nominatim-UI) for details on how to
|
||||
set up the UI.
|
||||
|
||||
The icons served together with the API responses have been moved to the
|
||||
nominatim-ui project as well. If you want to keep the `icon` field in the
|
||||
response, you need to set `CONST_MapIcon_URL` to the URL of the `/mapicon`
|
||||
directory of nominatim-ui.
|
||||
|
||||
### Change order during indexing
|
||||
|
||||
When reindexing places during updates, there is now a different order used
|
||||
which needs a different database index. Create it with the following SQL command:
|
||||
|
||||
```sql
|
||||
CREATE INDEX idx_placex_pendingsector_rank_address
|
||||
ON placex
|
||||
USING BTREE (rank_address, geometry_sector)
|
||||
WHERE indexed_status > 0;
|
||||
```
|
||||
|
||||
You can then drop the old index with:
|
||||
|
||||
```sql
|
||||
DROP INDEX idx_placex_pendingsector;
|
||||
```
|
||||
|
||||
### Unused index
|
||||
|
||||
This index has been unused ever since the query using it was changed two years ago. Saves about 12GB on a planet installation.
|
||||
|
||||
```sql
|
||||
DROP INDEX idx_placex_geometry_reverse_lookupPoint;
|
||||
```
|
||||
|
||||
### Switching to dotenv
|
||||
|
||||
As part of the work changing the configuration format, the configuration for
|
||||
the website is now using a separate configuration file. To create the
|
||||
configuration file, run the following command after updating:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --setup-website
|
||||
```
|
||||
|
||||
## 3.4.0 -> 3.5.0
|
||||
|
||||
### New Wikipedia/Wikidata importance tables
|
||||
|
||||
The `wikipedia_*` tables have a new format that also includes references to
|
||||
Wikidata. You need to update the computation functions and the tables as
|
||||
follows:
|
||||
|
||||
* download the new Wikipedia tables as described in the import section
|
||||
* reimport the tables: `./utils/setup.php --import-wikipedia-articles`
|
||||
* update the functions: `./utils/setup.php --create-functions --enable-diff-updates`
|
||||
* create a new lookup index:
|
||||
```sql
|
||||
CREATE INDEX idx_placex_wikidata
|
||||
ON placex
|
||||
USING BTREE ((extratags -> 'wikidata'))
|
||||
WHERE extratags ? 'wikidata'
|
||||
AND class = 'place'
|
||||
AND osm_type = 'N'
|
||||
AND rank_search < 26;
|
||||
```
|
||||
* compute importance: `./utils/update.php --recompute-importance`
|
||||
|
||||
The last step takes about 10 hours on the full planet.
|
||||
|
||||
Remove one function (it will be recreated in the next step):
|
||||
|
||||
```sql
|
||||
DROP FUNCTION create_country(hstore,character varying);
|
||||
```
|
||||
|
||||
Finally, update all SQL functions:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
|
||||
```
|
||||
|
||||
## 3.3.0 -> 3.4.0
|
||||
|
||||
### Reorganisation of location_area_country table
|
||||
|
||||
The table `location_area_country` has been optimized. You need to switch to the
|
||||
new format when you run updates. While updates are disabled, run the following
|
||||
SQL commands:
|
||||
|
||||
```sql
|
||||
CREATE TABLE location_area_country_new AS
|
||||
SELECT place_id, country_code, geometry FROM location_area_country;
|
||||
DROP TABLE location_area_country;
|
||||
ALTER TABLE location_area_country_new RENAME TO location_area_country;
|
||||
CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry);
|
||||
CREATE INDEX idx_location_area_country_place_id ON location_area_country USING BTREE (place_id);
|
||||
```
|
||||
|
||||
Finally, update all SQL functions:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
|
||||
```
|
||||
|
||||
## 3.2.0 -> 3.3.0
|
||||
|
||||
### New database connection string (DSN) format
|
||||
|
||||
Previously database connection setting (`CONST_Database_DSN` in `settings/*.php`) had the format
|
||||
|
||||
* (simple) `pgsql://@/nominatim`
|
||||
* (complex) `pgsql://johndoe:secret@machine1.domain.com:1234/db1`
|
||||
|
||||
The new format is
|
||||
|
||||
* (simple) `pgsql:dbname=nominatim`
|
||||
* (complex) `pgsql:dbname=db1;host=machine1.domain.com;port=1234;user=johndoe;password=secret`
|
||||
|
||||
### Natural Earth country boundaries no longer needed as fallback
|
||||
|
||||
```sql
|
||||
DROP TABLE country_naturalearthdata;
|
||||
```
|
||||
|
||||
Finally, update all SQL functions:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
|
||||
```
|
||||
|
||||
### Configurable Address Levels
|
||||
|
||||
The new configurable address levels require a new table. Create it with the
|
||||
following command:
|
||||
|
||||
```sh
|
||||
./utils/update.php --update-address-levels
|
||||
```
|
||||
|
||||
## 3.1.0 -> 3.2.0
|
||||
|
||||
@@ -13,38 +215,54 @@ SQL statements should be executed from the postgres commandline. Execute
|
||||
The reverse algorithm has changed and requires new indexes. Run the following
|
||||
SQL statements to create the indexes:
|
||||
|
||||
```
|
||||
```sql
|
||||
CREATE INDEX idx_placex_geometry_reverse_lookupPoint
|
||||
ON placex USING gist (geometry) {ts:search-index}
|
||||
WHERE (name is not null or housenumber is not null or rank_address between 26 and 27)
|
||||
AND class not in ('railway','tunnel','bridge','man_made')
|
||||
AND rank_address >= 26 AND indexed_status = 0 AND linked_place_id is null;
|
||||
ON placex
|
||||
USING gist (geometry)
|
||||
WHERE (name IS NOT null or housenumber IS NOT null or rank_address BETWEEN 26 AND 27)
|
||||
AND class NOT IN ('railway','tunnel','bridge','man_made')
|
||||
AND rank_address >= 26
|
||||
AND indexed_status = 0
|
||||
AND linked_place_id IS null;
|
||||
CREATE INDEX idx_placex_geometry_reverse_lookupPolygon
|
||||
ON placex USING gist (geometry) {ts:search-index}
|
||||
ON placex USING gist (geometry)
|
||||
WHERE St_GeometryType(geometry) in ('ST_Polygon', 'ST_MultiPolygon')
|
||||
AND rank_address between 4 and 25 AND type != 'postcode'
|
||||
AND name is not null AND indexed_status = 0 AND linked_place_id is null;
|
||||
AND rank_address between 4 and 25
|
||||
AND type != 'postcode'
|
||||
AND name is not null
|
||||
AND indexed_status = 0
|
||||
AND linked_place_id is null;
|
||||
CREATE INDEX idx_placex_geometry_reverse_placeNode
|
||||
ON placex USING gist (geometry) {ts:search-index}
|
||||
WHERE osm_type = 'N' AND rank_search between 5 and 25
|
||||
AND class = 'place' AND type != 'postcode'
|
||||
AND name is not null AND indexed_status = 0 AND linked_place_id is null;
|
||||
ON placex USING gist (geometry)
|
||||
WHERE osm_type = 'N'
|
||||
AND rank_search between 5 and 25
|
||||
AND class = 'place'
|
||||
AND type != 'postcode'
|
||||
AND name is not null
|
||||
AND indexed_status = 0
|
||||
AND linked_place_id is null;
|
||||
```
|
||||
|
||||
You also need to grant the website user access to the `country_osm_grid` table:
|
||||
|
||||
```
|
||||
```sql
|
||||
GRANT SELECT ON table country_osm_grid to "www-user";
|
||||
```
|
||||
|
||||
Replace the `www-user` with the user name of your website server if necessary.
|
||||
|
||||
Finally, you can drop the now unused indexes:
|
||||
You can now drop the unused indexes:
|
||||
|
||||
```
|
||||
```sql
|
||||
DROP INDEX idx_placex_reverse_geometry;
|
||||
```
|
||||
|
||||
Finally, update all SQL functions:
|
||||
|
||||
```sh
|
||||
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
|
||||
```
|
||||
|
||||
## 3.0.0 -> 3.1.0
|
||||
|
||||
### Postcode Table
|
||||
@@ -64,8 +282,8 @@ CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry);
|
||||
CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id);
|
||||
CREATE INDEX idx_postcode_postcode ON location_postcode USING BTREE (postcode);
|
||||
GRANT SELECT ON location_postcode TO "www-data";
|
||||
drop type if exists nearfeaturecentr cascade;
|
||||
create type nearfeaturecentr as (
|
||||
DROP TYPE IF EXISTS nearfeaturecentr CASCADE;
|
||||
CREATE TYPE nearfeaturecentr AS (
|
||||
place_id BIGINT,
|
||||
keywords int[],
|
||||
rank_address smallint,
|
||||
|
||||
185
docs/admin/Setup-Nominatim-UI.md
Normal file
185
docs/admin/Setup-Nominatim-UI.md
Normal file
@@ -0,0 +1,185 @@
|
||||
# Setting up the Nominatim UI
|
||||
|
||||
Nominatim is a search API, it does not provide a website interface on its
|
||||
own. [nominatim-ui](https://github.com/osm-search/nominatim-ui) offers a
|
||||
small website for testing your setup and inspecting the database content.
|
||||
|
||||
This section provides a quick start how to use nominatim-ui with your
|
||||
installation. For more details, please also have a look at the
|
||||
[README of nominatim-ui](https://github.com/osm-search/nominatim-ui/blob/master/README.md).
|
||||
|
||||
## Installing nominatim-ui
|
||||
|
||||
nominatim-ui does not need any special installation, just download, configure
|
||||
and run it.
|
||||
|
||||
Clone the source from github:
|
||||
|
||||
git clone https://github.com/osm-search/nominatim-ui
|
||||
|
||||
Copy the example configuration into the right place:
|
||||
|
||||
cd nominatim-ui
|
||||
cp dist/config.example.js dist/config.js
|
||||
|
||||
Now adapt the configuration to your needs. You need at least
|
||||
to change the `Nominatim_API_Endpoint` to point to your Nominatim installation.
|
||||
|
||||
Then you can just test it locally by spinning up a webserver in the `dist`
|
||||
directory. For example, with Python:
|
||||
|
||||
cd nominatim-ui/dist
|
||||
python3 -m http.server 8765
|
||||
|
||||
The website is now available at `http://localhost:8765`.
|
||||
|
||||
## Forwarding searches to nominatim-ui
|
||||
|
||||
Nominatim used to provide the search interface directly by itself when
|
||||
`format=html` was requested. For all endpoints except for `/reverse` and
|
||||
`/lookup` this even used to be the default.
|
||||
|
||||
The following section describes how to set up Apache or nginx, so that your
|
||||
users are forwarded to nominatim-ui when they go to URL that formerly presented
|
||||
the UI.
|
||||
|
||||
### Setting up forwarding in Nginx
|
||||
|
||||
First of all make nominatim-ui available under `/ui` on your webserver:
|
||||
|
||||
``` nginx
|
||||
server {
|
||||
|
||||
# Here is the Nominatim setup as described in the Installation section
|
||||
|
||||
location /ui/ {
|
||||
alias <full path to the nominatim-ui directory>/dist/;
|
||||
index index.html;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now we need to find out if a URL should be forwarded to the UI. Add the
|
||||
following `map` commands *outside* the server section:
|
||||
|
||||
``` nginx
|
||||
# Inspect the format parameter in the query arguments. We are interested
|
||||
# if it is set to html or something else or if it is missing completely.
|
||||
map $args $format {
|
||||
default default;
|
||||
~(^|&)format=html(&|$) html;
|
||||
~(^|&)format= other;
|
||||
}
|
||||
|
||||
# Determine from the URI and the format parameter above if forwarding is needed.
|
||||
map $uri/$format $forward_to_ui {
|
||||
default 1; # The default is to forward.
|
||||
~^/ui 0; # If the URI point to the UI already, we are done.
|
||||
~/other$ 0; # An explicit non-html format parameter. No forwarding.
|
||||
~/reverse.*/default 0; # Reverse and lookup assume xml format when
|
||||
~/lookup.*/default 0; # no format parameter is given. No forwarding.
|
||||
}
|
||||
```
|
||||
|
||||
The `$forward_to_ui` parameter can now be used to conditionally forward the
|
||||
calls:
|
||||
|
||||
```
|
||||
# When no endpoint is given, default to search.
|
||||
# Need to add a rewrite so that the rewrite rules below catch it correctly.
|
||||
rewrite ^/$ /search;
|
||||
|
||||
location @php {
|
||||
# fastcgi stuff..
|
||||
if ($forward_to_ui) {
|
||||
rewrite ^(/[^/]*) https://yourserver.com/ui$1.html redirect;
|
||||
}
|
||||
}
|
||||
|
||||
location ~ [^/]\.php(/|$) {
|
||||
# fastcgi stuff..
|
||||
if ($forward_to_ui) {
|
||||
rewrite (.*).php https://yourserver.com/ui$1.html redirect;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
!!! warning
|
||||
Be aware that the rewrite commands are slightly different for URIs with and
|
||||
without the .php suffix.
|
||||
|
||||
Reload nginx and the UI should be available.
|
||||
|
||||
### Setting up forwarding in Apache
|
||||
|
||||
First of all make nominatim-ui available in the `ui/` subdirectory where
|
||||
Nominatim is installed. For example, given you have set up an alias under
|
||||
`nominatim` like this:
|
||||
|
||||
``` apache
|
||||
Alias /nominatim /home/vagrant/build/website
|
||||
```
|
||||
|
||||
you need to insert the following rules for nominatim-ui before that alias:
|
||||
|
||||
```
|
||||
<Directory "/home/vagrant/nominatim-ui/dist">
|
||||
DirectoryIndex search.html
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
Alias /nominatim/ui /home/vagrant/nominatim-ui/dist
|
||||
```
|
||||
|
||||
Replace `/home/vagrant/nominatim-ui` with the directory where you have cloned
|
||||
nominatim-ui.
|
||||
|
||||
!!! important
|
||||
The alias for nominatim-ui must come before the alias for the Nominatim
|
||||
website directory.
|
||||
|
||||
To set up forwarding, the Apache rewrite module is needed. Enable it with:
|
||||
|
||||
``` sh
|
||||
sudo a2enmod rewrite
|
||||
```
|
||||
|
||||
Then add rewrite rules to the `Directory` directive of the Nominatim website
|
||||
directory like this:
|
||||
|
||||
``` apache
|
||||
<Directory "/home/vagrant/build/website">
|
||||
Options FollowSymLinks MultiViews
|
||||
AddType text/html .php
|
||||
Require all granted
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# This must correspond to the URL where nominatim can be found.
|
||||
RewriteBase "/nominatim/"
|
||||
|
||||
# If no endpoint is given, then use search.
|
||||
RewriteRule ^(/|$) "search.php"
|
||||
|
||||
# If format-html is explicity requested, forward to the UI.
|
||||
RewriteCond %{QUERY_STRING} "format=html"
|
||||
RewriteRule ^([^/]+).php ui/$1.html [R,END]
|
||||
# Same but .php suffix is missing.
|
||||
RewriteCond %{QUERY_STRING} "format=html"
|
||||
RewriteRule ^([^/]+) ui/$1.html [R,END]
|
||||
|
||||
# If no format parameter is there then forward anything
|
||||
# but /reverse and /lookup to the UI.
|
||||
RewriteCond %{QUERY_STRING} "!format="
|
||||
RewriteCond %{REQUEST_URI} "!/lookup"
|
||||
RewriteCond %{REQUEST_URI} "!/reverse"
|
||||
RewriteRule ^([^/]+).php ui/$1.html [R,END]
|
||||
# Same but .php suffix is missing.
|
||||
RewriteCond %{QUERY_STRING} "!format="
|
||||
RewriteCond %{REQUEST_URI} "!/lookup"
|
||||
RewriteCond %{REQUEST_URI} "!/reverse"
|
||||
RewriteRule ^([^/]+) ui/$1.html [R,END]
|
||||
</Directory>
|
||||
```
|
||||
|
||||
Restart Apache and the UI should be available.
|
||||
56
docs/admin/Update.md
Normal file
56
docs/admin/Update.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Updating the Database
|
||||
|
||||
There are many different ways to update your Nominatim database.
|
||||
The following section describes how to keep it up-to-date using
|
||||
an [online replication service for OpenStreetMap data](https://wiki.openstreetmap.org/wiki/Planet.osm/diffs)
|
||||
For a list of other methods to add or update data see the output of
|
||||
`nominatim add-data --help`.
|
||||
|
||||
!!! important
|
||||
If you have configured a flatnode file for the import, then you
|
||||
need to keep this flatnode file around for updates.
|
||||
|
||||
#### Installing the newest version of Pyosmium
|
||||
|
||||
It is recommended to install Pyosmium via pip. Make sure to use python3.
|
||||
Run (as the same user who will later run the updates):
|
||||
|
||||
```sh
|
||||
pip3 install --user osmium
|
||||
```
|
||||
|
||||
#### Setting up the update process
|
||||
|
||||
Next the update needs to be initialised. By default Nominatim is configured
|
||||
to update using the global minutely diffs.
|
||||
|
||||
If you want a different update source you will need to add some settings
|
||||
to `.env`. For example, to use the daily country extracts
|
||||
diffs for Ireland from Geofabrik add the following:
|
||||
|
||||
# base URL of the replication service
|
||||
NOMINATIM_REPLICATION_URL="https://download.geofabrik.de/europe/ireland-and-northern-ireland-updates"
|
||||
# How often upstream publishes diffs
|
||||
NOMINATIM_REPLICATION_UPDATE_INTERVAL=86400
|
||||
# How long to sleep if no update found yet
|
||||
NOMINATIM_REPLICATION_RECHECK_INTERVAL=900
|
||||
|
||||
To set up the update process now run the following command:
|
||||
|
||||
nominatim replication --init
|
||||
|
||||
It outputs the date where updates will start. Recheck that this date is
|
||||
what you expect.
|
||||
|
||||
The `replication --init` command needs to be rerun whenever the replication
|
||||
service is changed.
|
||||
|
||||
#### Updating Nominatim
|
||||
|
||||
The following command will keep your database constantly up to date:
|
||||
|
||||
nominatim replication
|
||||
|
||||
If you have imported multiple country extracts and want to keep them
|
||||
up-to-date, [Advanced installations section](Advanced-Installations.md) contains instructions
|
||||
to set up and update multiple country extracts.
|
||||
@@ -1,19 +1,22 @@
|
||||
# Place details
|
||||
|
||||
Lookup details about a single place by id. The default output is HTML for debugging search logic and results.
|
||||
Show all details about a single place saved in the database.
|
||||
|
||||
**The details page (including JSON output) exists for debugging only and must not be downloaded automatically**, see [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/).
|
||||
!!! warning
|
||||
The details page exists for debugging only. You may not use it in scripts
|
||||
or to automatically query details about a result.
|
||||
See [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/).
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
The details API supports the following two request formats:
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=<value>&class=<value>
|
||||
``` xml
|
||||
https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=<value>&class=<value>
|
||||
```
|
||||
|
||||
`osmtype` and `osmid` are required parameter. The type is one of node (N), way (W)
|
||||
`osmtype` and `osmid` are required parameters. The type is one of node (N), way (W)
|
||||
or relation (R). The id must be a number. The `class` parameter is optional and
|
||||
allows to distinguish between entries, when the corresponding OSM object has more
|
||||
than one main tag. For example, when a place is tagged with `tourism=hotel` and
|
||||
@@ -23,36 +26,34 @@ to get exactly the one you want. If there are multiple places in the database
|
||||
but the `class` parameter is left out, then one of the places will be chosen
|
||||
at random and displayed.
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/details?placeid=<value>
|
||||
``` xml
|
||||
https://nominatim.openstreetmap.org/details?place_id=<value>
|
||||
```
|
||||
|
||||
Placeids are assigned sequentially during Nominatim data import. The id for a place is different between Nominatim installation (servers) and changes when data gets reimported. Therefore it can't be used as permanent id and shouldn't be used in bug reports.
|
||||
Place IDs are assigned sequentially during Nominatim data import. The ID
|
||||
for a place is different between Nominatim installation (servers) and
|
||||
changes when data gets reimported. Therefore it cannot be used as
|
||||
a permanent id and shouldn't be used in bug reports.
|
||||
|
||||
|
||||
Additional optional parameters are explained below.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[html|json]`
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: html)
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap json output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
Only has an effect for JSON output formats.
|
||||
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
|
||||
* `pretty=[0|1]`
|
||||
|
||||
For JSON output will add indentation to make it more human-readable. (Default: 0)
|
||||
Add indentation to make it more human-readable. (Default: 0)
|
||||
|
||||
|
||||
### Output details
|
||||
|
||||
* `addressdetails=[0|1]`
|
||||
|
||||
Include a breakdown of the address into elements. (Default for JSON: 0, for HTML: 1)
|
||||
Include a breakdown of the address into elements. (Default: 0)
|
||||
|
||||
* `keywords=[0|1]`
|
||||
|
||||
@@ -60,11 +61,16 @@ Include a list of name keywords and address keywords (word ids). (Default: 0)
|
||||
|
||||
* `linkedplaces=[0|1]`
|
||||
|
||||
Include details of places higher in the address hierarchy. E.g. for a street this is usually the city, state, postal code, country. (Default: 1)
|
||||
Include a details of places that are linked with this one. Places get linked
|
||||
together when they are different forms of the same physical object. Nominatim
|
||||
links two kinds of objects together: place nodes get linked with the
|
||||
corresponding administrative boundaries. Waterway relations get linked together with their
|
||||
members.
|
||||
(Default: 1)
|
||||
|
||||
* `hierarchy=[0|1]`
|
||||
|
||||
Include details of places lower in the address hierarchy. E.g. for a city this usually a list of streets, suburbs, rivers. (Default for JSON: 0, for HTML: 1)
|
||||
Include details of places lower in the address hierarchy. (Default: 0)
|
||||
|
||||
* `group_hierarchy=[0|1]`
|
||||
|
||||
@@ -72,7 +78,7 @@ For JSON output will group the places by type. (Default: 0)
|
||||
|
||||
* `polygon_geojson=[0|1]`
|
||||
|
||||
Include geometry of result. (Default for JSON: 0, for HTML: 1)
|
||||
Include geometry of result. (Default: 0)
|
||||
|
||||
### Language of results
|
||||
|
||||
@@ -86,10 +92,6 @@ comma-separated list of language codes.
|
||||
|
||||
## Examples
|
||||
|
||||
##### HTML
|
||||
|
||||
[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407)
|
||||
|
||||
##### JSON
|
||||
|
||||
[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json)
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
Nominatim computes the address from two sources in the OpenStreetMap data:
|
||||
from administrative boundaries and from place nodes. Boundaries are the more
|
||||
useful source. They precisely describe an area. So it is very clear for
|
||||
Nominatim if a point belongs to an area of not. Place nodes are more complicated.
|
||||
These are only points without any precise extend. So Nominatim has to take a
|
||||
guess and assume that an address belongs to the closest place nose it can find.
|
||||
Nominatim if a point belongs to an area or not. Place nodes are more complicated.
|
||||
These are only points without any precise extent. So Nominatim has to take a
|
||||
guess and assume that an address belongs to the closest place node it can find.
|
||||
In an ideal world, Nominatim would not need the place nodes but there are
|
||||
many places on earth where there are not precise boundaries available for
|
||||
many places on earth where there are no precise boundaries available for
|
||||
all parts that make up an address. This is in particular true for the more
|
||||
local address parts, like villages and suburbs. Therefore it is not possible
|
||||
to completely dismiss place nodes. And sometimes they sneak in where they
|
||||
@@ -21,7 +21,7 @@ As a OpenStreetMap mapper, you can improve the situation in two ways: if you
|
||||
see a place node for which already an administrative area exists, then you
|
||||
should _link_ the two by adding the node with a 'label' role to the boundary
|
||||
relation. If there is no administrative area, you can add the approximate
|
||||
extend of the place and tag it place=<something> as well.
|
||||
extent of the place and tag it place=<something> as well.
|
||||
|
||||
#### 2. When doing reverse search, the address details have parts that don't contain the point I was looking up.
|
||||
|
||||
@@ -30,7 +30,7 @@ Reverse does not give you the address of the point you asked for. Reverse
|
||||
returns the closest object to the point you asked for and then returns the
|
||||
address of that object. Now, if you are close to a border, then the closest
|
||||
object may be across that border. When Nominatim then returns the address,
|
||||
contains the county/state/country across the border.
|
||||
it contains the county/state/country across the border.
|
||||
|
||||
#### 3. I get different counties/states/countries when I change the zoom parameter in the reverse query. How is that possible?
|
||||
|
||||
@@ -41,3 +41,21 @@ border while the closest street is on the other. As the address details contain
|
||||
the address of the closest object found, you might sometimes get one result,
|
||||
sometimes the other for the closest point.
|
||||
|
||||
#### 4. Can you return the continent?
|
||||
|
||||
Nominatim assigns each map feature one country. Those outside any administrative
|
||||
boundaries are assigned a special no-country. Continents or other super-national
|
||||
administrations (e.g. European Union, NATO, Custom unions) are not supported,
|
||||
see also [Administrative Boundary](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#Super-national_administrations).
|
||||
|
||||
#### 5. Can you return the timezone?
|
||||
|
||||
See this separate OpenStreetMap-based project [Timezone Boundary Builder](https://github.com/evansiroky/timezone-boundary-builder).
|
||||
|
||||
#### 6. I want to download a list of streets/restaurants of a city/region
|
||||
|
||||
The [Overpass API](https://wiki.openstreetmap.org/wiki/Overpass_API) is more
|
||||
suited for these kinds of queries.
|
||||
|
||||
That said if you installed your own Nominatim instance you can use the
|
||||
`nominatim export` PHP script as basis to return such lists.
|
||||
|
||||
@@ -19,13 +19,13 @@ Additional optional parameters are explained below.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[html|xml|json|jsonv2|geojson|geocodejson]`
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap json output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
Only has an effect for JSON output formats.
|
||||
|
||||
### Output details
|
||||
@@ -56,6 +56,21 @@ specified in the "Accept-Language" HTTP header.
|
||||
Either use a standard RFC2616 accept-language string or a simple
|
||||
comma-separated list of language codes.
|
||||
|
||||
### Polygon output
|
||||
|
||||
* `polygon_geojson=1`
|
||||
* `polygon_kml=1`
|
||||
* `polygon_svg=1`
|
||||
* `polygon_text=1`
|
||||
|
||||
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||
options can be used at a time. (Default: 0)
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
# Place Output
|
||||
|
||||
The [\reverse](Reverse.md), [\search](Search.md) and [\lookup](Lookup.md)
|
||||
The [/reverse](Reverse.md), [/search](Search.md) and [/lookup](Lookup.md)
|
||||
API calls produce very similar output which is explained in this section.
|
||||
There is one section for each format which is selectable via the `format`
|
||||
parameter.
|
||||
There is one section for each format. The format correspond to what was
|
||||
selected via the `format` parameter.
|
||||
|
||||
## Formats
|
||||
|
||||
### JSON
|
||||
## JSON
|
||||
|
||||
The JSON format returns an array of places (for search and lookup) or
|
||||
a single place (for reverse) of the following format:
|
||||
@@ -41,88 +39,87 @@ a single place (for reverse) of the following format:
|
||||
"wikipedia": "en:London",
|
||||
"population": "8416535"
|
||||
}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
The possible fields are:
|
||||
|
||||
* `place_id` - reference to the Nominatim internal database ID
|
||||
* `osm_type`, `osm_id` - reference to the OSM object
|
||||
* `boundingbox` - area of corner coordinates
|
||||
* `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id))
|
||||
* `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference))
|
||||
* `boundingbox` - area of corner coordinates ([see notes](#boundingbox))
|
||||
* `lat`, `lon` - latitude and longitude of the centroid of the object
|
||||
* `display_name` - full comma-separated address
|
||||
* `class`, `type` - key and value of the main OSM tag
|
||||
* `importance` - computed importance rank
|
||||
* `icon` - link to class icon (if available)
|
||||
* `address` - dictionary of address details (only with `addressdetails=1`)
|
||||
* `address` - dictionary of address details (only with `addressdetails=1`,
|
||||
[see notes](#addressdetails))
|
||||
* `extratags` - dictionary with additional useful tags like website or maxspeed
|
||||
(only with `extratags=1`)
|
||||
* `namedetails` - dictionary with full list of available names including ref etc.
|
||||
* `geojson`, `svg`, `geotext`, `geokml` - full geometry
|
||||
(only with the appropriate `polygon_*` parameter)
|
||||
|
||||
### JSONv2
|
||||
## JSONv2
|
||||
|
||||
This is the same as the JSON format with two changes:
|
||||
|
||||
* `class` renamed to `category`
|
||||
* additional field `place_rank` with the search rank of the object
|
||||
|
||||
### GeoJSON
|
||||
## GeoJSON
|
||||
|
||||
This format follows the [RFC7946](http://geojson.org). Every feature includes
|
||||
This format follows the [RFC7946](https://geojson.org). Every feature includes
|
||||
a bounding box (`bbox`).
|
||||
|
||||
The feature list has the following fields:
|
||||
The properties object has the following fields:
|
||||
|
||||
* `place_id` - reference to the Nominatim internal database ID
|
||||
* `osm_type`, `osm_id` - reference to the OSM object
|
||||
* `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id))
|
||||
* `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference))
|
||||
* `category`, `type` - key and value of the main OSM tag
|
||||
* `display_name` - full comma-separated address
|
||||
* `place_rank` - class search rank
|
||||
* `importance` - computed importance rank
|
||||
* `icon` - link to class icon (if available)
|
||||
* `address` - dictionary of address details (only with `addressdetails=1`)
|
||||
* `extratags` - dictionary with additional useful tags like website or maxspeed
|
||||
* `address` - dictionary of address details (only with `addressdetails=1`,
|
||||
[see notes](#addressdetails))
|
||||
* `extratags` - dictionary with additional useful tags like `website` or `maxspeed`
|
||||
(only with `extratags=1`)
|
||||
* `namedetails` - dictionary with full list of available names including ref etc.
|
||||
|
||||
Use `polygon_geojson` to output the full geometry of the object instead
|
||||
of the centroid.
|
||||
|
||||
### GeocodeJSON
|
||||
## GeocodeJSON
|
||||
|
||||
The GeocodeJSON format follows the
|
||||
[GeocodeJSON spec 0.1.0](https://github.com/geocoders/geocodejson-spec).
|
||||
The following feature attributes are implemented:
|
||||
|
||||
* `osm_type`, `osm_id` - reference to the OSM object (unofficial extension)
|
||||
* `osm_type`, `osm_id` - reference to the OSM object (unofficial extension, [see notes](#osm-reference))
|
||||
* `type` - value of the main tag of the object (e.g. residential, restaurant, ...)
|
||||
* `label` - full comma-separated address
|
||||
* `name` - localised name of the place
|
||||
* `housenumber`, `street`, `locality`, `postcode`, `city`,
|
||||
`district`, `county`, `state`, `country` -
|
||||
* `housenumber`, `street`, `locality`, `district`, `postcode`, `city`,
|
||||
`county`, `state`, `country` -
|
||||
provided when it can be determined from the address
|
||||
(see [this issue](https://github.com/openstreetmap/Nominatim/issues/1080) for
|
||||
current limitations on the correctness of the address) and `addressdetails=1`
|
||||
was given
|
||||
* `admin` - list of localised names of administrative boundaries (only with `addressdetails=1`)
|
||||
|
||||
Use `polygon_geojson` to output the full geometry of the object instead
|
||||
of the centroid.
|
||||
|
||||
### XML
|
||||
## XML
|
||||
|
||||
The XML response returns one or more place objects in slightly different
|
||||
formats depending on the API call.
|
||||
|
||||
#### Reverse
|
||||
### Reverse
|
||||
|
||||
```
|
||||
<reversegeocode timestamp="Sat, 11 Aug 18 11:53:21 +0000"
|
||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright"
|
||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright"
|
||||
querystring="lat=48.400381&lon=11.745876&zoom=5&format=xml">
|
||||
<result place_id="179509537" osm_type="relation" osm_id="2145268" ref="BY"
|
||||
<result place_id="179509537" osm_type="relation" osm_id="2145268" ref="BY" place_rank="15" address_rank="15"
|
||||
lat="48.9467562" lon="11.4038717"
|
||||
boundingbox="47.2701114,50.5647142,8.9763497,13.8396373">
|
||||
Bavaria, Germany
|
||||
@@ -148,28 +145,28 @@ attribution to OSM and the original querystring.
|
||||
|
||||
The place information can be found in the `result` element. The attributes of that element contain:
|
||||
|
||||
* `place_id` - reference to the Nominatim internal database ID
|
||||
* `osm_type`, `osm_id` - reference to the OSM object
|
||||
* `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id))
|
||||
* `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference))
|
||||
* `ref` - content of `ref` tag if it exists
|
||||
* `lat`, `lon` - latitude and longitude of the centroid of the object
|
||||
* `boundingbox` - comma-separated list of corner coordinates
|
||||
* `boundingbox` - comma-separated list of corner coordinates ([see notes](#boundingbox))
|
||||
|
||||
The full address address of the result can be found in the content of the
|
||||
The full address of the result can be found in the content of the
|
||||
`result` element as a comma-separated list.
|
||||
|
||||
Additional information requested with `addressdetails=1`, `extratags=1` and
|
||||
`namedetails=1` can be found in extra elements.
|
||||
|
||||
#### Search and Lookup
|
||||
### Search and Lookup
|
||||
|
||||
```
|
||||
<searchresults timestamp="Sat, 11 Aug 18 11:55:35 +0000"
|
||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright"
|
||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright"
|
||||
querystring="london" polygon="false" exclude_place_ids="100149"
|
||||
more_url="https://nominatim.openstreetmap.org/search.php?q=london&addressdetails=1&extratags=1&exclude_place_ids=100149&format=xml&accept-language=en-US%2Cen%3Bq%3D0.7%2Cde%3Bq%3D0.3">
|
||||
<place place_id="100149" osm_type="node" osm_id="107775" place_rank="15"
|
||||
<place place_id="100149" osm_type="node" osm_id="107775" place_rank="15" address_rank="15"
|
||||
boundingbox="51.3473219,51.6673219,-0.2876474,0.0323526" lat="51.5073219" lon="-0.1276474"
|
||||
display_name="London, Greater London, England, SW1A 2DU, United Kingdom"
|
||||
display_name="London, Greater London, England, SW1A 2DU, United Kingdom"
|
||||
class="place" type="city" importance="0.9654895765402"
|
||||
icon="https://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png">
|
||||
<extratags>
|
||||
@@ -203,12 +200,13 @@ generic information about the query:
|
||||
The place information can be found in the `place` elements, of which there may
|
||||
be more than one. The attributes of that element contain:
|
||||
|
||||
* `place_id` - reference to the Nominatim internal database ID
|
||||
* `osm_type`, `osm_id` - reference to the OSM object
|
||||
* `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id))
|
||||
* `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference))
|
||||
* `ref` - content of `ref` tag if it exists
|
||||
* `lat`, `lon` - latitude and longitude of the centroid of the object
|
||||
* `boundingbox` - comma-separated list of corner coordinates
|
||||
* `place_rank` - class search rank
|
||||
* `boundingbox` - comma-separated list of corner coordinates ([see notes](#boundingbox))
|
||||
* `place_rank` - class [search rank](../develop/Ranking#search-rank)
|
||||
* `address_rank` - place [address rank](../develop/Ranking#address-rank)
|
||||
* `display_name` - full comma-separated address
|
||||
* `class`, `type` - key and value of the main OSM tag
|
||||
* `importance` - computed importance rank
|
||||
@@ -218,5 +216,80 @@ When `addressdetails=1` is requested, the localised address parts appear
|
||||
as subelements with the type of the address part.
|
||||
|
||||
Additional information requested with `extratags=1` and `namedetails=1` can
|
||||
be found in extra elements as sub-element of each place.
|
||||
be found in extra elements as sub-element of `extratags` and `namedetails`
|
||||
respectively.
|
||||
|
||||
|
||||
## Notes on field values
|
||||
|
||||
### place_id is not a persistent id
|
||||
|
||||
The `place_id` is an internal identifier that is assigned data is imported
|
||||
into a Nominatim database. The same OSM object will have a different value
|
||||
on another server. It may even change its ID on the same server when it is
|
||||
removed and reimported while updating the database with fresh OSM data.
|
||||
It is thus not useful to treat it as permanent for later use.
|
||||
|
||||
The combination `osm_type`+`osm_id` is slighly better but remember in
|
||||
OpenStreetMap mappers can delete, split, recreate places (and those
|
||||
get a new `osm_id`), there is no link between those old and new ids.
|
||||
Places can also change their meaning without changing their `osm_id`,
|
||||
e.g. when a restaurant is retagged as supermarket. For a more in-depth
|
||||
discussion see [Permanent ID](https://wiki.openstreetmap.org/wiki/Permanent_ID).
|
||||
|
||||
If you need an ID that is consistent over multiple installations of Nominatim,
|
||||
then you should use the combination of `osm_type`+`osm_id`+`class`.
|
||||
|
||||
### OSM reference
|
||||
|
||||
Nominatim may sometimes return special objects that do not correspond directly
|
||||
to an object in OpenStreetMap. These are:
|
||||
|
||||
* **Postcodes**. Nominatim returns an postcode point created from all mapped
|
||||
postcodes of the same name. The class and type of these object is `place=postcdode`.
|
||||
No `osm_type` and `osm_id` are included in the result.
|
||||
* **Housenumber interpolations**. Nominatim returns a single interpolated
|
||||
housenumber from the interpolation way. The class and type are `place=house`
|
||||
and `osm_type` and `osm_id` correspond to the interpolation way in OSM.
|
||||
* **TIGER housenumber.** Nominatim returns a single interpolated housenumber
|
||||
from the TIGER data. The class and type are `place=house`
|
||||
and `osm_type` and `osm_id` correspond to the street mentioned in the result.
|
||||
|
||||
Please note that the `osm_type` and `osm_id` returned may be changed in the
|
||||
future. You should not expect to only find `node`, `way` and `relation` for
|
||||
the type.
|
||||
|
||||
### boundingbox
|
||||
|
||||
Comma separated list of min latitude, max latitude, min longitude, max longitude.
|
||||
The whole planet would be `-90,90,-180,180`.
|
||||
|
||||
Can be used to pan and center the map on the result, for example with leafletjs
|
||||
mapping library
|
||||
`map.fitBounds([[bbox[0],bbox[2]],[bbox[1],bbox[3]]], {padding: [20, 20], maxzoom: 16});`
|
||||
|
||||
Bounds crossing the antimeridian have a min latitude -180 and max latitude 180,
|
||||
essentially covering the entire planet
|
||||
(see [issue 184](https://github.com/openstreetmap/Nominatim/issues/184)).
|
||||
|
||||
### addressdetails
|
||||
|
||||
Address details in the xml and json formats return a list of names together
|
||||
with a designation label. Per default the following labels may appear:
|
||||
|
||||
* continent
|
||||
* country, country_code
|
||||
* region, state, state_district, county
|
||||
* municipality, city, town, village
|
||||
* city_district, district, borough, suburb, subdivision
|
||||
* hamlet, croft, isolated_dwelling
|
||||
* neighbourhood, allotments, quarter
|
||||
* city_block, residental, farm, farmyard, industrial, commercial, retail
|
||||
* road
|
||||
* house_number, house_name
|
||||
* emergency, historic, military, natural, landuse, place, railway,
|
||||
man_made, aerialway, boundary, amenity, aeroway, club, craft, leisure,
|
||||
office, mountain_pass, shop, tourism, bridge, tunnel, waterway
|
||||
|
||||
They roughly correspond to the classification of the OpenStreetMap data
|
||||
according to either the `place` tag or the main key of the object.
|
||||
|
||||
@@ -7,7 +7,7 @@ Its API has the following endpoints for querying the data:
|
||||
* __[/search](Search.md)__ - search OSM objects by name or type
|
||||
* __[/reverse](Reverse.md)__ - search OSM object by their location
|
||||
* __[/lookup](Lookup.md)__ - look up address details for OSM objects by their ID
|
||||
* __/status__ - query the status of the server
|
||||
* __[/status](Status.md)__ - query the status of the server
|
||||
* __/deletable__ - list objects that have been deleted in OSM but are held
|
||||
back in Nominatim in case the deletion was accidental
|
||||
* __/polygons__ - list of broken polygons detected by Nominatim
|
||||
|
||||
@@ -1,40 +1,52 @@
|
||||
# Reverse Geocoding
|
||||
|
||||
Reverse geocoding generates an address from a latitude and longitude or from
|
||||
an OSM object.
|
||||
Reverse geocoding generates an address from a latitude and longitude.
|
||||
|
||||
## How it works
|
||||
|
||||
The reverse geocoding API does not exactly compute the address for the
|
||||
coordinate it receives. It works by finding the closest suitable OSM object
|
||||
and returning its address information. This may occasionally lead to
|
||||
unexpected results.
|
||||
|
||||
First of all, Nominatim only includes OSM objects in
|
||||
its index that are suitable for searching. Small, unnamed paths for example
|
||||
are missing from the database and can therefore not be used for reverse
|
||||
geocoding either.
|
||||
|
||||
The other issue to be aware of is that the closest OSM object may not always
|
||||
have a similar enough address to the coordinate you were requesting. For
|
||||
example, in dense city areas it may belong to a completely different street.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
The main format of the reverse API is
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/reverse?<query>
|
||||
https://nominatim.openstreetmap.org/reverse?lat=<value>&lon=<value>&<params>
|
||||
```
|
||||
|
||||
There are two ways how the requested location can be specified:
|
||||
where `lat` and `lon` are latitude and longitutde of a coordinate in WGS84
|
||||
projection. The API returns exactly one result or an error when the coordinate
|
||||
is in an area with no OSM data coverage.
|
||||
|
||||
* `lat=<value>` `lon=<value>`
|
||||
Additional paramters are accepted as listed below.
|
||||
|
||||
A geographic location to generate an address for. The coordiantes must be
|
||||
in WGS84 format.
|
||||
|
||||
* `osm_type=[N|W|R]` `osm_id=<value>`
|
||||
|
||||
A specific OSM node(N), way(W) or relation(R) to return an address for.
|
||||
|
||||
In both cases exactly one object is returned. The two input paramters cannot
|
||||
be used at the same time. Both accept the additional optional parameters listed
|
||||
below.
|
||||
!!! warning "Deprecation warning"
|
||||
The reverse API used to allow address lookup for a single OSM object by
|
||||
its OSM id. This use is now deprecated. Use the [Address Lookup API](../Lookup)
|
||||
instead.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: html)
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap json output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||
Only has an effect for JSON output formats.
|
||||
|
||||
### Output details
|
||||
@@ -69,8 +81,9 @@ comma-separated list of language codes.
|
||||
|
||||
* `zoom=[0-18]`
|
||||
|
||||
Level of detail required for the address. Default: 18. This is a number that corresponds
|
||||
roughly to the zoom level used in map frameworks like Leaflet.js, Openlayers etc.
|
||||
Level of detail required for the address. Default: 18. This is a number that
|
||||
corresponds roughly to the zoom level used in XYZ tile sources in frameworks
|
||||
like Leaflet.js, Openlayers etc.
|
||||
In terms of address details the zoom levels are as follows:
|
||||
|
||||
zoom | address detail
|
||||
@@ -80,7 +93,8 @@ In terms of address details the zoom levels are as follows:
|
||||
8 | county
|
||||
10 | city
|
||||
14 | suburb
|
||||
16 | street
|
||||
16 | major streets
|
||||
17 | major and minor streets
|
||||
18 | building
|
||||
|
||||
|
||||
@@ -96,7 +110,7 @@ options can be used at a time. (Default: 0)
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
|
||||
Simplify the output geometry before returning. The parameter is the
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
|
||||
@@ -134,7 +148,7 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
<postcode>B72</postcode>
|
||||
<country>United Kingdom</country>
|
||||
<country_code>gb</country_code>
|
||||
</addressparts>
|
||||
</addressparts>
|
||||
</reversegeocode>
|
||||
```
|
||||
|
||||
@@ -145,10 +159,10 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
```json
|
||||
{
|
||||
"place_id":"134140761",
|
||||
"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright",
|
||||
"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https:\/\/www.openstreetmap.org\/copyright",
|
||||
"osm_type":"way",
|
||||
"osm_id":"280940520",
|
||||
"lat":"-34.4391708",
|
||||
"lat":"-34.4391708",
|
||||
"lon":"-58.7064573",
|
||||
"place_rank":"26",
|
||||
"category":"highway",
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
# Search queries
|
||||
|
||||
The search API allows to look up a location from a textual description.
|
||||
Nominatim supports structured as well as free-form search queries.
|
||||
The search API allows you to look up a location from a textual description
|
||||
or address. Nominatim supports structured and free-form search queries.
|
||||
|
||||
The search query may also contain
|
||||
[special phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
||||
which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`).
|
||||
Note that this only limits the items to be found, it's not suited to return complete
|
||||
lists of OSM objects of a specific type. For those use [Overpass API](https://overpass-api.de/).
|
||||
This can be used to narrow down the kind of objects to be returned.
|
||||
|
||||
!!! warning
|
||||
Special phrases are not suitable to query all objects of a certain type in an
|
||||
area. Nominatim will always just return a collection of the best matches. To
|
||||
download OSM data by object type, use the [Overpass API](https://overpass-api.de/).
|
||||
|
||||
## Parameters
|
||||
|
||||
The search API has the following two formats:
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/search/<query>?<params>
|
||||
```
|
||||
|
||||
This format only accepts a free-form query string where the
|
||||
parts of the query are separated by slashes.
|
||||
The search API has the following format:
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/search?<params>
|
||||
```
|
||||
|
||||
In this form, the query may be given through two different sets of parameters:
|
||||
The search term may be specified with two different sets of parameters:
|
||||
|
||||
* `q=<query>`
|
||||
|
||||
@@ -46,17 +43,17 @@ In this form, the query may be given through two different sets of parameters:
|
||||
Structured requests are faster but are less robust against alternative
|
||||
OSM tagging schemas. **Do not combine with** `q=<query>` **parameter**.
|
||||
|
||||
All three query forms accept the additional paramters listed below.
|
||||
Both query forms accept the additional parameters listed below.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[html|xml|json|jsonv2|geojson|geocodejson]`
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: html)
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: jsonv2)
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap json output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||
Only has an effect for JSON output formats.
|
||||
|
||||
### Output details
|
||||
@@ -92,16 +89,20 @@ comma-separated list of language codes.
|
||||
* `countrycodes=<countrycode>[,<countrycode>][,<countrycode>]...`
|
||||
|
||||
Limit search results to one or more countries. `<countrycode>` must be the
|
||||
ISO 3166-1alpha2 code, e.g. `gb` for the United Kingdom, `de` for Germany.
|
||||
[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code,
|
||||
e.g. `gb` for the United Kingdom, `de` for Germany.
|
||||
|
||||
Each place in Nominatim is assigned to one country code based
|
||||
on OSM country boundaries. In rare cases a place may not be in any country
|
||||
at all, for example, in international waters.
|
||||
|
||||
* `exclude_place_ids=<place_id,[place_id],[place_id]`
|
||||
|
||||
If you do not want certain OSM objects to appear in the search
|
||||
result, give a comma separated list of the `place_id`s you want to skip.
|
||||
This can be used to broaden search results. For example, if a previous
|
||||
query only returned a few results, then including those here would cause
|
||||
the search to return other, less accurate, matches (if possible).
|
||||
This can be used to retrieve additional search results. For example, if a
|
||||
previous query only returned a few results, then including those here would
|
||||
cause the search to return other, less accurate, matches (if possible).
|
||||
|
||||
|
||||
* `limit=<integer>`
|
||||
@@ -112,15 +113,17 @@ Limit the number of returned results. (Default: 10, Maximum: 50)
|
||||
* `viewbox=<x1>,<y1>,<x2>,<y2>`
|
||||
|
||||
The preferred area to find search results. Any two corner points of the box
|
||||
are accepted in any order as long as they span a real box.
|
||||
are accepted as long as they span a real box. `x` is longitude,
|
||||
`y` is latitude.
|
||||
|
||||
|
||||
* `bounded=[0|1]`
|
||||
|
||||
When a viewbox is given, restrict the result to items contained with that
|
||||
When a viewbox is given, restrict the result to items contained within that
|
||||
viewbox (see above). When `viewbox` and `bounded=1` are given, an amenity
|
||||
only search is allowed. In this case, give the special keyword for the
|
||||
amenity in square brackets, e.g. `[pub]`. (Default: 0)
|
||||
only search is allowed. Give the special keyword for the amenity in square
|
||||
brackets, e.g. `[pub]` and a selection of objects of this type is returned.
|
||||
There is no guarantee that the result is complete. (Default: 0)
|
||||
|
||||
|
||||
### Polygon output
|
||||
@@ -135,7 +138,7 @@ options can be used at a time. (Default: 0)
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
|
||||
Simplify the output geometry before returning. The parameter is the
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
|
||||
@@ -149,13 +152,11 @@ address to identify your requests. See Nominatim's [Usage Policy](https://operat
|
||||
* `dedupe=[0|1]`
|
||||
|
||||
Sometimes you have several objects in OSM identifying the same place or
|
||||
object in reality. The simplest case is a street being split in many
|
||||
object in reality. The simplest case is a street being split into many
|
||||
different OSM ways due to different characteristics. Nominatim will
|
||||
attempt to detect such duplicates and only return one match unless
|
||||
this parameter is set to 0. (Default: 1)
|
||||
|
||||
|
||||
|
||||
* `debug=[0|1]`
|
||||
|
||||
Output assorted developer debug information. Data on internals of Nominatim's
|
||||
@@ -167,21 +168,27 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
## Examples
|
||||
|
||||
|
||||
##### XML with polygon points
|
||||
##### XML with kml polygon
|
||||
|
||||
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon=1&addressdetails=1](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon=1&addressdetails=1)
|
||||
* [https://nominatim.openstreetmap.org/search/gb/birmingham/pilkington%20avenue/135?format=xml&polygon=1&addressdetails=1](https://nominatim.openstreetmap.org/search/gb/birmingham/pilkington%20avenue/135?format=xml&polygon=1&addressdetails=1)
|
||||
* [https://nominatim.openstreetmap.org/search/135%20pilkington%20avenue,%20birmingham?format=xml&polygon=1&addressdetails=1](https://nominatim.openstreetmap.org/search/135%20pilkington%20avenue,%20birmingham?format=xml&polygon=1&addressdetails=1)
|
||||
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1)
|
||||
|
||||
```xml
|
||||
<searchresults timestamp="Sat, 07 Nov 09 14:42:10 +0000" querystring="135 pilkington, avenue birmingham" polygon="true">
|
||||
<place
|
||||
place_id="1620612" osm_type="node" osm_id="452010817"
|
||||
boundingbox="52.548641204834,52.5488433837891,-1.81612110137939,-1.81592094898224"
|
||||
polygonpoints="[['-1.81592098644987','52.5487429714954'],['-1.81592290792183','52.5487234624632'],...]"
|
||||
lat="52.5487429714954" lon="-1.81602098644987"
|
||||
display_name="135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom"
|
||||
<place
|
||||
place_id="1620612" osm_type="node" osm_id="452010817"
|
||||
boundingbox="52.548641204834,52.5488433837891,-1.81612110137939,-1.81592094898224"
|
||||
lat="52.5487429714954" lon="-1.81602098644987"
|
||||
display_name="135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom"
|
||||
class="place" type="house">
|
||||
<geokml>
|
||||
<Polygon>
|
||||
<outerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>-1.816513,52.548756599999997 -1.816434,52.548747300000002 -1.816429,52.5487629 -1.8163717,52.548756099999999 -1.8163464,52.548834599999999 -1.8164599,52.548848100000001 -1.8164685,52.5488213 -1.8164913,52.548824000000003 -1.816513,52.548756599999997</coordinates>
|
||||
</LinearRing>
|
||||
</outerBoundaryIs>
|
||||
</Polygon>
|
||||
</geokml>
|
||||
<house_number>135</house_number>
|
||||
<road>Pilkington Avenue</road>
|
||||
<village>Wylde Green</village>
|
||||
@@ -237,7 +244,7 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
|
||||
##### JSON with address details
|
||||
|
||||
[https://nominatim.openstreetmap.org/?format=json&addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1](https://nominatim.openstreetmap.org/?format=json&addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1)
|
||||
[https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1](https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1)
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
66
docs/api/Status.md
Normal file
66
docs/api/Status.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Status
|
||||
|
||||
Useful for checking if the service and database is running. The JSON output also shows
|
||||
when the database was last updated.
|
||||
|
||||
## Parameters
|
||||
|
||||
* `format=[text|json]` (defaults to 'text')
|
||||
|
||||
|
||||
## Output
|
||||
|
||||
#### Text format
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/status.php
|
||||
```
|
||||
|
||||
will return HTTP status code 200 and print `OK`.
|
||||
|
||||
On error it will return HTTP status code 500 and print a message, e.g.
|
||||
`ERROR: Database connection failed`.
|
||||
|
||||
|
||||
|
||||
#### JSON format
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/status.php?format=json
|
||||
```
|
||||
|
||||
will return HTTP code 200 and a structure
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"message": "OK",
|
||||
"data_updated": "2020-05-04T14:47:00+00:00",
|
||||
"software_version": "3.6.0-0",
|
||||
"database_version": "3.6.0-0"
|
||||
}
|
||||
```
|
||||
|
||||
The `software_version` field contains the version of Nominatim used to serve
|
||||
the API. The `database_version` field contains the version of the data format
|
||||
in the database.
|
||||
|
||||
On error will also return HTTP status code 200 and a structure with error
|
||||
code and message, e.g.
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 700,
|
||||
"message": "Database connection failed"
|
||||
}
|
||||
```
|
||||
|
||||
Possible status codes are
|
||||
|
||||
| | message | notes |
|
||||
|-----|----------------------|---------------------------------------------------|
|
||||
| 700 | "No database" | connection failed |
|
||||
| 701 | "Module failed" | database could not load nominatim.so |
|
||||
| 702 | "Module call failed" | nominatim.so loaded but calling a function failed |
|
||||
| 703 | "Query failed" | test query against a database table failed |
|
||||
| 704 | "No value" | test query worked but returned no results |
|
||||
128
docs/develop/Development-Environment.md
Normal file
128
docs/develop/Development-Environment.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# 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 test suite consists of behavioural tests (using behave) and
|
||||
unit tests (using PHPUnit for PHP code and pytest for Python code).
|
||||
It has the following additional requirements:
|
||||
|
||||
* [behave test framework](https://behave.readthedocs.io) >= 1.2.5
|
||||
* [phpunit](https://phpunit.de) >= 7.3
|
||||
* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||
* [Pylint](https://pylint.org/) (2.6.0 is used for the CI)
|
||||
* [pytest](https://pytest.org)
|
||||
|
||||
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 pylint
|
||||
|
||||
pip3 install --user behave mkdocs pytest
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
To run all tests just go to the build directory and run make:
|
||||
|
||||
```sh
|
||||
cd build
|
||||
make test
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
170
docs/develop/Import.md
Normal file
170
docs/develop/Import.md
Normal file
@@ -0,0 +1,170 @@
|
||||
# OSM Data Import
|
||||
|
||||
OSM data is initially imported using [osm2pgsql](https://osm2pgsql.org).
|
||||
Nominatim uses its own data output style 'gazetteer', which differs from the
|
||||
output style created for map rendering.
|
||||
|
||||
## Database Layout
|
||||
|
||||
The gazetteer style produces a single table `place` with the following rows:
|
||||
|
||||
* `osm_type` - kind of OSM object (**N** - node, **W** - way, **R** - relation)
|
||||
* `osm_id` - original OSM ID
|
||||
* `class` - key of principal tag defining the object type
|
||||
* `type` - value of principal tag defining the object type
|
||||
* `name` - collection of tags that contain a name or reference
|
||||
* `admin_level` - numerical value of the tagged administrative level
|
||||
* `address` - collection of tags defining the address of an object
|
||||
* `extratags` - collection of additional interesting tags that are not
|
||||
directly relevant for searching
|
||||
* `geometry` - geometry of the object (in WGS84)
|
||||
|
||||
A single OSM object may appear multiple times in this table when it is tagged
|
||||
with multiple tags that may constitute a principal tag. Take for example a
|
||||
motorway bridge. In OSM, this would be a way which is tagged with
|
||||
`highway=motorway` and `bridge=yes`. This way would appear in the `place` table
|
||||
once with `class` of `highway` and once with a `class` of `bridge`. Thus the
|
||||
*unique key* for `place` is (`osm_type`, `osm_id`, `class`).
|
||||
|
||||
## Configuring the Import
|
||||
|
||||
How tags are interpreted and assigned to the different `place` columns can be
|
||||
configured via the import style configuration file (`NOMINATIM_IMPORT_STYLE`). This
|
||||
is a JSON file which contains a list of rules which are matched against every
|
||||
tag of every object and then assign the tag its specific role.
|
||||
|
||||
### Configuration Rules
|
||||
|
||||
A single rule looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"keys" : ["key1", "key2", ...],
|
||||
"values" : {
|
||||
"value1" : "prop",
|
||||
"value2" : "prop1,prop2"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
A rule first defines a list of keys to apply the rule to. This is always a list
|
||||
of strings. The string may have four forms. An empty string matches against
|
||||
any key. A string that ends in an asterisk `*` is a prefix match and accordingly
|
||||
matches against any key that starts with the given string (minus the `*`). A
|
||||
suffix match can be defined similarly with a string that starts with a `*`. Any
|
||||
other string constitutes an exact match.
|
||||
|
||||
The second part of the rules defines a list of values and the properties that
|
||||
apply to a successful match. Value strings may be either empty, which
|
||||
means that they match any value, or describe an exact match. Prefix
|
||||
or suffix matching of values is not possible.
|
||||
|
||||
For a rule to match, it has to find a valid combination of keys and values. The
|
||||
resulting property is that of the matched values.
|
||||
|
||||
The rules in a configuration file are processed sequentially and the first
|
||||
match for each tag wins.
|
||||
|
||||
A rule where key and value are the empty string is special. This defines the
|
||||
fallback when none of the rules match. The fallback is always used as a last
|
||||
resort when nothing else matches, no matter where the rule appears in the file.
|
||||
Defining multiple fallback rules is not allowed. What happens in this case,
|
||||
is undefined.
|
||||
|
||||
### Tag Properties
|
||||
|
||||
One or more of the following properties may be given for each tag:
|
||||
|
||||
* `main`
|
||||
|
||||
A principal tag. A new row will be added for the object with key and value
|
||||
as `class` and `type`.
|
||||
|
||||
* `with_name`
|
||||
|
||||
When the tag is a principal tag (`main` property set): only really add a new
|
||||
row, if there is any name tag found (a reference tag is not sufficient, see
|
||||
below).
|
||||
|
||||
* `with_name_key`
|
||||
|
||||
When the tag is a principal tag (`main` property set): only really add a new
|
||||
row, if there is also a name tag that matches the key of the principal tag.
|
||||
For example, if the main tag is `bridge=yes`, then it will only be added as
|
||||
an extra row, if there is a tag `bridge:name[:XXX]` for the same object.
|
||||
If this property is set, all other names that are not domain-specific are
|
||||
ignored.
|
||||
|
||||
* `fallback`
|
||||
|
||||
When the tag is a principal tag (`main` property set): only really add a new
|
||||
row, when no other principal tags for this object have been found. Only one
|
||||
fallback tag can win for an object.
|
||||
|
||||
* `operator`
|
||||
|
||||
When the tag is a principal tag (`main` property set): also include the
|
||||
`operator` tag in the list of names. This is a special construct for an
|
||||
out-dated tagging practise in OSM. Fuel stations and chain restaurants
|
||||
in particular used to have the name of the chain tagged as `operator`.
|
||||
These days the chain can be more commonly found in the `brand` tag but
|
||||
there is still enough old data around to warrant this special case.
|
||||
|
||||
* `name`
|
||||
|
||||
Add tag to the list of names.
|
||||
|
||||
* `ref`
|
||||
|
||||
Add tag to the list of names as a reference. At the moment this only means
|
||||
that the object is not considered to be named for `with_name`.
|
||||
|
||||
* `address`
|
||||
|
||||
Add tag to the list of address tags. If the tag starts with `addr:` or
|
||||
`is_in:`, then this prefix is cut off before adding it to the list.
|
||||
|
||||
* `postcode`
|
||||
|
||||
Add the value as a postcode to the address tags. If multiple tags are
|
||||
candidate for postcodes, one wins out and the others are dropped.
|
||||
|
||||
* `country`
|
||||
|
||||
Add the value as a country code to the address tags. The value must be a
|
||||
two letter country code, otherwise it is ignored. If there are multiple
|
||||
tags that match, then one wins out and the others are dropped.
|
||||
|
||||
* `house`
|
||||
|
||||
If no principle tags can be found for the object, still add the object with
|
||||
`class`=`place` and `type`=`house`. Use this for address nodes that have no
|
||||
other function.
|
||||
|
||||
* `interpolation`
|
||||
|
||||
Add this object as an address interpolation (appears as `class`=`place` and
|
||||
`type`=`houses` in the database).
|
||||
|
||||
* `extra`
|
||||
|
||||
Add tag to the list of extra tags.
|
||||
|
||||
* `skip`
|
||||
|
||||
Skip the tag completely. Useful when a custom default fallback is defined
|
||||
or to define exceptions to rules.
|
||||
|
||||
A rule can define as many of these properties for one match as it likes. For
|
||||
example, if the property is `"main,extra"` then the tag will open a new row
|
||||
but also have the tag appear in the list of extra tags.
|
||||
|
||||
There are a number of pre-defined styles in the `settings/` directory. It is
|
||||
advisable to start from one of these styles when defining your own.
|
||||
|
||||
### Changing the Style of Existing Databases
|
||||
|
||||
There is normally no issue changing the style of a database that is already
|
||||
imported and now kept up-to-date with change files. Just be aware that any
|
||||
change in the style applies to updates only. If you want to change the data
|
||||
that is already in the database, then a reimport is necessary.
|
||||
45
docs/develop/Postcodes.md
Normal file
45
docs/develop/Postcodes.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Postcodes in Nominatim
|
||||
|
||||
The blog post
|
||||
[Nominatim and Postcodes](https://www.openstreetmap.org/user/lonvia/diary/43143)
|
||||
describes the handling implemented since Nominatim 3.1.
|
||||
|
||||
Postcode centroids (aka 'calculated postcodes') are generated by looking at all
|
||||
postcodes of a country, grouping them and calculating the geometric centroid.
|
||||
There is currently no logic to deal with extreme outliers (typos or other
|
||||
mistakes in OSM data). There is also no check if a postcodes adheres to a
|
||||
country's format, e.g. if Swiss postcodes are 4 digits.
|
||||
|
||||
|
||||
## Regular updating calculated postcodes
|
||||
|
||||
The script to rerun the calculation is
|
||||
`nominatim refresh --postcodes`
|
||||
and runs once per night on nominatim.openstreetmap.org.
|
||||
|
||||
|
||||
## Finding places that share a specific postcode
|
||||
|
||||
In the Nominatim database run
|
||||
|
||||
```sql
|
||||
SELECT address->'postcode' as pc,
|
||||
osm_type, osm_id, class, type,
|
||||
st_x(centroid) as lon, st_y(centroid) as lat
|
||||
FROM placex
|
||||
WHERE country_code='fr'
|
||||
AND upper(trim (both ' ' from address->'postcode')) = '33210';
|
||||
```
|
||||
|
||||
Alternatively on [Overpass](https://overpass-turbo.eu/) run the following query
|
||||
|
||||
```
|
||||
[out:json][timeout:250];
|
||||
area["name"="France"]->.boundaryarea;
|
||||
(
|
||||
nwr(area.boundaryarea)["addr:postcode"="33210"];
|
||||
);
|
||||
out body;
|
||||
>;
|
||||
out skel qt;
|
||||
```
|
||||
140
docs/develop/Ranking.md
Normal file
140
docs/develop/Ranking.md
Normal file
@@ -0,0 +1,140 @@
|
||||
# Place Ranking in Nominatim
|
||||
|
||||
Nominatim uses two metrics to rank a place: search rank and address rank.
|
||||
Both can be assigned a value between 0 and 30. They serve slightly
|
||||
different purposes, which are explained in this chapter.
|
||||
|
||||
## Search rank
|
||||
|
||||
The search rank describes the extent and importance of a place. It is used
|
||||
when ranking search results. Simply put, if there are two results for a
|
||||
search query which are otherwise equal, then the result with the _lower_
|
||||
search rank will be appear higher in the result list.
|
||||
|
||||
Search ranks are not so important these days because many well-known
|
||||
places use the Wikipedia importance ranking instead.
|
||||
|
||||
The following table gives an overview of the kind of features that Nominatim
|
||||
expects for each rank:
|
||||
|
||||
rank | typical place types | extent
|
||||
-------|---------------------------------|-------
|
||||
1-3 | oceans, continents | -
|
||||
4 | countries | -
|
||||
5-9 | states, regions, provinces | -
|
||||
10-12 | counties | -
|
||||
13-16 | cities, municipalities, islands | 15 km
|
||||
17-18 | towns, boroughs | 4 km
|
||||
19 | villages, suburbs | 2 km
|
||||
20 | hamlets, farms, neighbourhoods | 1 km
|
||||
21-25 | isolated dwellings, city blocks | 500 m
|
||||
|
||||
The extent column describes how far a feature is assumed to reach when it
|
||||
is mapped only as a point. Larger features like countries and states are usually
|
||||
available with their exact area in the OpenStreetMap data. That is why no extent
|
||||
is given.
|
||||
|
||||
## Address rank
|
||||
|
||||
The address rank describes where a place shows up in an address hierarchy.
|
||||
Usually only administrative boundaries and place nodes and areas are
|
||||
eligible to be part of an address. Places that should not appear in the
|
||||
address must have an address rank of 0.
|
||||
|
||||
The following table gives an overview how ranks are mapped to address parts:
|
||||
|
||||
rank | address part
|
||||
-------------|-------------
|
||||
1-3 | _unused_
|
||||
4 | country
|
||||
5-9 | state
|
||||
10-12 | county
|
||||
13-16 | city
|
||||
17-21 | suburb
|
||||
22-24 | neighbourhood
|
||||
25 | squares, farms, localities
|
||||
26-27 | street
|
||||
28-30 | POI/house number
|
||||
|
||||
The country rank 4 usually doesn't show up in the address parts of an object.
|
||||
The country is determined indirectly from the country code.
|
||||
|
||||
Ranks 5-24 can be assigned more or less freely. They make up the major part
|
||||
of the address.
|
||||
|
||||
Rank 25 is also an addressing rank but it is special because while it can be
|
||||
the parent to a POI with an addr:place of the same name, it cannot be a parent
|
||||
to streets. Use it for place features that are technically on the same level
|
||||
as a street (e.g. squares, city blocks) or for places that should not normally
|
||||
appear in an address unless explicitly tagged so (e.g place=locality which
|
||||
should be uninhabited and as such not addressable).
|
||||
|
||||
The street ranks 26 and 27 are handled slightly differently. Only one object
|
||||
from these ranks shows up in an address.
|
||||
|
||||
For POI level objects like shops, buildings or house numbers always use rank 30.
|
||||
Ranks 28 is reserved for house number interpolations. 29 is for internal use
|
||||
only.
|
||||
|
||||
## Rank configuration
|
||||
|
||||
Search and address ranks are assigned to a place when it is first imported
|
||||
into the database. There are a few hard-coded rules for the assignment:
|
||||
|
||||
* postcodes follow special rules according to their length
|
||||
* boundaries that are not areas and railway=rail are dropped completely
|
||||
* the following are always search rank 30 and address rank 0:
|
||||
* highway nodes
|
||||
* landuse that is not an area
|
||||
|
||||
Other than that, the ranks can be freely assigned via the JSON file according
|
||||
to their type and the country they are in. The name of the config file to be
|
||||
used can be changed with the setting `NOMINATIM_ADDRESS_LEVEL_CONFIG`.
|
||||
|
||||
The address level configuration must consist of an array of configuration
|
||||
entries, each containing a tag definition and an optional country array:
|
||||
|
||||
```
|
||||
[ {
|
||||
"tags" : {
|
||||
"place" : {
|
||||
"county" : 12,
|
||||
"city" : 16,
|
||||
},
|
||||
"landuse" : {
|
||||
"residential" : 22,
|
||||
"" : 30
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"countries" : [ "ca", "us" ],
|
||||
"tags" : {
|
||||
"boundary" : {
|
||||
"administrative8" : 18,
|
||||
"administrative9" : 20
|
||||
},
|
||||
"landuse" : {
|
||||
"residential" : [22, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
The `countries` field contains a list of countries (as ISO 3166-1 alpha 2 code)
|
||||
for which the definition applies. When the field is omitted, then the
|
||||
definition is used as a fallback, when nothing more specific for a given
|
||||
country exists.
|
||||
|
||||
`tags` contains the ranks for key/value pairs. The ranks can be either a
|
||||
single number, in which case they are the search and address rank, or an array
|
||||
of search and address rank (in that order). The value may be left empty.
|
||||
Then the rank is used when no more specific value is found for the given
|
||||
key.
|
||||
|
||||
Countries and key/value combination may appear in multiple definitions. Just
|
||||
make sure that each combination of country/key/value appears only once per
|
||||
file. Otherwise the import will fail with a UNIQUE INDEX constraint violation
|
||||
on import.
|
||||
|
||||
@@ -1,22 +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).
|
||||
|
||||
* 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/)
|
||||
|
||||
To get the prerequisites on a a fresh Ubuntu LTS 16.04 run:
|
||||
|
||||
[sudo] apt-get install python3-dev python3-pip python3-psycopg2 python3-tidylib phpunit php-cgi
|
||||
pip3 install --user behave nose
|
||||
|
||||
|
||||
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
|
||||
@@ -33,66 +21,47 @@ This test directory is sturctured as follows:
|
||||
| +- api Tests for API endpoints (search, reverse, etc.)
|
||||
|
|
||||
+- php PHP unit tests
|
||||
+- python Python unit tests
|
||||
+- scenes Geometry test data
|
||||
+- 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.
|
||||
Unit tests for PHP code can be found in the `php/` directory. They test selected
|
||||
PHP functions. Very low coverage.
|
||||
|
||||
To execute the test suite run
|
||||
|
||||
cd test/php
|
||||
phpunit ../
|
||||
UNIT_TEST_DSN='pgsql:dbname=nominatim_unit_tests' phpunit ../
|
||||
|
||||
It will read phpunit.xml which points to the library, test path, bootstrap
|
||||
strip and set other parameters.
|
||||
strip and sets 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
|
||||
====================
|
||||
## Python Unit Tests (`test/python`)
|
||||
|
||||
Unit tests for Python code can be found in the `python/` directory. The goal is
|
||||
to have complete coverage of the Python library in `nominatim`.
|
||||
|
||||
To execute the tests run
|
||||
|
||||
py.test-3 test/python
|
||||
|
||||
or
|
||||
|
||||
pytest test/python
|
||||
|
||||
The name of the pytest binary depends on your installation.
|
||||
|
||||
## 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
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To run the functional tests, do
|
||||
|
||||
cd test/bdd
|
||||
behave
|
||||
|
||||
The tests can be configured with a set of environment variables:
|
||||
|
||||
* `BUILD_DIR` - build directory of Nominatim installation to test
|
||||
* `TEMPLATE_DB` - name of template database used as a skeleton for
|
||||
the test databases (db tests)
|
||||
* `TEST_DB` - name of test database (db tests)
|
||||
* `ABI_TEST_DB` - name of the database containing the API test data (api tests)
|
||||
* `DB_HOST` - (optional) hostname of database host
|
||||
* `DB_USER` - (optional) username of database login
|
||||
* `DB_PASS` - (optional) password for database login
|
||||
* `SERVER_MODULE_PATH` - (optional) path on the Postgres server to Nominatim
|
||||
* module shared library file
|
||||
* `TEST_SETTINGS_TEMPLATE` - file to write temporary Nominatim settings to
|
||||
* `REMOVE_TEMPLATE` - if true, the template database will not be reused during
|
||||
the next run. Reusing the base templates speeds up tests
|
||||
considerably but might lead to outdated errors for some
|
||||
changes in the database layout.
|
||||
* `KEEP_TEST_DB` - if true, the test database will not be dropped after a test
|
||||
is finished. Should only be used if one single scenario is
|
||||
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'
|
||||
feature of behave which comes in handy when writing new tests.
|
||||
|
||||
Writing Tests
|
||||
-------------
|
||||
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.
|
||||
@@ -100,30 +69,56 @@ notations of features, scenarios and steps.
|
||||
All possible steps can be found in the `steps` directory and should ideally
|
||||
be documented.
|
||||
|
||||
### General Usage
|
||||
|
||||
To run the functional tests, do
|
||||
|
||||
cd test/bdd
|
||||
behave
|
||||
|
||||
The tests can be configured with a set of environment variables (`behave -D key=val`):
|
||||
|
||||
* `BUILDDIR` - build directory of Nominatim installation to test
|
||||
* `TEMPLATE_DB` - name of template database used as a skeleton for
|
||||
the test databases (db tests)
|
||||
* `TEST_DB` - name of test database (db tests)
|
||||
* `API_TEST_DB` - name of the database containing the API test data (api tests)
|
||||
* `API_TEST_FILE` - OSM file to be imported into the API test database (api tests)
|
||||
* `DB_HOST` - (optional) hostname of database host
|
||||
* `DB_PORT` - (optional) port of database on host
|
||||
* `DB_USER` - (optional) username of database login
|
||||
* `DB_PASS` - (optional) password for database login
|
||||
* `SERVER_MODULE_PATH` - (optional) path on the Postgres server to Nominatim
|
||||
module shared library file
|
||||
* `REMOVE_TEMPLATE` - if true, the template and API database will not be reused
|
||||
during the next run. Reusing the base templates speeds
|
||||
up tests considerably but might lead to outdated errors
|
||||
for some changes in the database layout.
|
||||
* `KEEP_TEST_DB` - if true, the test database will not be dropped after a test
|
||||
is finished. Should only be used if one single scenario is
|
||||
run, otherwise the result is undefined.
|
||||
|
||||
Logging can be defined through command line parameters of behave itself. Check
|
||||
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.
|
||||
|
||||
### API Tests (`test/bdd/api`)
|
||||
|
||||
These tests are meant to test the different API endpoints and their parameters.
|
||||
They require a preimported test database, which consists of the import of a
|
||||
planet extract. A precompiled PBF with the necessary data can be downloaded from
|
||||
https://www.nominatim.org/data/test/nominatim-api-testdata.pbf
|
||||
They require to import several datasets into a test database. This is normally
|
||||
done automatically during setup of the test. The API test database is then
|
||||
kept around and reused in subsequent runs of behave. Use `behave -DREMOVE_TEMPLATE`
|
||||
to force a reimport of the database.
|
||||
|
||||
The polygons defining the extract can be found in the test/testdb
|
||||
directory. There is also a reduced set of wikipedia data for this extract,
|
||||
which you need to import as well. For Tiger tests the data of South Dakota
|
||||
is required. Get the Tiger files `46*`.
|
||||
The official test dataset is saved in the file `test/testdb/apidb-test-data.pbf`
|
||||
and compromises the following data:
|
||||
|
||||
The official test dataset is derived from the 160725 planet. 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:
|
||||
* Geofabrik extract of Liechtenstein
|
||||
* extract of Autauga country, Alabama, US (for tests against Tiger data)
|
||||
* additional data from `test/testdb/additional_api_test.data.osm`
|
||||
|
||||
wget https://free.nchc.org.tw/osm.planet/pbf/planet-160725.osm.pbf
|
||||
osmconvert planet-160725.osm.pbf -B=test/testdb/testdb.polys -o=testdb.pbf
|
||||
|
||||
Before importing make sure to add the following to your local settings:
|
||||
|
||||
@define('CONST_Database_DSN', 'pgsql://@/test_api_nominatim');
|
||||
@define('CONST_Wikipedia_Data_Path', CONST_BasePath.'/test/testdb');
|
||||
API tests should only be testing the functionality of the website PHP code.
|
||||
Most tests should be formulated as BDD DB creation tests (see below) instead.
|
||||
|
||||
#### Code Coverage
|
||||
|
||||
@@ -133,7 +128,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=<coverage output dir>
|
||||
|
||||
@@ -142,11 +137,11 @@ the [phpcov](https://github.com/sebastianbergmann/phpcov) tool:
|
||||
|
||||
phpcov merge --html=<report output dir> <coverage output dir>
|
||||
|
||||
### 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`
|
||||
table (and optionally `the planet_osm_*` tables if required) and then run
|
||||
table (and optionally the `planet_osm_*` tables if required) and then run
|
||||
Nominatim's processing functions on that.
|
||||
|
||||
These tests need to create their own test databases. By default they will be
|
||||
@@ -157,4 +152,8 @@ needs superuser rights for postgres.
|
||||
### Import Tests (`test/bdd/osm2pgsql`)
|
||||
|
||||
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.
|
||||
use the same template database as the DB Creation tests, so the same remarks apply.
|
||||
|
||||
Note that most testing of the gazetteer output of osm2pgsql is done in the tests
|
||||
of osm2pgsql itself. The BDD tests are just there to ensure compatibility of
|
||||
the osm2pgsql and Nominatim code.
|
||||
34
docs/develop/data-sources.md
Normal file
34
docs/develop/data-sources.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Additional Data Sources
|
||||
|
||||
This guide explains how data sources other than OpenStreetMap mentioned in
|
||||
the install instructions got obtained and converted.
|
||||
|
||||
## Country grid
|
||||
|
||||
Nominatim uses pre-generated country borders data. In case one imports only
|
||||
a subset of a country. And to assign each place a partition. Nominatim
|
||||
database tables are split into partitions for performance.
|
||||
|
||||
More details in [osm-search/country-grid-data](https://github.com/osm-search/country-grid-data).
|
||||
|
||||
## US Census TIGER
|
||||
|
||||
For the United States you can choose to import additonal street-level data.
|
||||
The data isn't mixed into OSM data but queried as fallback when no OSM
|
||||
result can be found.
|
||||
|
||||
More details in [osm-search/TIGER-data](https://github.com/osm-search/TIGER-data).
|
||||
|
||||
## GB postcodes
|
||||
|
||||
For Great Britain you can choose to import Royalmail postcode centroids.
|
||||
|
||||
More details in [osm-search/gb-postcode-data](https://github.com/osm-search/gb-postcode-data).
|
||||
|
||||
|
||||
## Wikipedia & Wikidata rankings
|
||||
|
||||
Nominatim can import "importance" data of place names. This greatly
|
||||
improves ranking of results.
|
||||
|
||||
More details in [osm-search/wikipedia-wikidata](https://github.com/osm-search/wikipedia-wikidata).
|
||||
@@ -1,6 +1,6 @@
|
||||
# Basic Architecture
|
||||
|
||||
Nominatim provides geocoding based on OpenStreetMap data. It uses a Postgresql
|
||||
Nominatim provides geocoding based on OpenStreetMap data. It uses a PostgreSQL
|
||||
database as a backend for storing the data.
|
||||
|
||||
There are three basic parts to Nominatim's architecture: the data import,
|
||||
@@ -9,16 +9,16 @@ the address computation and the search frontend.
|
||||
The __data import__ stage reads the raw OSM data and extracts all information
|
||||
that is useful for geocoding. This part is done by osm2pgsql, the same tool
|
||||
that can also be used to import a rendering database. It uses the special
|
||||
gazetteer output plugin in `osm2pgsql/output-gazetter.[ch]pp`. The result of
|
||||
gazetteer output plugin in `osm2pgsql/src/output-gazetter.[ch]pp`. The result of
|
||||
the import can be found in the database table `place`.
|
||||
|
||||
The __address computation__ or __indexing__ stage takes the data from `place`
|
||||
and adds additional information needed for geocoding. It ranks the places by
|
||||
importance, links objects that belong together and computes addresses and
|
||||
the search index. Most of this work is done in Pl/pqSQL via database triggers
|
||||
and can be found in the file `sql/functions.sql`.
|
||||
the search index. Most of this work is done in PL/pgSQL via database triggers
|
||||
and can be found in the files in the `sql/functions/` directory.
|
||||
|
||||
The __search frontend__ implements the actual API. It takes queries for
|
||||
search and reverse geocoding queries from the user, looks up the data and
|
||||
The __search frontend__ implements the actual API. It takes search
|
||||
and reverse geocoding queries from the user, looks up the data and
|
||||
returns the results in the requested format. This part is written in PHP
|
||||
and can be found in the `lib/` and `website/` directories.
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
.toctree-l3 {
|
||||
display: none!important
|
||||
}
|
||||
|
||||
table {
|
||||
margin-bottom: 12pt
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 1pt 12pt;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
site_name: Nominatim Documentation
|
||||
theme: readthedocs
|
||||
docs_dir: ${CMAKE_CURRENT_BINARY_DIR}
|
||||
site_url: http://nominatim.org
|
||||
site_url: https://nominatim.org
|
||||
repo_url: https://github.com/openstreetmap/Nominatim
|
||||
pages:
|
||||
- 'Introduction' : 'index.md'
|
||||
@@ -11,22 +11,34 @@ pages:
|
||||
- 'Reverse': 'api/Reverse.md'
|
||||
- 'Address Lookup': 'api/Lookup.md'
|
||||
- 'Details' : 'api/Details.md'
|
||||
- 'Status' : 'api/Status.md'
|
||||
- 'Place Output Formats': 'api/Output.md'
|
||||
- 'FAQ': 'api/Faq.md'
|
||||
- 'Administration Guide':
|
||||
- 'Basic Installation': 'admin/Installation.md'
|
||||
- 'Importing and Updating' : 'admin/Import-and-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'
|
||||
- 'Testing' : 'develop/Testing.md'
|
||||
- 'External Data Sources': 'develop/data-sources.md'
|
||||
- 'Appendix':
|
||||
- 'Installation on CentOS 7' : 'appendix/Install-on-Centos-7.md'
|
||||
- 'Installation on Ubuntu 16' : 'appendix/Install-on-Ubuntu-16.md'
|
||||
- 'Installation on CentOS 8' : 'appendix/Install-on-Centos-8.md'
|
||||
- 'Installation on Ubuntu 18' : 'appendix/Install-on-Ubuntu-18.md'
|
||||
- 'Installation on Ubuntu 20' : 'appendix/Install-on-Ubuntu-20.md'
|
||||
markdown_extensions:
|
||||
- codehilite:
|
||||
use_pygments: False
|
||||
- codehilite
|
||||
- admonition
|
||||
- toc:
|
||||
permalink:
|
||||
extra_css: [extra.css]
|
||||
extra_css: [extra.css, styles.css]
|
||||
|
||||
69
docs/styles.css
Normal file
69
docs/styles.css
Normal file
@@ -0,0 +1,69 @@
|
||||
.codehilite .hll { background-color: #ffffcc }
|
||||
.codehilite { background: #f0f0f0; }
|
||||
.codehilite .c { color: #60a0b0; font-style: italic } /* Comment */
|
||||
.codehilite .err { /* border: 1px solid #FF0000 */ } /* Error */
|
||||
.codehilite .k { color: #007020; font-weight: bold } /* Keyword */
|
||||
.codehilite .o { color: #666666 } /* Operator */
|
||||
.codehilite .ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */
|
||||
.codehilite .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
|
||||
.codehilite .cp { color: #007020 } /* Comment.Preproc */
|
||||
.codehilite .cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */
|
||||
.codehilite .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
|
||||
.codehilite .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
|
||||
.codehilite .gd { color: #A00000 } /* Generic.Deleted */
|
||||
.codehilite .ge { font-style: italic } /* Generic.Emph */
|
||||
.codehilite .gr { color: #FF0000 } /* Generic.Error */
|
||||
.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
.codehilite .gi { color: #00A000 } /* Generic.Inserted */
|
||||
.codehilite .go { color: #888888 } /* Generic.Output */
|
||||
.codehilite .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||||
.codehilite .gs { font-weight: bold } /* Generic.Strong */
|
||||
.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
.codehilite .gt { color: #0044DD } /* Generic.Traceback */
|
||||
.codehilite .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||||
.codehilite .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||||
.codehilite .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
||||
.codehilite .kp { color: #007020 } /* Keyword.Pseudo */
|
||||
.codehilite .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
|
||||
.codehilite .kt { color: #902000 } /* Keyword.Type */
|
||||
.codehilite .m { color: #40a070 } /* Literal.Number */
|
||||
.codehilite .s { color: #4070a0 } /* Literal.String */
|
||||
.codehilite .na { color: #4070a0 } /* Name.Attribute */
|
||||
.codehilite .nb { color: #007020 } /* Name.Builtin */
|
||||
.codehilite .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
|
||||
.codehilite .no { color: #60add5 } /* Name.Constant */
|
||||
.codehilite .nd { color: #555555; font-weight: bold } /* Name.Decorator */
|
||||
.codehilite .ni { color: #d55537; font-weight: bold } /* Name.Entity */
|
||||
.codehilite .ne { color: #007020 } /* Name.Exception */
|
||||
.codehilite .nf { color: #06287e } /* Name.Function */
|
||||
.codehilite .nl { color: #002070; font-weight: bold } /* Name.Label */
|
||||
.codehilite .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
|
||||
.codehilite .nt { color: #062873; font-weight: bold } /* Name.Tag */
|
||||
.codehilite .nv { color: #bb60d5 } /* Name.Variable */
|
||||
.codehilite .ow { color: #007020; font-weight: bold } /* Operator.Word */
|
||||
.codehilite .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.codehilite .mb { color: #40a070 } /* Literal.Number.Bin */
|
||||
.codehilite .mf { color: #40a070 } /* Literal.Number.Float */
|
||||
.codehilite .mh { color: #40a070 } /* Literal.Number.Hex */
|
||||
.codehilite .mi { color: #40a070 } /* Literal.Number.Integer */
|
||||
.codehilite .mo { color: #40a070 } /* Literal.Number.Oct */
|
||||
.codehilite .sa { color: #4070a0 } /* Literal.String.Affix */
|
||||
.codehilite .sb { color: #4070a0 } /* Literal.String.Backtick */
|
||||
.codehilite .sc { color: #4070a0 } /* Literal.String.Char */
|
||||
.codehilite .dl { color: #4070a0 } /* Literal.String.Delimiter */
|
||||
.codehilite .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
|
||||
.codehilite .s2 { color: #4070a0 } /* Literal.String.Double */
|
||||
.codehilite .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
|
||||
.codehilite .sh { color: #4070a0 } /* Literal.String.Heredoc */
|
||||
.codehilite .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
|
||||
.codehilite .sx { color: #c65d09 } /* Literal.String.Other */
|
||||
.codehilite .sr { color: #235388 } /* Literal.String.Regex */
|
||||
.codehilite .s1 { color: #4070a0 } /* Literal.String.Single */
|
||||
.codehilite .ss { color: #517918 } /* Literal.String.Symbol */
|
||||
.codehilite .bp { color: #007020 } /* Name.Builtin.Pseudo */
|
||||
.codehilite .fm { color: #06287e } /* Name.Function.Magic */
|
||||
.codehilite .vc { color: #bb60d5 } /* Name.Variable.Class */
|
||||
.codehilite .vg { color: #bb60d5 } /* Name.Variable.Global */
|
||||
.codehilite .vi { color: #bb60d5 } /* Name.Variable.Instance */
|
||||
.codehilite .vm { color: #bb60d5 } /* Name.Variable.Magic */
|
||||
.codehilite .il { color: #40a070 } /* Literal.Number.Integer.Long */
|
||||
171
lib-php/AddressDetails.php
Normal file
171
lib-php/AddressDetails.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_LibDir.'/ClassTypes.php');
|
||||
|
||||
/**
|
||||
* Detailed list of address parts for a single result
|
||||
*/
|
||||
class AddressDetails
|
||||
{
|
||||
private $iPlaceID;
|
||||
private $aAddressLines;
|
||||
|
||||
public function __construct(&$oDB, $iPlaceID, $sHousenumber, $mLangPref)
|
||||
{
|
||||
$this->iPlaceID = $iPlaceID;
|
||||
|
||||
if (is_array($mLangPref)) {
|
||||
$mLangPref = $oDB->getArraySQL($oDB->getDBQuotedList($mLangPref));
|
||||
}
|
||||
|
||||
if (!isset($sHousenumber)) {
|
||||
$sHousenumber = -1;
|
||||
}
|
||||
|
||||
$sSQL = 'SELECT *,';
|
||||
$sSQL .= ' get_name_by_language(name,'.$mLangPref.') as localname';
|
||||
$sSQL .= ' FROM get_addressdata('.$iPlaceID.','.$sHousenumber.')';
|
||||
$sSQL .= ' ORDER BY rank_address DESC, isaddress DESC';
|
||||
|
||||
$this->aAddressLines = $oDB->getAll($sSQL);
|
||||
}
|
||||
|
||||
private static function isAddress($aLine)
|
||||
{
|
||||
return $aLine['isaddress'] || $aLine['type'] == 'country_code';
|
||||
}
|
||||
|
||||
public function getAddressDetails($bAll = false)
|
||||
{
|
||||
if ($bAll) {
|
||||
return $this->aAddressLines;
|
||||
}
|
||||
|
||||
return array_filter($this->aAddressLines, array(__CLASS__, 'isAddress'));
|
||||
}
|
||||
|
||||
public function getLocaleAddress()
|
||||
{
|
||||
$aParts = array();
|
||||
$sPrevResult = '';
|
||||
|
||||
foreach ($this->aAddressLines as $aLine) {
|
||||
if ($aLine['isaddress'] && $sPrevResult != $aLine['localname']) {
|
||||
$sPrevResult = $aLine['localname'];
|
||||
$aParts[] = $sPrevResult;
|
||||
}
|
||||
}
|
||||
|
||||
return join(', ', $aParts);
|
||||
}
|
||||
|
||||
public function getAddressNames($sCountry = null)
|
||||
{
|
||||
$aAddress = array();
|
||||
|
||||
foreach ($this->aAddressLines as $aLine) {
|
||||
if (!self::isAddress($aLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sTypeLabel = ClassTypes\getLabelTag($aLine);
|
||||
|
||||
$sName = null;
|
||||
if (isset($aLine['localname']) && $aLine['localname']!=='') {
|
||||
$sName = $aLine['localname'];
|
||||
} elseif (isset($aLine['housenumber']) && $aLine['housenumber']!=='') {
|
||||
$sName = $aLine['housenumber'];
|
||||
}
|
||||
|
||||
if (isset($sName)) {
|
||||
$sTypeLabel = strtolower(str_replace(' ', '_', $sTypeLabel));
|
||||
if (!isset($aAddress[$sTypeLabel])
|
||||
|| $aLine['class'] == 'place'
|
||||
) {
|
||||
$aAddress[$sTypeLabel] = $sName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotates the given json with geocodejson address information fields.
|
||||
*
|
||||
* @param array $aJson Json hash to add the fields to.
|
||||
*
|
||||
* Geocodejson has the following fields:
|
||||
* street, locality, postcode, city, district,
|
||||
* county, state, country
|
||||
*
|
||||
* Postcode and housenumber are added by type, district is not used.
|
||||
* All other fields are set according to address rank.
|
||||
*/
|
||||
public function addGeocodeJsonAddressParts(&$aJson)
|
||||
{
|
||||
foreach (array_reverse($this->aAddressLines) as $aLine) {
|
||||
if (!$aLine['isaddress']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($aLine['localname']) || $aLine['localname'] == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($aLine['type'] == 'postcode' || $aLine['type'] == 'postal_code') {
|
||||
$aJson['postcode'] = $aLine['localname'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($aLine['type'] == 'house_number') {
|
||||
$aJson['housenumber'] = $aLine['localname'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->iPlaceID == $aLine['place_id']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$iRank = (int)$aLine['rank_address'];
|
||||
|
||||
if ($iRank > 25 && $iRank < 28) {
|
||||
$aJson['street'] = $aLine['localname'];
|
||||
} elseif ($iRank >= 22 && $iRank <= 25) {
|
||||
$aJson['locality'] = $aLine['localname'];
|
||||
} elseif ($iRank >= 17 && $iRank <= 21) {
|
||||
$aJson['district'] = $aLine['localname'];
|
||||
} elseif ($iRank >= 13 && $iRank <= 16) {
|
||||
$aJson['city'] = $aLine['localname'];
|
||||
} elseif ($iRank >= 10 && $iRank <= 12) {
|
||||
$aJson['county'] = $aLine['localname'];
|
||||
} elseif ($iRank >= 5 && $iRank <= 9) {
|
||||
$aJson['state'] = $aLine['localname'];
|
||||
} elseif ($iRank == 4) {
|
||||
$aJson['country'] = $aLine['localname'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdminLevels()
|
||||
{
|
||||
$aAddress = array();
|
||||
foreach (array_reverse($this->aAddressLines) as $aLine) {
|
||||
if (self::isAddress($aLine)
|
||||
&& isset($aLine['admin_level'])
|
||||
&& $aLine['admin_level'] < 15
|
||||
&& !isset($aAddress['level'.$aLine['admin_level']])
|
||||
) {
|
||||
$aAddress['level'.$aLine['admin_level']] = $aLine['localname'];
|
||||
}
|
||||
}
|
||||
return $aAddress;
|
||||
}
|
||||
|
||||
public function debugInfo()
|
||||
{
|
||||
return $this->aAddressLines;
|
||||
}
|
||||
}
|
||||
568
lib-php/ClassTypes.php
Normal file
568
lib-php/ClassTypes.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim\ClassTypes;
|
||||
|
||||
/**
|
||||
* Create a label tag for the given place that can be used as an XML name.
|
||||
*
|
||||
* @param array[] $aPlace Information about the place to label.
|
||||
*
|
||||
* A label tag groups various object types together under a common
|
||||
* label. The returned value is lower case and has no spaces
|
||||
*/
|
||||
function getLabelTag($aPlace, $sCountry = null)
|
||||
{
|
||||
$iRank = (int) ($aPlace['rank_address'] ?? 30);
|
||||
$sLabel;
|
||||
if (isset($aPlace['place_type'])) {
|
||||
$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) {
|
||||
$sLabel = 'road';
|
||||
} elseif ($aPlace['class'] == 'place'
|
||||
&& ($aPlace['type'] == 'house_number' ||
|
||||
$aPlace['type'] == 'house_name' ||
|
||||
$aPlace['type'] == 'country_code')
|
||||
) {
|
||||
$sLabel = $aPlace['type'];
|
||||
} else {
|
||||
$sLabel = $aPlace['class'];
|
||||
}
|
||||
|
||||
return strtolower(str_replace(' ', '_', $sLabel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a label for the given place.
|
||||
*
|
||||
* @param array[] $aPlace Information about the place to label.
|
||||
*/
|
||||
function getLabel($aPlace, $sCountry = null)
|
||||
{
|
||||
if (isset($aPlace['place_type'])) {
|
||||
return ucwords(str_replace('_', ' ', $aPlace['place_type']));
|
||||
}
|
||||
|
||||
if ($aPlace['class'] == 'boundary' && $aPlace['type'] == 'administrative') {
|
||||
return getBoundaryLabel(($aPlace['rank_address'] ?? 30)/2, $sCountry ?? null);
|
||||
}
|
||||
|
||||
// Return a label only for 'important' class/type combinations
|
||||
if (getImportance($aPlace) !== null) {
|
||||
return ucwords(str_replace('_', ' ', $aPlace['type']));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a simple label for an administrative boundary for the given country.
|
||||
*
|
||||
* @param int $iAdminLevel Content of admin_level tag.
|
||||
* @param string $sCountry Country code of the country where the object is
|
||||
* in. May be null, in which case a world-wide
|
||||
* fallback is used.
|
||||
* @param string $sFallback String to return if no explicit string is listed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getBoundaryLabel($iAdminLevel, $sCountry, $sFallback = 'Administrative')
|
||||
{
|
||||
static $aBoundaryList = array (
|
||||
'default' => array (
|
||||
1 => 'Continent',
|
||||
2 => 'Country',
|
||||
3 => 'Region',
|
||||
4 => 'State',
|
||||
5 => 'State District',
|
||||
6 => 'County',
|
||||
7 => 'Municipality',
|
||||
8 => 'City',
|
||||
9 => 'City District',
|
||||
10 => 'Suburb',
|
||||
11 => 'Neighbourhood',
|
||||
12 => 'City Block'
|
||||
),
|
||||
'no' => array (
|
||||
3 => 'State',
|
||||
4 => 'County'
|
||||
),
|
||||
'se' => array (
|
||||
3 => 'State',
|
||||
4 => 'County'
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($aBoundaryList[$sCountry])
|
||||
&& isset($aBoundaryList[$sCountry][$iAdminLevel])
|
||||
) {
|
||||
return $aBoundaryList[$sCountry][$iAdminLevel];
|
||||
}
|
||||
|
||||
return $aBoundaryList['default'][$iAdminLevel] ?? $sFallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an estimated radius of how far the object node extends.
|
||||
*
|
||||
* @param array[] $aPlace Information about the place. This must be a node
|
||||
* feature.
|
||||
*
|
||||
* @return float The radius around the feature in degrees.
|
||||
*/
|
||||
function getDefRadius($aPlace)
|
||||
{
|
||||
$aSpecialRadius = array(
|
||||
'place:continent' => 25,
|
||||
'place:country' => 7,
|
||||
'place:state' => 2.6,
|
||||
'place:province' => 2.6,
|
||||
'place:region' => 1.0,
|
||||
'place:county' => 0.7,
|
||||
'place:city' => 0.16,
|
||||
'place:municipality' => 0.16,
|
||||
'place:island' => 0.32,
|
||||
'place:postcode' => 0.16,
|
||||
'place:town' => 0.04,
|
||||
'place:village' => 0.02,
|
||||
'place:hamlet' => 0.02,
|
||||
'place:district' => 0.02,
|
||||
'place:borough' => 0.02,
|
||||
'place:suburb' => 0.02,
|
||||
'place:locality' => 0.01,
|
||||
'place:neighbourhood'=> 0.01,
|
||||
'place:quarter' => 0.01,
|
||||
'place:city_block' => 0.01,
|
||||
'landuse:farm' => 0.01,
|
||||
'place:farm' => 0.01,
|
||||
'place:airport' => 0.015,
|
||||
'aeroway:aerodrome' => 0.015,
|
||||
'railway:station' => 0.005
|
||||
);
|
||||
|
||||
$sClassPlace = $aPlace['class'].':'.$aPlace['type'];
|
||||
|
||||
return $aSpecialRadius[$sClassPlace] ?? 0.00005;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the icon to use with the given object.
|
||||
*/
|
||||
function getIcon($aPlace)
|
||||
{
|
||||
$aIcons = array(
|
||||
'boundary:administrative' => 'poi_boundary_administrative',
|
||||
'place:city' => 'poi_place_city',
|
||||
'place:town' => 'poi_place_town',
|
||||
'place:village' => 'poi_place_village',
|
||||
'place:hamlet' => 'poi_place_village',
|
||||
'place:suburb' => 'poi_place_village',
|
||||
'place:locality' => 'poi_place_village',
|
||||
'place:airport' => 'transport_airport2',
|
||||
'aeroway:aerodrome' => 'transport_airport2',
|
||||
'railway:station' => 'transport_train_station2',
|
||||
'amenity:place_of_worship' => 'place_of_worship_unknown3',
|
||||
'amenity:pub' => 'food_pub',
|
||||
'amenity:bar' => 'food_bar',
|
||||
'amenity:university' => 'education_university',
|
||||
'tourism:museum' => 'tourist_museum',
|
||||
'amenity:arts_centre' => 'tourist_art_gallery2',
|
||||
'tourism:zoo' => 'tourist_zoo',
|
||||
'tourism:theme_park' => 'poi_point_of_interest',
|
||||
'tourism:attraction' => 'poi_point_of_interest',
|
||||
'leisure:golf_course' => 'sport_golf',
|
||||
'historic:castle' => 'tourist_castle',
|
||||
'amenity:hospital' => 'health_hospital',
|
||||
'amenity:school' => 'education_school',
|
||||
'amenity:theatre' => 'tourist_theatre',
|
||||
'amenity:library' => 'amenity_library',
|
||||
'amenity:fire_station' => 'amenity_firestation3',
|
||||
'amenity:police' => 'amenity_police2',
|
||||
'amenity:bank' => 'money_bank2',
|
||||
'amenity:post_office' => 'amenity_post_office',
|
||||
'tourism:hotel' => 'accommodation_hotel2',
|
||||
'amenity:cinema' => 'tourist_cinema',
|
||||
'tourism:artwork' => 'tourist_art_gallery2',
|
||||
'historic:archaeological_site' => 'tourist_archaeological2',
|
||||
'amenity:doctors' => 'health_doctors',
|
||||
'leisure:sports_centre' => 'sport_leisure_centre',
|
||||
'leisure:swimming_pool' => 'sport_swimming_outdoor',
|
||||
'shop:supermarket' => 'shopping_supermarket',
|
||||
'shop:convenience' => 'shopping_convenience',
|
||||
'amenity:restaurant' => 'food_restaurant',
|
||||
'amenity:fast_food' => 'food_fastfood',
|
||||
'amenity:cafe' => 'food_cafe',
|
||||
'tourism:guest_house' => 'accommodation_bed_and_breakfast',
|
||||
'amenity:pharmacy' => 'health_pharmacy_dispensing',
|
||||
'amenity:fuel' => 'transport_fuel',
|
||||
'natural:peak' => 'poi_peak',
|
||||
'natural:wood' => 'landuse_coniferous_and_deciduous',
|
||||
'shop:bicycle' => 'shopping_bicycle',
|
||||
'shop:clothes' => 'shopping_clothes',
|
||||
'shop:hairdresser' => 'shopping_hairdresser',
|
||||
'shop:doityourself' => 'shopping_diy',
|
||||
'shop:estate_agent' => 'shopping_estateagent2',
|
||||
'shop:car' => 'shopping_car',
|
||||
'shop:garden_centre' => 'shopping_garden_centre',
|
||||
'shop:car_repair' => 'shopping_car_repair',
|
||||
'shop:bakery' => 'shopping_bakery',
|
||||
'shop:butcher' => 'shopping_butcher',
|
||||
'shop:apparel' => 'shopping_clothes',
|
||||
'shop:laundry' => 'shopping_laundrette',
|
||||
'shop:beverages' => 'shopping_alcohol',
|
||||
'shop:alcohol' => 'shopping_alcohol',
|
||||
'shop:optician' => 'health_opticians',
|
||||
'shop:chemist' => 'health_pharmacy',
|
||||
'shop:gallery' => 'tourist_art_gallery2',
|
||||
'shop:jewelry' => 'shopping_jewelry',
|
||||
'tourism:information' => 'amenity_information',
|
||||
'historic:ruins' => 'tourist_ruin',
|
||||
'amenity:college' => 'education_school',
|
||||
'historic:monument' => 'tourist_monument',
|
||||
'historic:memorial' => 'tourist_monument',
|
||||
'historic:mine' => 'poi_mine',
|
||||
'tourism:caravan_site' => 'accommodation_caravan_park',
|
||||
'amenity:bus_station' => 'transport_bus_station',
|
||||
'amenity:atm' => 'money_atm2',
|
||||
'tourism:viewpoint' => 'tourist_view_point',
|
||||
'tourism:guesthouse' => 'accommodation_bed_and_breakfast',
|
||||
'railway:tram' => 'transport_tram_stop',
|
||||
'amenity:courthouse' => 'amenity_court',
|
||||
'amenity:recycling' => 'amenity_recycling',
|
||||
'amenity:dentist' => 'health_dentist',
|
||||
'natural:beach' => 'tourist_beach',
|
||||
'railway:tram_stop' => 'transport_tram_stop',
|
||||
'amenity:prison' => 'amenity_prison',
|
||||
'highway:bus_stop' => 'transport_bus_stop2'
|
||||
);
|
||||
|
||||
$sClassPlace = $aPlace['class'].':'.$aPlace['type'];
|
||||
|
||||
return $aIcons[$sClassPlace] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an icon for the given object with its full URL.
|
||||
*/
|
||||
function getIconFile($aPlace)
|
||||
{
|
||||
if (CONST_MapIcon_URL === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sIcon = getIcon($aPlace);
|
||||
|
||||
if (!isset($sIcon)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CONST_MapIcon_URL.'/'.$sIcon.'.p.20.png';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a class importance value for the given place.
|
||||
*
|
||||
* @param array[] $aPlace Information about the place.
|
||||
*
|
||||
* @return int An importance value. The lower the value, the more
|
||||
* important the class.
|
||||
*/
|
||||
function getImportance($aPlace)
|
||||
{
|
||||
static $aWithImportance = null;
|
||||
|
||||
if ($aWithImportance === null) {
|
||||
$aWithImportance = array_flip(array(
|
||||
'boundary:administrative',
|
||||
'place:country',
|
||||
'place:state',
|
||||
'place:province',
|
||||
'place:county',
|
||||
'place:city',
|
||||
'place:region',
|
||||
'place:island',
|
||||
'place:town',
|
||||
'place:village',
|
||||
'place:hamlet',
|
||||
'place:suburb',
|
||||
'place:locality',
|
||||
'landuse:farm',
|
||||
'place:farm',
|
||||
'highway:motorway_junction',
|
||||
'highway:motorway',
|
||||
'highway:trunk',
|
||||
'highway:primary',
|
||||
'highway:secondary',
|
||||
'highway:tertiary',
|
||||
'highway:residential',
|
||||
'highway:unclassified',
|
||||
'highway:living_street',
|
||||
'highway:service',
|
||||
'highway:track',
|
||||
'highway:road',
|
||||
'highway:byway',
|
||||
'highway:bridleway',
|
||||
'highway:cycleway',
|
||||
'highway:pedestrian',
|
||||
'highway:footway',
|
||||
'highway:steps',
|
||||
'highway:motorway_link',
|
||||
'highway:trunk_link',
|
||||
'highway:primary_link',
|
||||
'landuse:industrial',
|
||||
'landuse:residential',
|
||||
'landuse:retail',
|
||||
'landuse:commercial',
|
||||
'place:airport',
|
||||
'aeroway:aerodrome',
|
||||
'railway:station',
|
||||
'amenity:place_of_worship',
|
||||
'amenity:pub',
|
||||
'amenity:bar',
|
||||
'amenity:university',
|
||||
'tourism:museum',
|
||||
'amenity:arts_centre',
|
||||
'tourism:zoo',
|
||||
'tourism:theme_park',
|
||||
'tourism:attraction',
|
||||
'leisure:golf_course',
|
||||
'historic:castle',
|
||||
'amenity:hospital',
|
||||
'amenity:school',
|
||||
'amenity:theatre',
|
||||
'amenity:public_building',
|
||||
'amenity:library',
|
||||
'amenity:townhall',
|
||||
'amenity:community_centre',
|
||||
'amenity:fire_station',
|
||||
'amenity:police',
|
||||
'amenity:bank',
|
||||
'amenity:post_office',
|
||||
'leisure:park',
|
||||
'amenity:park',
|
||||
'landuse:park',
|
||||
'landuse:recreation_ground',
|
||||
'tourism:hotel',
|
||||
'tourism:motel',
|
||||
'amenity:cinema',
|
||||
'tourism:artwork',
|
||||
'historic:archaeological_site',
|
||||
'amenity:doctors',
|
||||
'leisure:sports_centre',
|
||||
'leisure:swimming_pool',
|
||||
'shop:supermarket',
|
||||
'shop:convenience',
|
||||
'amenity:restaurant',
|
||||
'amenity:fast_food',
|
||||
'amenity:cafe',
|
||||
'tourism:guest_house',
|
||||
'amenity:pharmacy',
|
||||
'amenity:fuel',
|
||||
'natural:peak',
|
||||
'waterway:waterfall',
|
||||
'natural:wood',
|
||||
'natural:water',
|
||||
'landuse:forest',
|
||||
'landuse:cemetery',
|
||||
'landuse:allotments',
|
||||
'landuse:farmyard',
|
||||
'railway:rail',
|
||||
'waterway:canal',
|
||||
'waterway:river',
|
||||
'waterway:stream',
|
||||
'shop:bicycle',
|
||||
'shop:clothes',
|
||||
'shop:hairdresser',
|
||||
'shop:doityourself',
|
||||
'shop:estate_agent',
|
||||
'shop:car',
|
||||
'shop:garden_centre',
|
||||
'shop:car_repair',
|
||||
'shop:newsagent',
|
||||
'shop:bakery',
|
||||
'shop:furniture',
|
||||
'shop:butcher',
|
||||
'shop:apparel',
|
||||
'shop:electronics',
|
||||
'shop:department_store',
|
||||
'shop:books',
|
||||
'shop:yes',
|
||||
'shop:outdoor',
|
||||
'shop:mall',
|
||||
'shop:florist',
|
||||
'shop:charity',
|
||||
'shop:hardware',
|
||||
'shop:laundry',
|
||||
'shop:shoes',
|
||||
'shop:beverages',
|
||||
'shop:dry_cleaning',
|
||||
'shop:carpet',
|
||||
'shop:computer',
|
||||
'shop:alcohol',
|
||||
'shop:optician',
|
||||
'shop:chemist',
|
||||
'shop:gallery',
|
||||
'shop:mobile_phone',
|
||||
'shop:sports',
|
||||
'shop:jewelry',
|
||||
'shop:pet',
|
||||
'shop:beauty',
|
||||
'shop:stationery',
|
||||
'shop:shopping_centre',
|
||||
'shop:general',
|
||||
'shop:electrical',
|
||||
'shop:toys',
|
||||
'shop:jeweller',
|
||||
'shop:betting',
|
||||
'shop:household',
|
||||
'shop:travel_agency',
|
||||
'shop:hifi',
|
||||
'amenity:shop',
|
||||
'tourism:information',
|
||||
'place:house',
|
||||
'place:house_name',
|
||||
'place:house_number',
|
||||
'place:country_code',
|
||||
'leisure:pitch',
|
||||
'highway:unsurfaced',
|
||||
'historic:ruins',
|
||||
'amenity:college',
|
||||
'historic:monument',
|
||||
'railway:subway',
|
||||
'historic:memorial',
|
||||
'leisure:nature_reserve',
|
||||
'leisure:common',
|
||||
'waterway:lock_gate',
|
||||
'natural:fell',
|
||||
'amenity:nightclub',
|
||||
'highway:path',
|
||||
'leisure:garden',
|
||||
'landuse:reservoir',
|
||||
'leisure:playground',
|
||||
'leisure:stadium',
|
||||
'historic:mine',
|
||||
'natural:cliff',
|
||||
'tourism:caravan_site',
|
||||
'amenity:bus_station',
|
||||
'amenity:kindergarten',
|
||||
'highway:construction',
|
||||
'amenity:atm',
|
||||
'amenity:emergency_phone',
|
||||
'waterway:lock',
|
||||
'waterway:riverbank',
|
||||
'natural:coastline',
|
||||
'tourism:viewpoint',
|
||||
'tourism:hostel',
|
||||
'tourism:bed_and_breakfast',
|
||||
'railway:halt',
|
||||
'railway:platform',
|
||||
'railway:tram',
|
||||
'amenity:courthouse',
|
||||
'amenity:recycling',
|
||||
'amenity:dentist',
|
||||
'natural:beach',
|
||||
'place:moor',
|
||||
'amenity:grave_yard',
|
||||
'waterway:drain',
|
||||
'landuse:grass',
|
||||
'landuse:village_green',
|
||||
'natural:bay',
|
||||
'railway:tram_stop',
|
||||
'leisure:marina',
|
||||
'highway:stile',
|
||||
'natural:moor',
|
||||
'railway:light_rail',
|
||||
'railway:narrow_gauge',
|
||||
'natural:land',
|
||||
'amenity:village_hall',
|
||||
'waterway:dock',
|
||||
'amenity:veterinary',
|
||||
'landuse:brownfield',
|
||||
'leisure:track',
|
||||
'railway:historic_station',
|
||||
'landuse:construction',
|
||||
'amenity:prison',
|
||||
'landuse:quarry',
|
||||
'amenity:telephone',
|
||||
'highway:traffic_signals',
|
||||
'natural:heath',
|
||||
'historic:house',
|
||||
'amenity:social_club',
|
||||
'landuse:military',
|
||||
'amenity:health_centre',
|
||||
'historic:building',
|
||||
'amenity:clinic',
|
||||
'highway:services',
|
||||
'amenity:ferry_terminal',
|
||||
'natural:marsh',
|
||||
'natural:hill',
|
||||
'highway:raceway',
|
||||
'amenity:taxi',
|
||||
'amenity:take_away',
|
||||
'amenity:car_rental',
|
||||
'place:islet',
|
||||
'amenity:nursery',
|
||||
'amenity:nursing_home',
|
||||
'amenity:toilets',
|
||||
'amenity:hall',
|
||||
'waterway:boatyard',
|
||||
'highway:mini_roundabout',
|
||||
'historic:manor',
|
||||
'tourism:chalet',
|
||||
'amenity:bicycle_parking',
|
||||
'amenity:hotel',
|
||||
'waterway:weir',
|
||||
'natural:wetland',
|
||||
'natural:cave_entrance',
|
||||
'amenity:crematorium',
|
||||
'tourism:picnic_site',
|
||||
'landuse:wood',
|
||||
'landuse:basin',
|
||||
'natural:tree',
|
||||
'leisure:slipway',
|
||||
'landuse:meadow',
|
||||
'landuse:piste',
|
||||
'amenity:care_home',
|
||||
'amenity:club',
|
||||
'amenity:medical_centre',
|
||||
'historic:roman_road',
|
||||
'historic:fort',
|
||||
'railway:subway_entrance',
|
||||
'historic:yes',
|
||||
'highway:gate',
|
||||
'leisure:fishing',
|
||||
'historic:museum',
|
||||
'amenity:car_wash',
|
||||
'railway:level_crossing',
|
||||
'leisure:bird_hide',
|
||||
'natural:headland',
|
||||
'tourism:apartments',
|
||||
'amenity:shopping',
|
||||
'natural:scrub',
|
||||
'natural:fen',
|
||||
'building:yes',
|
||||
'mountain_pass:yes',
|
||||
'amenity:parking',
|
||||
'highway:bus_stop',
|
||||
'place:postcode',
|
||||
'amenity:post_box',
|
||||
'place:houses',
|
||||
'railway:preserved',
|
||||
'waterway:derelict_canal',
|
||||
'amenity:dead_pub',
|
||||
'railway:disused_station',
|
||||
'railway:abandoned',
|
||||
'railway:disused'
|
||||
));
|
||||
}
|
||||
|
||||
$sClassPlace = $aPlace['class'].':'.$aPlace['type'];
|
||||
|
||||
return $aWithImportance[$sClassPlace] ?? null;
|
||||
}
|
||||
341
lib-php/DB.php
Normal file
341
lib-php/DB.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_LibDir.'/DatabaseError.php');
|
||||
|
||||
/**
|
||||
* Uses PDO to access the database specified in the CONST_Database_DSN
|
||||
* setting.
|
||||
*/
|
||||
class DB
|
||||
{
|
||||
protected $connection;
|
||||
|
||||
public function __construct($sDSN = null)
|
||||
{
|
||||
$this->sDSN = $sDSN ?? getSetting('DATABASE_DSN');
|
||||
}
|
||||
|
||||
public function connect($bNew = false, $bPersistent = true)
|
||||
{
|
||||
if (isset($this->connection) && !$bNew) {
|
||||
return true;
|
||||
}
|
||||
$aConnOptions = array(
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
||||
\PDO::ATTR_PERSISTENT => $bPersistent
|
||||
);
|
||||
|
||||
// https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
|
||||
try {
|
||||
$conn = new \PDO($this->sDSN, null, null, $aConnOptions);
|
||||
} catch (\PDOException $e) {
|
||||
$sMsg = 'Failed to establish database connection:' . $e->getMessage();
|
||||
throw new \Nominatim\DatabaseError($sMsg, 500, null, $e->getMessage());
|
||||
}
|
||||
|
||||
$conn->exec("SET DateStyle TO 'sql,european'");
|
||||
$conn->exec("SET client_encoding TO 'utf-8'");
|
||||
$iMaxExecution = ini_get('max_execution_time');
|
||||
if ($iMaxExecution > 0) $conn->setAttribute(\PDO::ATTR_TIMEOUT, $iMaxExecution); // seconds
|
||||
|
||||
$this->connection = $conn;
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns the number of rows that were modified or deleted by the SQL
|
||||
// statement. If no rows were affected returns 0.
|
||||
public function exec($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
$val = null;
|
||||
try {
|
||||
if (isset($aInputVars)) {
|
||||
$stmt = $this->connection->prepare($sSQL);
|
||||
$stmt->execute($aInputVars);
|
||||
} else {
|
||||
$val = $this->connection->exec($sSQL);
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns first row as array.
|
||||
* Returns false if no result found.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getRow($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
try {
|
||||
$stmt = $this->getQueryStatement($sSQL, $aInputVars, $sErrMessage);
|
||||
$row = $stmt->fetch();
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns first value of first result.
|
||||
* Returns false if no results found.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getOne($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
try {
|
||||
$stmt = $this->getQueryStatement($sSQL, $aInputVars, $sErrMessage);
|
||||
$row = $stmt->fetch(\PDO::FETCH_NUM);
|
||||
if ($row === false) return false;
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns array of results (arrays).
|
||||
* Returns empty array if no results found.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getAll($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
try {
|
||||
$stmt = $this->getQueryStatement($sSQL, $aInputVars, $sErrMessage);
|
||||
$rows = $stmt->fetchAll();
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns array of the first value of each result.
|
||||
* Returns empty array if no results found.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getCol($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
$aVals = array();
|
||||
try {
|
||||
$stmt = $this->getQueryStatement($sSQL, $aInputVars, $sErrMessage);
|
||||
|
||||
while (($val = $stmt->fetchColumn(0)) !== false) { // returns first column or false
|
||||
$aVals[] = $val;
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $aVals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns associate array mapping first value to second value of each result.
|
||||
* Returns empty array if no results found.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getAssoc($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
try {
|
||||
$stmt = $this->getQueryStatement($sSQL, $aInputVars, $sErrMessage);
|
||||
|
||||
$aList = array();
|
||||
while ($aRow = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$aList[$aRow[0]] = $aRow[1];
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $aList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query. Returns a PDO statement to iterate over.
|
||||
*
|
||||
* @param string $sSQL
|
||||
*
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public function getQueryStatement($sSQL, $aInputVars = null, $sErrMessage = 'Database query failed')
|
||||
{
|
||||
try {
|
||||
if (isset($aInputVars)) {
|
||||
$stmt = $this->connection->prepare($sSQL);
|
||||
$stmt->execute($aInputVars);
|
||||
} else {
|
||||
$stmt = $this->connection->query($sSQL);
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new \Nominatim\DatabaseError($sErrMessage, 500, null, $e, $sSQL);
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* St. John's Way => 'St. John\'s Way'
|
||||
*
|
||||
* @param string $sVal Text to be quoted.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDBQuoted($sVal)
|
||||
{
|
||||
return $this->connection->quote($sVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like getDBQuoted, but takes an array.
|
||||
*
|
||||
* @param array $aVals List of text to be quoted.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getDBQuotedList($aVals)
|
||||
{
|
||||
return array_map(function ($sVal) {
|
||||
return $this->getDBQuoted($sVal);
|
||||
}, $aVals);
|
||||
}
|
||||
|
||||
/**
|
||||
* [1,2,'b'] => 'ARRAY[1,2,'b']''
|
||||
*
|
||||
* @param array $aVals List of text to be quoted.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getArraySQL($a)
|
||||
{
|
||||
return 'ARRAY['.join(',', $a).']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a table exists in the database. Returns true if it does.
|
||||
*
|
||||
* @param string $sTableName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function tableExists($sTableName)
|
||||
{
|
||||
$sSQL = 'SELECT count(*) FROM pg_tables WHERE tablename = :tablename';
|
||||
return ($this->getOne($sSQL, array(':tablename' => $sTableName)) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a table. Returns true if deleted or didn't exist.
|
||||
*
|
||||
* @param string $sTableName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function deleteTable($sTableName)
|
||||
{
|
||||
return $this->exec('DROP TABLE IF EXISTS '.$sTableName.' CASCADE') == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to connect to the database but on failure doesn't throw an exception.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkConnection()
|
||||
{
|
||||
$bExists = true;
|
||||
try {
|
||||
$this->connect(true);
|
||||
} catch (\Nominatim\DatabaseError $e) {
|
||||
$bExists = false;
|
||||
}
|
||||
return $bExists;
|
||||
}
|
||||
|
||||
/**
|
||||
* e.g. 9.6, 10, 11.2
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPostgresVersion()
|
||||
{
|
||||
$sVersionString = $this->getOne('SHOW server_version_num');
|
||||
preg_match('#([0-9]?[0-9])([0-9][0-9])[0-9][0-9]#', $sVersionString, $aMatches);
|
||||
return (float) ($aMatches[1].'.'.$aMatches[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* e.g. 2, 2.2
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPostgisVersion()
|
||||
{
|
||||
$sVersionString = $this->getOne('select postgis_lib_version()');
|
||||
preg_match('#^([0-9]+)[.]([0-9]+)[.]#', $sVersionString, $aMatches);
|
||||
return (float) ($aMatches[1].'.'.$aMatches[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an associate array of postgresql database connection settings. Keys can
|
||||
* be 'database', 'hostspec', 'port', 'username', 'password'.
|
||||
* Returns empty array on failure, thus check if at least 'database' is set.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public static function parseDSN($sDSN)
|
||||
{
|
||||
// https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
|
||||
$aInfo = array();
|
||||
if (preg_match('/^pgsql:(.+)$/', $sDSN, $aMatches)) {
|
||||
foreach (explode(';', $aMatches[1]) as $sKeyVal) {
|
||||
list($sKey, $sVal) = explode('=', $sKeyVal, 2);
|
||||
if ($sKey == 'host') $sKey = 'hostspec';
|
||||
if ($sKey == 'dbname') $sKey = 'database';
|
||||
if ($sKey == 'user') $sKey = 'username';
|
||||
$aInfo[$sKey] = $sVal;
|
||||
}
|
||||
}
|
||||
return $aInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an array of settings and return the DNS string. Key names can be
|
||||
* 'database', 'hostspec', 'port', 'username', 'password' but aliases
|
||||
* 'dbname', 'host' and 'user' are also supported.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public static function generateDSN($aInfo)
|
||||
{
|
||||
$sDSN = sprintf(
|
||||
'pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s;',
|
||||
$aInfo['host'] ?? $aInfo['hostspec'] ?? '',
|
||||
$aInfo['port'] ?? '',
|
||||
$aInfo['dbname'] ?? $aInfo['database'] ?? '',
|
||||
$aInfo['user'] ?? '',
|
||||
$aInfo['password'] ?? ''
|
||||
);
|
||||
$sDSN = preg_replace('/\b\w+=;/', '', $sDSN);
|
||||
$sDSN = preg_replace('/;\Z/', '', $sDSN);
|
||||
|
||||
return $sDSN;
|
||||
}
|
||||
}
|
||||
34
lib-php/DatabaseError.php
Normal file
34
lib-php/DatabaseError.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
class DatabaseError extends \Exception
|
||||
{
|
||||
|
||||
public function __construct($message, $code = 500, Exception $previous = null, $oPDOErr, $sSql = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
// https://secure.php.net/manual/en/class.pdoexception.php
|
||||
$this->oPDOErr = $oPDOErr;
|
||||
$this->sSql = $sSql;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
|
||||
public function getSqlError()
|
||||
{
|
||||
return $this->oPDOErr->getMessage();
|
||||
}
|
||||
|
||||
public function getSqlDebugDump()
|
||||
{
|
||||
if (CONST_Debug) {
|
||||
return var_export($this->oPDOErr, true);
|
||||
} else {
|
||||
return $this->sSql;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class Debug
|
||||
|
||||
public static function printSQL($sSQL)
|
||||
{
|
||||
echo '<p><tt><font color="#aaa">'.$sSQL.'</font></tt></p>'."\n";
|
||||
echo '<p><tt><font color="#aaa">'.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'</font></tt></p>'."\n";
|
||||
}
|
||||
|
||||
private static function outputVar($mVar, $sPreNL)
|
||||
@@ -170,11 +170,12 @@ class Debug
|
||||
}
|
||||
|
||||
if (is_string($mVar)) {
|
||||
echo "'$mVar'";
|
||||
return strlen($mVar) + 2;
|
||||
$sOut = "'$mVar'";
|
||||
} else {
|
||||
$sOut = (string)$mVar;
|
||||
}
|
||||
|
||||
echo (string)$mVar;
|
||||
return strlen((string)$mVar);
|
||||
echo htmlspecialchars($sOut, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401);
|
||||
return strlen($sOut);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/Phrase.php');
|
||||
require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
|
||||
require_once(CONST_BasePath.'/lib/SearchDescription.php');
|
||||
require_once(CONST_BasePath.'/lib/SearchContext.php');
|
||||
require_once(CONST_BasePath.'/lib/TokenList.php');
|
||||
require_once(CONST_LibDir.'/PlaceLookup.php');
|
||||
require_once(CONST_LibDir.'/Phrase.php');
|
||||
require_once(CONST_LibDir.'/ReverseGeocode.php');
|
||||
require_once(CONST_LibDir.'/SearchDescription.php');
|
||||
require_once(CONST_LibDir.'/SearchContext.php');
|
||||
require_once(CONST_LibDir.'/TokenList.php');
|
||||
|
||||
class Geocode
|
||||
{
|
||||
@@ -18,7 +18,7 @@ class Geocode
|
||||
protected $aLangPrefOrder = array();
|
||||
|
||||
protected $aExcludePlaceIDs = array();
|
||||
protected $bReverseInPlan = false;
|
||||
protected $bReverseInPlan = true;
|
||||
|
||||
protected $iLimit = 20;
|
||||
protected $iFinalLimit = 10;
|
||||
@@ -245,7 +245,6 @@ class Geocode
|
||||
}
|
||||
|
||||
$this->oPlaceLookup->loadParamArray($oParams, $sForceGeometryType);
|
||||
$this->oPlaceLookup->setIncludePolygonAsPoints($oParams->getBool('polygon'));
|
||||
$this->oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', false));
|
||||
}
|
||||
|
||||
@@ -348,10 +347,7 @@ class Geocode
|
||||
$aNewPhraseSearches = array();
|
||||
$sPhraseType = $bIsStructured ? $oPhrase->getPhraseType() : '';
|
||||
|
||||
foreach ($oPhrase->getWordSets() as $iWordSet => $aWordset) {
|
||||
// Too many permutations - too expensive
|
||||
if ($iWordSet > 120) break;
|
||||
|
||||
foreach ($oPhrase->getWordSets() as $aWordset) {
|
||||
$aWordsetSearches = $aSearches;
|
||||
|
||||
// Add all words from this wordset
|
||||
@@ -527,8 +523,8 @@ class Geocode
|
||||
$sNormQuery = $this->normTerm($this->sQuery);
|
||||
Debug::printVar('Normalized query', $sNormQuery);
|
||||
|
||||
$sLanguagePrefArraySQL = getArraySQL(
|
||||
array_map('getDBQuoted', $this->aLangPrefOrder)
|
||||
$sLanguagePrefArraySQL = $this->oDB->getArraySQL(
|
||||
$this->oDB->getDBQuotedList($this->aLangPrefOrder)
|
||||
);
|
||||
|
||||
$sQuery = $this->sQuery;
|
||||
@@ -546,7 +542,6 @@ class Geocode
|
||||
// Do we have anything that looks like a lat/lon pair?
|
||||
$sQuery = $oCtx->setNearPointFromQuery($sQuery);
|
||||
|
||||
$aResults = array();
|
||||
if ($sQuery || $this->aStructuredQuery) {
|
||||
// Start with a single blank search
|
||||
$aSearches = array(new SearchDescription($oCtx));
|
||||
@@ -582,8 +577,9 @@ class Geocode
|
||||
|
||||
if ($sSpecialTerm && !$aSearches[0]->hasOperator()) {
|
||||
$sSpecialTerm = pg_escape_string($sSpecialTerm);
|
||||
$sToken = chksql(
|
||||
$this->oDB->getOne("SELECT make_standard_name('$sSpecialTerm')"),
|
||||
$sToken = $this->oDB->getOne(
|
||||
'SELECT make_standard_name(:term)',
|
||||
array(':term' => $sSpecialTerm),
|
||||
'Cannot decode query. Wrong encoding?'
|
||||
);
|
||||
$sSQL = 'SELECT class, type FROM word ';
|
||||
@@ -591,7 +587,7 @@ class Geocode
|
||||
$sSQL .= ' AND class is not null AND class not in (\'place\')';
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
$aSearchWords = chksql($this->oDB->getAll($sSQL));
|
||||
$aSearchWords = $this->oDB->getAll($sSQL);
|
||||
$aNewSearches = array();
|
||||
foreach ($aSearches as $oSearch) {
|
||||
foreach ($aSearchWords as $aSearchTerm) {
|
||||
@@ -629,8 +625,9 @@ class Geocode
|
||||
$aTokens = array();
|
||||
$aPhrases = array();
|
||||
foreach ($aInPhrases as $iPhrase => $sPhrase) {
|
||||
$sPhrase = chksql(
|
||||
$this->oDB->getOne('SELECT make_standard_name('.getDBQuoted($sPhrase).')'),
|
||||
$sPhrase = $this->oDB->getOne(
|
||||
'SELECT make_standard_name(:phrase)',
|
||||
array(':phrase' => $sPhrase),
|
||||
'Cannot normalize query string (is it a UTF-8 string?)'
|
||||
);
|
||||
if (trim($sPhrase)) {
|
||||
@@ -640,18 +637,11 @@ class Geocode
|
||||
}
|
||||
}
|
||||
|
||||
Debug::printDebugTable('Phrases', $aPhrases);
|
||||
Debug::printVar('Tokens', $aTokens);
|
||||
|
||||
$oValidTokens = new TokenList();
|
||||
|
||||
if (!empty($aTokens)) {
|
||||
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count';
|
||||
$sSQL .= ' FROM word ';
|
||||
$sSQL .= ' WHERE word_token in ('.join(',', array_map('getDBQuoted', $aTokens)).')';
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$oValidTokens->addTokensFromDB(
|
||||
$this->oDB,
|
||||
$aTokens,
|
||||
@@ -660,6 +650,8 @@ class Geocode
|
||||
$this->oNormalizer
|
||||
);
|
||||
|
||||
$oCtx->setFullNameWords($oValidTokens->getFullWordIDs());
|
||||
|
||||
// Try more interpretations for Tokens that could not be matched.
|
||||
foreach ($aTokens as $sToken) {
|
||||
if ($sToken[0] == ' ' && !$oValidTokens->contains($sToken)) {
|
||||
@@ -685,6 +677,11 @@ class Geocode
|
||||
|
||||
Debug::printGroupTable('Valid Tokens', $oValidTokens->debugInfo());
|
||||
|
||||
foreach ($aPhrases as $oPhrase) {
|
||||
$oPhrase->computeWordSets($oValidTokens);
|
||||
}
|
||||
Debug::printDebugTable('Phrases', $aPhrases);
|
||||
|
||||
Debug::newSection('Search candidates');
|
||||
|
||||
$aGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $oValidTokens, $bStructuredPhrases);
|
||||
@@ -746,8 +743,10 @@ class Geocode
|
||||
// Start the search process
|
||||
$iGroupLoop = 0;
|
||||
$iQueryLoop = 0;
|
||||
$aNextResults = array();
|
||||
foreach ($aGroupedSearches as $iGroupedRank => $aSearches) {
|
||||
$iGroupLoop++;
|
||||
$aResults = $aNextResults;
|
||||
foreach ($aSearches as $oSearch) {
|
||||
$iQueryLoop++;
|
||||
|
||||
@@ -757,16 +756,47 @@ class Geocode
|
||||
$oValidTokens->debugTokenByWordIdList()
|
||||
);
|
||||
|
||||
$aResults += $oSearch->query(
|
||||
$aNewResults = $oSearch->query(
|
||||
$this->oDB,
|
||||
$this->iMinAddressRank,
|
||||
$this->iMaxAddressRank,
|
||||
$this->iLimit
|
||||
);
|
||||
|
||||
// The same result may appear in different rounds, only
|
||||
// use the one with minimal rank.
|
||||
foreach ($aNewResults as $iPlace => $oRes) {
|
||||
if (!isset($aResults[$iPlace])
|
||||
|| $aResults[$iPlace]->iResultRank > $oRes->iResultRank) {
|
||||
$aResults[$iPlace] = $oRes;
|
||||
}
|
||||
}
|
||||
|
||||
if ($iQueryLoop > 20) break;
|
||||
}
|
||||
|
||||
if (!empty($aResults)) {
|
||||
$aSplitResults = Result::splitResults($aResults);
|
||||
Debug::printVar('Split results', $aSplitResults);
|
||||
if ($iGroupLoop <= 4
|
||||
&& reset($aSplitResults['head'])->iResultRank > 0
|
||||
&& $iGroupedRank !== array_key_last($aGroupedSearches)) {
|
||||
// Haven't found an exact match for the query yet.
|
||||
// Therefore add result from the next group level.
|
||||
$aNextResults = $aSplitResults['head'];
|
||||
foreach ($aNextResults as $oRes) {
|
||||
$oRes->iResultRank--;
|
||||
}
|
||||
foreach ($aSplitResults['tail'] as $oRes) {
|
||||
$oRes->iResultRank--;
|
||||
$aNextResults[$oRes->iId] = $oRes;
|
||||
}
|
||||
$aResults = array();
|
||||
} else {
|
||||
$aResults = $aSplitResults['head'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
|
||||
// Need to verify passes rank limits before dropping out of the loop (yuk!)
|
||||
// reduces the number of place ids, like a filter
|
||||
@@ -778,9 +808,7 @@ class Geocode
|
||||
$sSQL .= 'WHERE place_id in ('.$sPlaceIds.') ';
|
||||
$sSQL .= ' AND (';
|
||||
$sSQL .= " placex.rank_address between $this->iMinAddressRank and $this->iMaxAddressRank ";
|
||||
if (14 >= $this->iMinAddressRank && 14 <= $this->iMaxAddressRank) {
|
||||
$sSQL .= " OR (extratags->'place') = 'city'";
|
||||
}
|
||||
$sSQL .= " OR placex.rank_search between $this->iMinAddressRank and $this->iMaxAddressRank ";
|
||||
if ($this->aAddressRankList) {
|
||||
$sSQL .= ' OR placex.rank_address in ('.join(',', $this->aAddressRankList).')';
|
||||
}
|
||||
@@ -803,7 +831,7 @@ class Geocode
|
||||
if ($aFilterSql) {
|
||||
$sSQL = join(' UNION ', $aFilterSql);
|
||||
Debug::printSQL($sSQL);
|
||||
$aFilteredIDs = chksql($this->oDB->getCol($sSQL));
|
||||
$aFilteredIDs = $this->oDB->getCol($sSQL);
|
||||
}
|
||||
|
||||
$tempIDs = array();
|
||||
@@ -860,7 +888,6 @@ class Geocode
|
||||
|
||||
$aSearchResults = $this->oPlaceLookup->lookup($aResults);
|
||||
|
||||
$aClassType = ClassTypes\getListWithImportance();
|
||||
$aRecheckWords = preg_split('/\b[\s,\\-]*/u', $sQuery);
|
||||
foreach ($aRecheckWords as $i => $sWord) {
|
||||
if (!preg_match('/[\pL\pN]/', $sWord)) unset($aRecheckWords[$i]);
|
||||
@@ -869,33 +896,23 @@ class Geocode
|
||||
Debug::printVar('Recheck words', $aRecheckWords);
|
||||
|
||||
foreach ($aSearchResults as $iIdx => $aResult) {
|
||||
// Default
|
||||
$fDiameter = ClassTypes\getProperty($aResult, 'defdiameter', 0.0001);
|
||||
$fRadius = ClassTypes\getDefRadius($aResult);
|
||||
|
||||
$aOutlineResult = $this->oPlaceLookup->getOutlines($aResult['place_id'], $aResult['lon'], $aResult['lat'], $fDiameter/2);
|
||||
$aOutlineResult = $this->oPlaceLookup->getOutlines($aResult['place_id'], $aResult['lon'], $aResult['lat'], $fRadius);
|
||||
if ($aOutlineResult) {
|
||||
$aResult = array_merge($aResult, $aOutlineResult);
|
||||
}
|
||||
|
||||
if ($aResult['extra_place'] == 'city') {
|
||||
$aResult['class'] = 'place';
|
||||
$aResult['type'] = 'city';
|
||||
$aResult['rank_search'] = 16;
|
||||
}
|
||||
|
||||
// Is there an icon set for this type of result?
|
||||
$aClassInfo = ClassTypes\getInfo($aResult);
|
||||
|
||||
if ($aClassInfo) {
|
||||
if (isset($aClassInfo['icon'])) {
|
||||
$aResult['icon'] = CONST_Website_BaseURL.'images/mapicons/'.$aClassInfo['icon'].'.p.20.png';
|
||||
}
|
||||
|
||||
if (isset($aClassInfo['label'])) {
|
||||
$aResult['label'] = $aClassInfo['label'];
|
||||
}
|
||||
$sIcon = ClassTypes\getIconFile($aResult);
|
||||
if (isset($sIcon)) {
|
||||
$aResult['icon'] = $sIcon;
|
||||
}
|
||||
|
||||
$sLabel = ClassTypes\getLabel($aResult);
|
||||
if (isset($sLabel)) {
|
||||
$aResult['label'] = $sLabel;
|
||||
}
|
||||
$aResult['name'] = $aResult['langaddress'];
|
||||
|
||||
if ($oCtx->hasNearPoint()) {
|
||||
@@ -907,6 +924,26 @@ class Geocode
|
||||
$aResult['lon'],
|
||||
$aResult['lat']
|
||||
);
|
||||
|
||||
// secondary ordering (for results with same importance (the smaller the better):
|
||||
// - approximate importance of address parts
|
||||
if (isset($aResult['addressimportance']) && $aResult['addressimportance']) {
|
||||
$aResult['foundorder'] = -$aResult['addressimportance']/10;
|
||||
} else {
|
||||
$aResult['foundorder'] = -$aResult['importance'];
|
||||
}
|
||||
// - number of exact matches from the query
|
||||
$aResult['foundorder'] -= $aResults[$aResult['place_id']]->iExactMatches;
|
||||
// - importance of the class/type
|
||||
$iClassImportance = ClassTypes\getImportance($aResult);
|
||||
if (isset($iClassImportance)) {
|
||||
$aResult['foundorder'] += 0.0001 * $iClassImportance;
|
||||
} else {
|
||||
$aResult['foundorder'] += 0.01;
|
||||
}
|
||||
// - rank
|
||||
$aResult['foundorder'] -= 0.00001 * (30 - $aResult['rank_search']);
|
||||
|
||||
// Adjust importance for the number of exact string matches in the result
|
||||
$iCountWords = 0;
|
||||
$sAddress = $aResult['langaddress'];
|
||||
@@ -917,21 +954,8 @@ class Geocode
|
||||
}
|
||||
}
|
||||
|
||||
$aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1); // 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
|
||||
|
||||
// secondary ordering (for results with same importance (the smaller the better):
|
||||
// - approximate importance of address parts
|
||||
$aResult['foundorder'] = -$aResult['addressimportance']/10;
|
||||
// - number of exact matches from the query
|
||||
$aResult['foundorder'] -= $aResults[$aResult['place_id']]->iExactMatches;
|
||||
// - importance of the class/type
|
||||
if (isset($aClassType[$aResult['class'].':'.$aResult['type']]['importance'])
|
||||
&& $aClassType[$aResult['class'].':'.$aResult['type']]['importance']
|
||||
) {
|
||||
$aResult['foundorder'] += 0.0001 * $aClassType[$aResult['class'].':'.$aResult['type']]['importance'];
|
||||
} else {
|
||||
$aResult['foundorder'] += 0.01;
|
||||
}
|
||||
// 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
|
||||
$aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1);
|
||||
}
|
||||
$aSearchResults[$iIdx] = $aResult;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class ParameterParser
|
||||
$sLangString = $this->getString('accept-language', $sFallback);
|
||||
|
||||
if ($sLangString) {
|
||||
if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $sLangString, $aLanguagesParse, PREG_SET_ORDER)) {
|
||||
if (preg_match_all('/(([a-z]{1,8})([-_][a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $sLangString, $aLanguagesParse, PREG_SET_ORDER)) {
|
||||
foreach ($aLanguagesParse as $iLang => $aLanguage) {
|
||||
$aLanguages[$aLanguage[1]] = isset($aLanguage[5])?(float)$aLanguage[5]:1 - ($iLang/100);
|
||||
if (!isset($aLanguages[$aLanguage[2]])) $aLanguages[$aLanguage[2]] = $aLanguages[$aLanguage[1]]/10;
|
||||
@@ -104,18 +104,29 @@ class ParameterParser
|
||||
}
|
||||
|
||||
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
|
||||
$aLangPrefOrder['short_name:'.$sLanguage] = 'short_name:'.$sLanguage;
|
||||
$aLangPrefOrder['name:'.$sLanguage] = 'name:'.$sLanguage;
|
||||
}
|
||||
$aLangPrefOrder['short_name'] = 'short_name';
|
||||
$aLangPrefOrder['name'] = 'name';
|
||||
$aLangPrefOrder['brand'] = 'brand';
|
||||
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
|
||||
$aLangPrefOrder['official_name:'.$sLanguage] = 'official_name:'.$sLanguage;
|
||||
$aLangPrefOrder['short_name:'.$sLanguage] = 'short_name:'.$sLanguage;
|
||||
}
|
||||
$aLangPrefOrder['official_name'] = 'official_name';
|
||||
$aLangPrefOrder['short_name'] = 'short_name';
|
||||
$aLangPrefOrder['ref'] = 'ref';
|
||||
$aLangPrefOrder['type'] = 'type';
|
||||
return $aLangPrefOrder;
|
||||
}
|
||||
|
||||
public function hasSetAny($aParamNames)
|
||||
{
|
||||
foreach ($aParamNames as $sName) {
|
||||
if ($this->getBool($sName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
160
lib-php/Phrase.php
Normal file
160
lib-php/Phrase.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
/**
|
||||
* Segment of a query string.
|
||||
*
|
||||
* The parts of a query strings are usually separated by commas.
|
||||
*/
|
||||
class Phrase
|
||||
{
|
||||
const MAX_WORDSET_LEN = 20;
|
||||
const MAX_WORDSETS = 100;
|
||||
|
||||
// Complete phrase as a string.
|
||||
private $sPhrase;
|
||||
// Element type for structured searches.
|
||||
private $sPhraseType;
|
||||
// Space-separated words of the phrase.
|
||||
private $aWords;
|
||||
// Possible segmentations of the phrase.
|
||||
private $aWordSets;
|
||||
|
||||
public static function cmpByArraylen($aA, $aB)
|
||||
{
|
||||
$iALen = count($aA);
|
||||
$iBLen = count($aB);
|
||||
|
||||
if ($iALen == $iBLen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($iALen < $iBLen) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
public function __construct($sPhrase, $sPhraseType)
|
||||
{
|
||||
$this->sPhrase = trim($sPhrase);
|
||||
$this->sPhraseType = $sPhraseType;
|
||||
$this->aWords = explode(' ', $this->sPhrase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element type of the phrase.
|
||||
*
|
||||
* @return string Pharse type if the phrase comes from a structured query
|
||||
* or empty string otherwise.
|
||||
*/
|
||||
public function getPhraseType()
|
||||
{
|
||||
return $this->sPhraseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of possible segmentations of the phrase.
|
||||
*
|
||||
* @return string[][] Array of segmentations, each consisting of an
|
||||
* array of terms.
|
||||
*/
|
||||
public function getWordSets()
|
||||
{
|
||||
return $this->aWordSets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the tokens from this phrase to the given list of tokens.
|
||||
*
|
||||
* @param string[] $aTokens List of tokens to append.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addTokens(&$aTokens)
|
||||
{
|
||||
$iNumWords = count($this->aWords);
|
||||
|
||||
for ($i = 0; $i < $iNumWords; $i++) {
|
||||
$sPhrase = $this->aWords[$i];
|
||||
$aTokens[' '.$sPhrase] = ' '.$sPhrase;
|
||||
$aTokens[$sPhrase] = $sPhrase;
|
||||
|
||||
for ($j = $i + 1; $j < $iNumWords; $j++) {
|
||||
$sPhrase .= ' '.$this->aWords[$j];
|
||||
$aTokens[' '.$sPhrase] = ' '.$sPhrase;
|
||||
$aTokens[$sPhrase] = $sPhrase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert the set of possible segmentations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function invertWordSets()
|
||||
{
|
||||
foreach ($this->aWordSets as $i => $aSet) {
|
||||
$this->aWordSets[$i] = array_reverse($aSet);
|
||||
}
|
||||
}
|
||||
|
||||
public function computeWordSets($oTokens)
|
||||
{
|
||||
$iNumWords = count($this->aWords);
|
||||
// Caches the word set for the partial phrase up to word i.
|
||||
$aSetCache = array_fill(0, $iNumWords, array());
|
||||
|
||||
// Initialise first element of cache. There can only be the word.
|
||||
if ($oTokens->containsAny($this->aWords[0])) {
|
||||
$aSetCache[0][] = array($this->aWords[0]);
|
||||
}
|
||||
|
||||
// Now do the next elements using what we already have.
|
||||
for ($i = 1; $i < $iNumWords; $i++) {
|
||||
for ($j = $i; $j > 0; $j--) {
|
||||
$sPartial = $j == $i ? $this->aWords[$j] : $this->aWords[$j].' '.$sPartial;
|
||||
if (!empty($aSetCache[$j - 1]) && $oTokens->containsAny($sPartial)) {
|
||||
$aPartial = array($sPartial);
|
||||
foreach ($aSetCache[$j - 1] as $aSet) {
|
||||
if (count($aSet) < Phrase::MAX_WORDSET_LEN) {
|
||||
$aSetCache[$i][] = array_merge($aSet, $aPartial);
|
||||
}
|
||||
}
|
||||
if (count($aSetCache[$i]) > 2 * Phrase::MAX_WORDSETS) {
|
||||
usort(
|
||||
$aSetCache[$i],
|
||||
array('\Nominatim\Phrase', 'cmpByArraylen')
|
||||
);
|
||||
$aSetCache[$i] = array_slice(
|
||||
$aSetCache[$i],
|
||||
0,
|
||||
Phrase::MAX_WORDSETS
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally the current full phrase
|
||||
$sPartial = $this->aWords[0].' '.$sPartial;
|
||||
if ($oTokens->containsAny($sPartial)) {
|
||||
$aSetCache[$i][] = array($sPartial);
|
||||
}
|
||||
}
|
||||
|
||||
$this->aWordSets = $aSetCache[$iNumWords - 1];
|
||||
usort($this->aWordSets, array('\Nominatim\Phrase', 'cmpByArraylen'));
|
||||
$this->aWordSets = array_slice($this->aWordSets, 0, Phrase::MAX_WORDSETS);
|
||||
}
|
||||
|
||||
|
||||
public function debugInfo()
|
||||
{
|
||||
return array(
|
||||
'Type' => $this->sPhraseType,
|
||||
'Phrase' => $this->sPhrase,
|
||||
'Words' => $this->aWords,
|
||||
'WordSets' => $this->aWordSets
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/AddressDetails.php');
|
||||
require_once(CONST_BasePath.'/lib/Result.php');
|
||||
require_once(CONST_LibDir.'/AddressDetails.php');
|
||||
require_once(CONST_LibDir.'/Result.php');
|
||||
|
||||
class PlaceLookup
|
||||
{
|
||||
@@ -15,7 +15,6 @@ class PlaceLookup
|
||||
protected $bExtraTags = false;
|
||||
protected $bNameDetails = false;
|
||||
|
||||
protected $bIncludePolygonAsPoints = false;
|
||||
protected $bIncludePolygonAsText = false;
|
||||
protected $bIncludePolygonAsGeoJSON = false;
|
||||
protected $bIncludePolygonAsKML = false;
|
||||
@@ -38,11 +37,6 @@ class PlaceLookup
|
||||
return $this->bDeDupe;
|
||||
}
|
||||
|
||||
public function setIncludePolygonAsPoints($b = true)
|
||||
{
|
||||
$this->bIncludePolygonAsPoints = $b;
|
||||
}
|
||||
|
||||
public function setIncludeAddressDetails($b)
|
||||
{
|
||||
$this->bAddressDetails = $b;
|
||||
@@ -52,7 +46,7 @@ class PlaceLookup
|
||||
{
|
||||
$aLangs = $oParams->getPreferredLanguages();
|
||||
$this->aLangPrefOrderSql =
|
||||
'ARRAY['.join(',', array_map('getDBQuoted', $aLangs)).']';
|
||||
'ARRAY['.join(',', $this->oDB->getDBQuotedList($aLangs)).']';
|
||||
|
||||
$this->bExtraTags = $oParams->getBool('extratags', false);
|
||||
$this->bNameDetails = $oParams->getBool('namedetails', false);
|
||||
@@ -61,7 +55,6 @@ class PlaceLookup
|
||||
|
||||
if ($sGeomType === null || $sGeomType == 'geojson') {
|
||||
$this->bIncludePolygonAsGeoJSON = $oParams->getBool('polygon_geojson');
|
||||
$this->bIncludePolygonAsPoints = false;
|
||||
}
|
||||
|
||||
if ($oParams->getString('format', '') !== 'geojson') {
|
||||
@@ -100,7 +93,6 @@ class PlaceLookup
|
||||
if ($this->bExtraTags) $aParams['extratags'] = '1';
|
||||
if ($this->bNameDetails) $aParams['namedetails'] = '1';
|
||||
|
||||
if ($this->bIncludePolygonAsPoints) $aParams['polygon'] = '1';
|
||||
if ($this->bIncludePolygonAsText) $aParams['polygon_text'] = '1';
|
||||
if ($this->bIncludePolygonAsGeoJSON) $aParams['polygon_geojson'] = '1';
|
||||
if ($this->bIncludePolygonAsKML) $aParams['polygon_kml'] = '1';
|
||||
@@ -132,8 +124,9 @@ class PlaceLookup
|
||||
|
||||
public function setLanguagePreference($aLangPrefOrder)
|
||||
{
|
||||
$this->aLangPrefOrderSql =
|
||||
'ARRAY['.join(',', array_map('getDBQuoted', $aLangPrefOrder)).']';
|
||||
$this->aLangPrefOrderSql = $this->oDB->getArraySQL(
|
||||
$this->oDB->getDBQuotedList($aLangPrefOrder)
|
||||
);
|
||||
}
|
||||
|
||||
private function addressImportanceSql($sGeometry, $sPlaceId)
|
||||
@@ -162,8 +155,8 @@ class PlaceLookup
|
||||
|
||||
public function lookupOSMID($sType, $iID)
|
||||
{
|
||||
$sSQL = "select place_id from placex where osm_type = '".$sType."' and osm_id = ".$iID;
|
||||
$iPlaceID = chksql($this->oDB->getOne($sSQL));
|
||||
$sSQL = 'select place_id from placex where osm_type = :type and osm_id = :id';
|
||||
$iPlaceID = $this->oDB->getOne($sSQL, array(':type' => $sType, ':id' => $iID));
|
||||
|
||||
if (!$iPlaceID) {
|
||||
return null;
|
||||
@@ -214,7 +207,7 @@ class PlaceLookup
|
||||
'ST_Collect(centroid)',
|
||||
'min(CASE WHEN placex.rank_search < 28 THEN placex.place_id ELSE placex.parent_place_id END)'
|
||||
);
|
||||
$sSQL .= " (extratags->'place') AS extra_place ";
|
||||
$sSQL .= " COALESCE(extratags->'place', extratags->'linked_place') AS extra_place ";
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= " WHERE place_id in ($sPlaceIDs) ";
|
||||
$sSQL .= ' AND (';
|
||||
@@ -247,7 +240,7 @@ class PlaceLookup
|
||||
$sSQL .= ' ref, ';
|
||||
if ($this->bExtraTags) $sSQL .= 'extratags, ';
|
||||
if ($this->bNameDetails) $sSQL .= 'name, ';
|
||||
$sSQL .= " extratags->'place' ";
|
||||
$sSQL .= ' extra_place ';
|
||||
|
||||
$aSubSelects[] = $sSQL;
|
||||
}
|
||||
@@ -424,9 +417,10 @@ class PlaceLookup
|
||||
|
||||
$sSQL = join(' UNION ', $aSubSelects);
|
||||
Debug::printSQL($sSQL);
|
||||
$aPlaces = chksql($this->oDB->getAll($sSQL), 'Could not lookup place');
|
||||
$aPlaces = $this->oDB->getAll($sSQL, null, 'Could not lookup place');
|
||||
|
||||
foreach ($aPlaces as &$aPlace) {
|
||||
$aPlace['importance'] = (float) $aPlace['importance'];
|
||||
if ($this->bAddressDetails) {
|
||||
// to get addressdetails for tiger data, the housenumber is needed
|
||||
$aPlace['address'] = new AddressDetails(
|
||||
@@ -454,16 +448,24 @@ class PlaceLookup
|
||||
}
|
||||
}
|
||||
|
||||
$aPlace['addresstype'] = ClassTypes\getProperty(
|
||||
$aPlace['addresstype'] = ClassTypes\getLabelTag(
|
||||
$aPlace,
|
||||
'simplelabel',
|
||||
$aPlace['class']
|
||||
$aPlace['country_code']
|
||||
);
|
||||
|
||||
$aResults[$aPlace['place_id']] = $aPlace;
|
||||
}
|
||||
|
||||
Debug::printVar('Places', $aPlaces);
|
||||
$aResults = array_filter(
|
||||
$aResults,
|
||||
function ($v) {
|
||||
return !($v instanceof Result);
|
||||
}
|
||||
);
|
||||
|
||||
return $aPlaces;
|
||||
Debug::printVar('Places', $aResults);
|
||||
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
/* returns an array which will contain the keys
|
||||
@@ -484,82 +486,73 @@ class PlaceLookup
|
||||
$aOutlineResult = array();
|
||||
if (!$iPlaceID) return $aOutlineResult;
|
||||
|
||||
if (CONST_Search_AreaPolygons) {
|
||||
// Get the bounding box and outline polygon
|
||||
$sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
|
||||
if ($fLonReverse != null && $fLatReverse != null) {
|
||||
$sSQL .= ' ST_Y(closest_point) as centrelat,';
|
||||
$sSQL .= ' ST_X(closest_point) as centrelon,';
|
||||
} else {
|
||||
$sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
|
||||
}
|
||||
$sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
|
||||
$sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';
|
||||
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
|
||||
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
|
||||
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
|
||||
if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ',ST_AsText(geometry) as astext';
|
||||
if ($fLonReverse != null && $fLatReverse != null) {
|
||||
$sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
|
||||
$sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
|
||||
$sFrom .=' ELSE centroid END AS closest_point';
|
||||
$sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
|
||||
} else {
|
||||
$sFrom = ' from placex where place_id = '.$iPlaceID;
|
||||
}
|
||||
if ($this->fPolygonSimplificationThreshold > 0) {
|
||||
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
|
||||
} else {
|
||||
$sSQL .= $sFrom;
|
||||
// Get the bounding box and outline polygon
|
||||
$sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
|
||||
if ($fLonReverse != null && $fLatReverse != null) {
|
||||
$sSQL .= ' ST_Y(closest_point) as centrelat,';
|
||||
$sSQL .= ' ST_X(closest_point) as centrelon,';
|
||||
} else {
|
||||
$sSQL .= ' ST_Y(centroid) as centrelat, ST_X(centroid) as centrelon,';
|
||||
}
|
||||
$sSQL .= ' ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
|
||||
$sSQL .= ' ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';
|
||||
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
|
||||
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
|
||||
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
|
||||
if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext';
|
||||
if ($fLonReverse != null && $fLatReverse != null) {
|
||||
$sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
|
||||
$sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
|
||||
$sFrom .=' ELSE centroid END AS closest_point';
|
||||
$sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx';
|
||||
} else {
|
||||
$sFrom = ' from placex where place_id = '.$iPlaceID;
|
||||
}
|
||||
if ($this->fPolygonSimplificationThreshold > 0) {
|
||||
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
|
||||
} else {
|
||||
$sSQL .= $sFrom;
|
||||
}
|
||||
|
||||
$aPointPolygon = $this->oDB->getRow($sSQL, null, 'Could not get outline');
|
||||
|
||||
if ($aPointPolygon && $aPointPolygon['place_id']) {
|
||||
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
|
||||
$aOutlineResult['lat'] = $aPointPolygon['centrelat'];
|
||||
$aOutlineResult['lon'] = $aPointPolygon['centrelon'];
|
||||
}
|
||||
|
||||
$aPointPolygon = chksql($this->oDB->getRow($sSQL), 'Could not get outline');
|
||||
if ($this->bIncludePolygonAsGeoJSON) $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson'];
|
||||
if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml'];
|
||||
if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg'];
|
||||
if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext'];
|
||||
|
||||
if ($aPointPolygon['place_id']) {
|
||||
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {
|
||||
$aOutlineResult['lat'] = $aPointPolygon['centrelat'];
|
||||
$aOutlineResult['lon'] = $aPointPolygon['centrelon'];
|
||||
}
|
||||
|
||||
if ($this->bIncludePolygonAsGeoJSON) $aOutlineResult['asgeojson'] = $aPointPolygon['asgeojson'];
|
||||
if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml'];
|
||||
if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg'];
|
||||
if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext'];
|
||||
if ($this->bIncludePolygonAsPoints) $aOutlineResult['aPolyPoints'] = geometryText2Points($aPointPolygon['astext'], $fRadius);
|
||||
|
||||
|
||||
if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
|
||||
$aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
|
||||
$aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
|
||||
}
|
||||
|
||||
if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
|
||||
$aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
|
||||
$aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
|
||||
}
|
||||
|
||||
$aOutlineResult['aBoundingBox'] = array(
|
||||
(string)$aPointPolygon['minlat'],
|
||||
(string)$aPointPolygon['maxlat'],
|
||||
(string)$aPointPolygon['minlon'],
|
||||
(string)$aPointPolygon['maxlon']
|
||||
);
|
||||
if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
|
||||
$aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
|
||||
$aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
|
||||
}
|
||||
|
||||
if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001) {
|
||||
$aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
|
||||
$aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
|
||||
}
|
||||
|
||||
$aOutlineResult['aBoundingBox'] = array(
|
||||
(string)$aPointPolygon['minlat'],
|
||||
(string)$aPointPolygon['maxlat'],
|
||||
(string)$aPointPolygon['minlon'],
|
||||
(string)$aPointPolygon['maxlon']
|
||||
);
|
||||
}
|
||||
|
||||
// as a fallback we generate a bounding box without knowing the size of the geometry
|
||||
if ((!isset($aOutlineResult['aBoundingBox'])) && isset($fLon)) {
|
||||
//
|
||||
if ($this->bIncludePolygonAsPoints) {
|
||||
$sGeometryText = 'POINT('.$fLon.','.$fLat.')';
|
||||
$aOutlineResult['aPolyPoints'] = geometryText2Points($sGeometryText, $fRadius);
|
||||
}
|
||||
|
||||
$aBounds = array();
|
||||
$aBounds['minlat'] = $fLat - $fRadius;
|
||||
$aBounds['maxlat'] = $fLat + $fRadius;
|
||||
$aBounds['minlon'] = $fLon - $fRadius;
|
||||
$aBounds['maxlon'] = $fLon + $fRadius;
|
||||
$aBounds = array(
|
||||
'minlat' => $fLat - $fRadius,
|
||||
'maxlat' => $fLat + $fRadius,
|
||||
'minlon' => $fLon - $fRadius,
|
||||
'maxlon' => $fLon + $fRadius
|
||||
);
|
||||
|
||||
$aOutlineResult['aBoundingBox'] = array(
|
||||
(string)$aBounds['minlat'],
|
||||
@@ -26,6 +26,8 @@ class Result
|
||||
public $iExactMatches = 0;
|
||||
/// Subranking within the results (the higher the worse).
|
||||
public $iResultRank = 0;
|
||||
/// Address rank of the result.
|
||||
public $iAddressRank;
|
||||
|
||||
public function debugInfo()
|
||||
{
|
||||
@@ -68,4 +70,32 @@ class Result
|
||||
|
||||
return $sHousenumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a result array into highest ranked result and the rest
|
||||
*
|
||||
* @param object[] $aResults List of results to split.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public static function splitResults($aResults)
|
||||
{
|
||||
$aHead = array();
|
||||
$aTail = array();
|
||||
$iMinRank = 10000;
|
||||
|
||||
foreach ($aResults as $oRes) {
|
||||
if ($oRes->iResultRank < $iMinRank) {
|
||||
$aTail += $aHead;
|
||||
$aHead = array($oRes->iId => $oRes);
|
||||
$iMinRank = $oRes->iResultRank;
|
||||
} elseif ($oRes->iResultRank == $iMinRank) {
|
||||
$aHead[$oRes->iId] = $oRes;
|
||||
} else {
|
||||
$aTail[$oRes->iId] = $oRes;
|
||||
}
|
||||
}
|
||||
|
||||
return array('head' => $aHead, 'tail' => $aTail);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/Result.php');
|
||||
require_once(CONST_LibDir.'/Result.php');
|
||||
|
||||
class ReverseGeocode
|
||||
{
|
||||
@@ -36,8 +36,8 @@ class ReverseGeocode
|
||||
13 => 18,
|
||||
14 => 22, // Suburb
|
||||
15 => 22,
|
||||
16 => 26, // Street, TODO: major street?
|
||||
17 => 26,
|
||||
16 => 26, // major street
|
||||
17 => 27, // minor street
|
||||
18 => 30, // or >, Building
|
||||
19 => 30, // or >, Building
|
||||
);
|
||||
@@ -54,6 +54,7 @@ class ReverseGeocode
|
||||
*/
|
||||
protected function lookupInterpolation($sPointSQL, $fSearchDiam)
|
||||
{
|
||||
Debug::newFunction('lookupInterpolation');
|
||||
$sSQL = 'SELECT place_id, parent_place_id, 30 as rank_search,';
|
||||
$sSQL .= ' ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fraction,';
|
||||
$sSQL .= ' startnumber, endnumber, interpolationtype,';
|
||||
@@ -62,9 +63,11 @@ class ReverseGeocode
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', linegeo, '.$fSearchDiam.')';
|
||||
$sSQL .= ' and indexed_status = 0 and startnumber is not NULL ';
|
||||
$sSQL .= ' ORDER BY distance ASC limit 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
return chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
return $this->oDB->getRow(
|
||||
$sSQL,
|
||||
null,
|
||||
'Could not determine closest housenumber on an osm interpolation line.'
|
||||
);
|
||||
}
|
||||
@@ -87,15 +90,20 @@ class ReverseGeocode
|
||||
|
||||
protected function lookupInCountry($sPointSQL, $iMaxRank)
|
||||
{
|
||||
Debug::newFunction('lookupInCountry');
|
||||
// searches for polygon in table country_osm_grid which contains the searchpoint
|
||||
// and searches for the nearest place node to the searchpoint in this polygon
|
||||
$sSQL = 'SELECT country_code FROM country_osm_grid';
|
||||
$sSQL .= ' WHERE ST_CONTAINS(geometry, '.$sPointSQL.') LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$sCountryCode = chksql(
|
||||
$this->oDB->getOne($sSQL),
|
||||
$sCountryCode = $this->oDB->getOne(
|
||||
$sSQL,
|
||||
null,
|
||||
'Could not determine country polygon containing the point.'
|
||||
);
|
||||
Debug::printVar('Country code', $sCountryCode);
|
||||
|
||||
if ($sCountryCode) {
|
||||
if ($iMaxRank > 4) {
|
||||
// look for place nodes with the given country code
|
||||
@@ -113,12 +121,11 @@ class ReverseGeocode
|
||||
$sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)';
|
||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aPlace = $this->oDB->getRow($sSQL, null, 'Could not determine place node.');
|
||||
Debug::printVar('Country node', $aPlace);
|
||||
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlace = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine place node.'
|
||||
);
|
||||
if ($aPlace) {
|
||||
return new Result($aPlace['place_id']);
|
||||
}
|
||||
@@ -132,12 +139,10 @@ class ReverseGeocode
|
||||
$sSQL .= ' AND class in (\'boundary\', \'place\')';
|
||||
$sSQL .= ' AND linked_place_id is null';
|
||||
$sSQL .= ' ORDER BY distance ASC';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlace = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine place node.'
|
||||
);
|
||||
$aPlace = $this->oDB->getRow($sSQL, null, 'Could not determine place node.');
|
||||
Debug::printVar('Country place', $aPlace);
|
||||
if ($aPlace) {
|
||||
return new Result($aPlace['place_id']);
|
||||
}
|
||||
@@ -160,6 +165,7 @@ class ReverseGeocode
|
||||
*/
|
||||
protected function lookupPolygon($sPointSQL, $iMaxRank)
|
||||
{
|
||||
Debug::newFunction('lookupPolygon');
|
||||
// polygon search begins at suburb-level
|
||||
if ($iMaxRank > 25) $iMaxRank = 25;
|
||||
// no polygon search over country-level
|
||||
@@ -177,11 +183,11 @@ class ReverseGeocode
|
||||
$sSQL .= ' ORDER BY rank_address DESC LIMIT 50 ) as a';
|
||||
$sSQL .= ' WHERE ST_CONTAINS(geometry, '.$sPointSQL.' )';
|
||||
$sSQL .= ' ORDER BY rank_address DESC LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aPoly = $this->oDB->getRow($sSQL, null, 'Could not determine polygon containing the point.');
|
||||
Debug::printVar('Polygon result', $aPoly);
|
||||
|
||||
$aPoly = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine polygon containing the point.'
|
||||
);
|
||||
if ($aPoly) {
|
||||
// if a polygon is found, search for placenodes begins ...
|
||||
$iParentPlaceID = $aPoly['parent_place_id'];
|
||||
@@ -199,6 +205,7 @@ class ReverseGeocode
|
||||
// for place nodes at rank_address 16
|
||||
$sSQL .= ' AND rank_search > '.$iRankSearch;
|
||||
$sSQL .= ' AND rank_search <= '.$iMaxRank;
|
||||
$sSQL .= ' AND rank_address > 0';
|
||||
$sSQL .= ' AND class = \'place\'';
|
||||
$sSQL .= ' AND type != \'postcode\'';
|
||||
$sSQL .= ' AND name IS NOT NULL ';
|
||||
@@ -211,14 +218,12 @@ class ReverseGeocode
|
||||
$sSQL .= ' AND distance <= reverse_place_diameter(rank_search)';
|
||||
$sSQL .= ' ORDER BY distance ASC, rank_search DESC';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlacNode = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine place node.'
|
||||
);
|
||||
if ($aPlacNode) {
|
||||
return $aPlacNode;
|
||||
$aPlaceNode = $this->oDB->getRow($sSQL, null, 'Could not determine place node.');
|
||||
Debug::printVar('Nearest place node', $aPlaceNode);
|
||||
if ($aPlaceNode) {
|
||||
return $aPlaceNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,6 +241,7 @@ class ReverseGeocode
|
||||
|
||||
public function lookupPoint($sPointSQL, $bDoInterpolation = true)
|
||||
{
|
||||
Debug::newFunction('lookupPoint');
|
||||
// starts if the search is on POI or street level,
|
||||
// searches for the nearest POI or street,
|
||||
// if a street is found and a POI is searched for,
|
||||
@@ -255,52 +261,25 @@ class ReverseGeocode
|
||||
$sSQL .= ' placex';
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
|
||||
$sSQL .= ' AND';
|
||||
// only streets
|
||||
if ($iMaxRank == 26) {
|
||||
$sSQL .= ' rank_address = 26';
|
||||
} else {
|
||||
$sSQL .= ' rank_address between 26 and '.$iMaxRank;
|
||||
}
|
||||
$sSQL .= ' rank_address between 26 and '.$iMaxRank;
|
||||
$sSQL .= ' and (name is not null or housenumber is not null';
|
||||
$sSQL .= ' or rank_address between 26 and 27)';
|
||||
$sSQL .= ' and class not in (\'railway\',\'tunnel\',\'bridge\',\'man_made\')';
|
||||
$sSQL .= ' and (rank_address between 26 and 27';
|
||||
$sSQL .= ' or ST_GeometryType(geometry) != \'ST_LineString\')';
|
||||
$sSQL .= ' and class not in (\'boundary\')';
|
||||
$sSQL .= ' and indexed_status = 0 and linked_place_id is null';
|
||||
$sSQL .= ' and (ST_GeometryType(geometry) not in (\'ST_Polygon\',\'ST_MultiPolygon\') ';
|
||||
$sSQL .= ' OR ST_DWithin('.$sPointSQL.', centroid, '.$fSearchDiam.'))';
|
||||
$sSQL .= ' ORDER BY distance ASC limit 1';
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlace = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine closest place.'
|
||||
);
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
if (CONST_Debug) var_dump($aPlace);
|
||||
$aPlace = $this->oDB->getRow($sSQL, null, 'Could not determine closest place.');
|
||||
|
||||
Debug::printVar('POI/street level result', $aPlace);
|
||||
if ($aPlace) {
|
||||
$iPlaceID = $aPlace['place_id'];
|
||||
$oResult = new Result($iPlaceID);
|
||||
$iRankAddress = $aPlace['rank_address'];
|
||||
$iParentPlaceID = $aPlace['parent_place_id'];
|
||||
}
|
||||
|
||||
if ($bDoInterpolation && $iMaxRank >= 30) {
|
||||
$fDistance = $fSearchDiam;
|
||||
if ($aPlace) {
|
||||
// We can't reliably go from the closest street to an
|
||||
// interpolation line because the closest interpolation
|
||||
// may have a different street segments as a parent.
|
||||
// Therefore allow an interpolation line to take precendence
|
||||
// even when the street is closer.
|
||||
$fDistance = $iRankAddress < 28 ? 0.001 : $aPlace['distance'];
|
||||
}
|
||||
|
||||
$aHouse = $this->lookupInterpolation($sPointSQL, $fDistance);
|
||||
|
||||
if ($aHouse) {
|
||||
$oResult = new Result($aHouse['place_id'], Result::TABLE_OSMLINE);
|
||||
$oResult->iHouseNumber = closestHouseNumber($aHouse);
|
||||
$aPlace = $aHouse;
|
||||
$iRankAddress = 30;
|
||||
}
|
||||
}
|
||||
|
||||
if ($aPlace) {
|
||||
@@ -314,19 +293,21 @@ class ReverseGeocode
|
||||
// radius ?
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, 0.001)';
|
||||
$sSQL .= ' AND parent_place_id = '.$iPlaceID;
|
||||
$sSQL .= ' and rank_address != 28';
|
||||
$sSQL .= ' and rank_address > 28';
|
||||
$sSQL .= ' and ST_GeometryType(geometry) != \'ST_LineString\'';
|
||||
$sSQL .= ' and (name is not null or housenumber is not null)';
|
||||
$sSQL .= ' and class not in (\'railway\',\'tunnel\',\'bridge\',\'man_made\')';
|
||||
$sSQL .= ' and class not in (\'boundary\')';
|
||||
$sSQL .= ' and indexed_status = 0 and linked_place_id is null';
|
||||
$sSQL .= ' ORDER BY distance ASC limit 1';
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aStreet = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine closest place.'
|
||||
);
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aStreet = $this->oDB->getRow($sSQL, null, 'Could not determine closest place.');
|
||||
Debug::printVar('Closest POI result', $aStreet);
|
||||
|
||||
if ($aStreet) {
|
||||
if (CONST_Debug) var_dump($aStreet);
|
||||
$aPlace = $aStreet;
|
||||
$oResult = new Result($aStreet['place_id']);
|
||||
$iRankAddress = 30;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,18 +324,43 @@ class ReverseGeocode
|
||||
$sSQL .= ' FROM location_property_tiger WHERE parent_place_id = '.$oResult->iId;
|
||||
$sSQL .= ' AND ST_DWithin('.$sPointSQL.', linegeo, 0.001)';
|
||||
$sSQL .= ' ORDER BY distance ASC limit 1';
|
||||
if (CONST_Debug) var_dump($sSQL);
|
||||
$aPlaceTiger = chksql(
|
||||
$this->oDB->getRow($sSQL),
|
||||
'Could not determine closest Tiger place.'
|
||||
);
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aPlaceTiger = $this->oDB->getRow($sSQL, null, 'Could not determine closest Tiger place.');
|
||||
Debug::printVar('Tiger house number result', $aPlaceTiger);
|
||||
|
||||
if ($aPlaceTiger) {
|
||||
if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
|
||||
$aPlace = $aPlaceTiger;
|
||||
$oResult = new Result($aPlaceTiger['place_id'], Result::TABLE_TIGER);
|
||||
$oResult->iHouseNumber = closestHouseNumber($aPlaceTiger);
|
||||
$iRankAddress = 30;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if ($bDoInterpolation && $iMaxRank >= 30) {
|
||||
$fDistance = $fSearchDiam;
|
||||
if ($aPlace) {
|
||||
// We can't reliably go from the closest street to an
|
||||
// interpolation line because the closest interpolation
|
||||
// may have a different street segments as a parent.
|
||||
// Therefore allow an interpolation line to take precendence
|
||||
// even when the street is closer.
|
||||
$fDistance = $iRankAddress < 28 ? 0.001 : $aPlace['distance'];
|
||||
}
|
||||
|
||||
$aHouse = $this->lookupInterpolation($sPointSQL, $fDistance);
|
||||
Debug::printVar('Interpolation result', $aPlace);
|
||||
|
||||
if ($aHouse) {
|
||||
$oResult = new Result($aHouse['place_id'], Result::TABLE_OSMLINE);
|
||||
$oResult->iHouseNumber = closestHouseNumber($aHouse);
|
||||
$aPlace = $aHouse;
|
||||
$iRankAddress = 30;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$aPlace) {
|
||||
// if no POI or street is found ...
|
||||
$oResult = $this->lookupLargeArea($sPointSQL, 25);
|
||||
}
|
||||
@@ -362,6 +368,8 @@ class ReverseGeocode
|
||||
// lower than street level ($iMaxRank < 26 )
|
||||
$oResult = $this->lookupLargeArea($sPointSQL, $iMaxRank);
|
||||
}
|
||||
|
||||
Debug::printVar('Final result', $oResult);
|
||||
return $oResult;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/lib.php');
|
||||
require_once(CONST_LibDir.'/lib.php');
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,18 @@ class SearchContext
|
||||
public $sqlCountryList = '';
|
||||
/// List of place IDs to exclude (as SQL).
|
||||
private $sqlExcludeList = '';
|
||||
/// Subset of word ids of full words in the query.
|
||||
private $aFullNameWords = array();
|
||||
|
||||
public function setFullNameWords($aWordList)
|
||||
{
|
||||
$this->aFullNameWords = $aWordList;
|
||||
}
|
||||
|
||||
public function getFullNameTerms()
|
||||
{
|
||||
return $this->aFullNameWords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a reference point is defined.
|
||||
@@ -126,7 +137,7 @@ class SearchContext
|
||||
* The viewbox may be bounded which means that no search results
|
||||
* must be outside the viewbox.
|
||||
*
|
||||
* @param object $oDB DB connection to use for computing the box.
|
||||
* @param object $oDB Nominatim::DB instance to use for computing the box.
|
||||
* @param string[] $aRoutePoints List of x,y coordinates along a route.
|
||||
* @param float $fRouteWidth Buffer around the route to use.
|
||||
* @param bool $bBounded True if the viewbox bounded.
|
||||
@@ -146,11 +157,11 @@ class SearchContext
|
||||
$this->sqlViewboxCentre .= ")'::geometry,4326)";
|
||||
|
||||
$sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/69).')';
|
||||
$sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get small viewbox');
|
||||
$sGeom = $oDB->getOne('select '.$sSQL, null, 'Could not get small viewbox');
|
||||
$this->sqlViewboxSmall = "'".$sGeom."'::geometry";
|
||||
|
||||
$sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/30).')';
|
||||
$sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get large viewbox');
|
||||
$sGeom = $oDB->getOne('select '.$sSQL, null, 'Could not get large viewbox');
|
||||
$this->sqlViewboxLarge = "'".$sGeom."'::geometry";
|
||||
}
|
||||
|
||||
@@ -203,7 +214,7 @@ class SearchContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an SQL snipped for computing the distance from the reference point.
|
||||
* Get an SQL snippet for computing the distance from the reference point.
|
||||
*
|
||||
* @param string $sObj SQL variable name to compute the distance from.
|
||||
*
|
||||
@@ -215,7 +226,7 @@ class SearchContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an SQL snipped for checking if something is within range of the
|
||||
* Get an SQL snippet for checking if something is within range of the
|
||||
* reference point.
|
||||
*
|
||||
* @param string $sObj SQL variable name to compute if it is within range.
|
||||
@@ -228,14 +239,14 @@ class SearchContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an SQL snipped of the importance factor of the viewbox.
|
||||
* Get an SQL snippet of the importance factor of the viewbox.
|
||||
*
|
||||
* The importance factor is computed by checking if an object is within
|
||||
* the viewbox and/or the extended version of the viewbox.
|
||||
*
|
||||
* @param string $sObj SQL variable name of object to weight the importance
|
||||
*
|
||||
* @return string SQL snipped of the factor with a leading multiply sign.
|
||||
* @return string SQL snippet of the factor with a leading multiply sign.
|
||||
*/
|
||||
public function viewboxImportanceSQL($sObj)
|
||||
{
|
||||
@@ -252,7 +263,7 @@ class SearchContext
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL snipped checking if a place ID should be excluded.
|
||||
* SQL snippet checking if a place ID should be excluded.
|
||||
*
|
||||
* @param string $sVariable SQL variable name of place ID to check,
|
||||
* potentially prefixed with more SQL.
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
|
||||
require_once(CONST_BasePath.'/lib/SearchContext.php');
|
||||
require_once(CONST_BasePath.'/lib/Result.php');
|
||||
require_once(CONST_LibDir.'/SpecialSearchOperator.php');
|
||||
require_once(CONST_LibDir.'/SearchContext.php');
|
||||
require_once(CONST_LibDir.'/Result.php');
|
||||
|
||||
/**
|
||||
* Description of a single interpretation of a search query.
|
||||
@@ -21,8 +21,6 @@ class SearchDescription
|
||||
private $bRareName = false;
|
||||
/// List of word ids making up the address of the object.
|
||||
private $aAddress = array();
|
||||
/// Subset of word ids of full words making up the address.
|
||||
private $aFullNameAddress = array();
|
||||
/// List of word ids that appear in the name but should be ignored.
|
||||
private $aNameNonSearch = array();
|
||||
/// List of word ids that appear in the address but should be ignored.
|
||||
@@ -88,18 +86,6 @@ class SearchDescription
|
||||
$this->sType = $sType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this might be a full address search.
|
||||
*
|
||||
* @return bool True if the search contains name, address and housenumber.
|
||||
*/
|
||||
public function looksLikeFullAddress()
|
||||
{
|
||||
return (!empty($this->aName))
|
||||
&& (!empty($this->aAddress) || $this->sCountryCode)
|
||||
&& preg_match('/[0-9]+/', $this->sHouseNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any operator is set.
|
||||
*
|
||||
@@ -193,21 +179,17 @@ class SearchDescription
|
||||
// - increase score for finding it anywhere else (optimisation)
|
||||
if (!$bLastToken) {
|
||||
$oSearch->iSearchRank += 5;
|
||||
$oSearch->iNamePhrase = -1;
|
||||
}
|
||||
$aNewSearches[] = $oSearch;
|
||||
}
|
||||
} elseif (($sPhraseType == '' || $sPhraseType == 'postalcode')
|
||||
&& is_a($oSearchTerm, '\Nominatim\Token\Postcode')
|
||||
) {
|
||||
// We need to try the case where the postal code is the primary element
|
||||
// (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode)
|
||||
// so try both.
|
||||
if (!$this->sPostcode) {
|
||||
// If we have structured search or this is the first term,
|
||||
// make the postcode the primary search element.
|
||||
if ($this->iOperator == Operator::NONE
|
||||
&& ($sPhraseType == 'postalcode' || $bFirstToken)
|
||||
) {
|
||||
if ($this->iOperator == Operator::NONE && $bFirstToken) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->iOperator = Operator::POSTCODE;
|
||||
@@ -224,6 +206,10 @@ class SearchDescription
|
||||
) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->iNamePhrase = -1;
|
||||
if (strlen($oSearchTerm->sPostcode) < 4) {
|
||||
$oSearch->iSearchRank += 4 - strlen($oSearchTerm->sPostcode);
|
||||
}
|
||||
$oSearch->sPostcode = $oSearchTerm->sPostcode;
|
||||
$aNewSearches[] = $oSearch;
|
||||
}
|
||||
@@ -234,10 +220,15 @@ class SearchDescription
|
||||
if (!$this->sHouseNumber && $this->iOperator != Operator::POSTCODE) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->iNamePhrase = -1;
|
||||
$oSearch->sHouseNumber = $oSearchTerm->sToken;
|
||||
if ($this->iOperator != Operator::NONE) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
// sanity check: if the housenumber is not mainly made
|
||||
// up of numbers, add a penalty
|
||||
if (preg_match_all('/[^0-9]/', $oSearch->sHouseNumber, $aMatches) > 2) {
|
||||
if (preg_match('/\\d/', $oSearch->sHouseNumber) === 0
|
||||
|| preg_match_all('/[^0-9]/', $oSearch->sHouseNumber, $aMatches) > 2) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
if (empty($oSearchTerm->iId)) {
|
||||
@@ -251,13 +242,27 @@ class SearchDescription
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
$aNewSearches[] = $oSearch;
|
||||
// Housenumbers may appear in the name when the place has its own
|
||||
// address terms.
|
||||
if ($oSearchTerm->iId !== null
|
||||
&& ($this->iNamePhrase >= 0 || empty($this->aName))
|
||||
&& empty($this->aAddress)
|
||||
) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->aAddress = $this->aName;
|
||||
$oSearch->bRareName = false;
|
||||
$oSearch->aName = array($oSearchTerm->iId => $oSearchTerm->iId);
|
||||
$aNewSearches[] = $oSearch;
|
||||
}
|
||||
}
|
||||
} elseif ($sPhraseType == ''
|
||||
&& is_a($oSearchTerm, '\Nominatim\Token\SpecialTerm')
|
||||
) {
|
||||
if ($this->iOperator == Operator::NONE) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->iSearchRank += 2;
|
||||
$oSearch->iNamePhrase = -1;
|
||||
|
||||
$iOp = $oSearchTerm->iOperator;
|
||||
if ($iOp == Operator::NONE) {
|
||||
@@ -267,6 +272,11 @@ class SearchDescription
|
||||
$iOp = Operator::NEAR;
|
||||
}
|
||||
$oSearch->iSearchRank += 2;
|
||||
} elseif (!$bFirstToken && !$bLastToken) {
|
||||
$oSearch->iSearchRank += 2;
|
||||
}
|
||||
if ($this->sHouseNumber) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
|
||||
$oSearch->setPoiSearch(
|
||||
@@ -287,13 +297,12 @@ class SearchDescription
|
||||
if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
|
||||
if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->iNamePhrase = -1;
|
||||
$oSearch->iSearchRank += 3 * $oSearchTerm->iTermCount;
|
||||
$oSearch->aAddress[$iWordID] = $iWordID;
|
||||
$aNewSearches[] = $oSearch;
|
||||
} else {
|
||||
$this->aFullNameAddress[$iWordID] = $iWordID;
|
||||
}
|
||||
} else {
|
||||
} elseif (empty($this->aNameNonSearch)) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->aName = array($iWordID => $iWordID);
|
||||
@@ -333,48 +342,34 @@ class SearchDescription
|
||||
|
||||
if ((!$bStructuredPhrases || $iPhrase > 0)
|
||||
&& (!empty($this->aName))
|
||||
&& strpos($sToken, ' ') === false
|
||||
) {
|
||||
if ($oSearchTerm->iSearchNameCount < CONST_Max_Word_Frequency) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank += 2;
|
||||
$oSearch->aAddress[$iWordID] = $iWordID;
|
||||
$aNewSearches[] = $oSearch;
|
||||
} else {
|
||||
$oSearch = clone $this;
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
if (preg_match('#^[0-9 ]+$#', $sToken)) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
if ($oSearchTerm->iSearchNameCount < CONST_Max_Word_Frequency) {
|
||||
$oSearch->aAddress[$iWordID] = $iWordID;
|
||||
} else {
|
||||
$oSearch->aAddressNonSearch[$iWordID] = $iWordID;
|
||||
if (preg_match('#^[0-9]+$#', $sToken)) {
|
||||
$oSearch->iSearchRank += 2;
|
||||
}
|
||||
if (!empty($aFullTokens)) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
$aNewSearches[] = $oSearch;
|
||||
|
||||
// revert to the token version?
|
||||
foreach ($aFullTokens as $oSearchTermToken) {
|
||||
if (is_a($oSearchTermToken, '\Nominatim\Token\Word')) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank++;
|
||||
$oSearch->aAddress[$oSearchTermToken->iId]
|
||||
= $oSearchTermToken->iId;
|
||||
$aNewSearches[] = $oSearch;
|
||||
}
|
||||
}
|
||||
}
|
||||
$aNewSearches[] = $oSearch;
|
||||
}
|
||||
|
||||
if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
|
||||
&& (empty($this->aName) || $this->iNamePhrase == $iPhrase)
|
||||
&& ((empty($this->aName) && empty($this->aNameNonSearch)) || $this->iNamePhrase == $iPhrase)
|
||||
&& strpos($sToken, ' ') === false
|
||||
) {
|
||||
$oSearch = clone $this;
|
||||
$oSearch->iSearchRank += 2;
|
||||
if (empty($this->aName)) {
|
||||
$oSearch->iSearchRank += 1;
|
||||
$oSearch->iSearchRank++;
|
||||
if (empty($this->aName) && empty($this->aNameNonSearch)) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
if (preg_match('#^[0-9]+$#', $sToken)) {
|
||||
$oSearch->iSearchRank += 2;
|
||||
if (preg_match('#^[0-9 ]+$#', $sToken)) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
if ($oSearchTerm->iSearchNameCount < CONST_Max_Word_Frequency) {
|
||||
if (empty($this->aName)
|
||||
@@ -388,6 +383,9 @@ class SearchDescription
|
||||
}
|
||||
$oSearch->aName[$iWordID] = $iWordID;
|
||||
} else {
|
||||
if (!empty($aFullTokens)) {
|
||||
$oSearch->iSearchRank++;
|
||||
}
|
||||
$oSearch->aNameNonSearch[$iWordID] = $iWordID;
|
||||
}
|
||||
$oSearch->iNamePhrase = $iPhrase;
|
||||
@@ -403,7 +401,7 @@ class SearchDescription
|
||||
/**
|
||||
* Query database for places that match this search.
|
||||
*
|
||||
* @param object $oDB Database connection to use.
|
||||
* @param object $oDB Nominatim::DB instance to use.
|
||||
* @param integer $iMinRank Minimum address rank to restrict search to.
|
||||
* @param integer $iMaxRank Maximum address rank to restrict search to.
|
||||
* @param integer $iLimit Maximum number of results.
|
||||
@@ -446,13 +444,24 @@ class SearchDescription
|
||||
$iLimit
|
||||
);
|
||||
|
||||
//now search for housenumber, if housenumber provided
|
||||
if ($this->sHouseNumber && !empty($aResults)) {
|
||||
$aNamedPlaceIDs = $aResults;
|
||||
$aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs);
|
||||
// Now search for housenumber, if housenumber provided. Can be zero.
|
||||
if (($this->sHouseNumber || $this->sHouseNumber === '0') && !empty($aResults)) {
|
||||
// Downgrade the rank of the street results, they are missing
|
||||
// the housenumber.
|
||||
foreach ($aResults as $oRes) {
|
||||
if ($oRes->iAddressRank >= 26) {
|
||||
$oRes->iResultRank++;
|
||||
} else {
|
||||
$oRes->iResultRank += 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($aResults) && $this->looksLikeFullAddress()) {
|
||||
$aResults = $aNamedPlaceIDs;
|
||||
$aHnResults = $this->queryHouseNumber($oDB, $aResults);
|
||||
|
||||
if (!empty($aHnResults)) {
|
||||
foreach ($aHnResults as $oRes) {
|
||||
$aResults[$oRes->iId] = $oRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,16 +478,13 @@ class SearchDescription
|
||||
if ($sPlaceIds) {
|
||||
$sSQL = 'SELECT place_id FROM placex';
|
||||
$sSQL .= ' WHERE place_id in ('.$sPlaceIds.')';
|
||||
$sSQL .= " AND postcode = '".$this->sPostcode."'";
|
||||
$sSQL .= " AND postcode != '".$this->sPostcode."'";
|
||||
Debug::printSQL($sSQL);
|
||||
$aFilteredPlaceIDs = chksql($oDB->getCol($sSQL));
|
||||
$aFilteredPlaceIDs = $oDB->getCol($sSQL);
|
||||
if ($aFilteredPlaceIDs) {
|
||||
$aNewResults = array();
|
||||
foreach ($aFilteredPlaceIDs as $iPlaceId) {
|
||||
$aNewResults[$iPlaceId] = $aResults[$iPlaceId];
|
||||
$aResults[$iPlaceId]->iResultRank++;
|
||||
}
|
||||
$aResults = $aNewResults;
|
||||
Debug::printVar('Place IDs after postcode filtering', $aResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,8 +505,10 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$iPlaceId = $oDB->getOne($sSQL);
|
||||
|
||||
$aResults = array();
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
if ($iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
|
||||
@@ -516,8 +524,7 @@ class SearchDescription
|
||||
$aDBResults = array();
|
||||
$sPoiTable = $this->poiTable();
|
||||
|
||||
$sSQL = 'SELECT count(*) FROM pg_tables WHERE tablename = \''.$sPoiTable."'";
|
||||
if (chksql($oDB->getOne($sSQL))) {
|
||||
if ($oDB->tableExists($sPoiTable)) {
|
||||
$sSQL = 'SELECT place_id FROM '.$sPoiTable.' ct';
|
||||
if ($this->oContext->sqlCountryList) {
|
||||
$sSQL .= ' JOIN placex USING (place_id)';
|
||||
@@ -537,14 +544,14 @@ class SearchDescription
|
||||
} elseif ($this->oContext->hasNearPoint()) {
|
||||
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('ct.centroid').' ASC';
|
||||
}
|
||||
$sSQL .= " limit $iLimit";
|
||||
$sSQL .= " LIMIT $iLimit";
|
||||
Debug::printSQL($sSQL);
|
||||
$aDBResults = chksql($oDB->getCol($sSQL));
|
||||
$aDBResults = $oDB->getCol($sSQL);
|
||||
}
|
||||
|
||||
if ($this->oContext->hasNearPoint()) {
|
||||
$sSQL = 'SELECT place_id FROM placex WHERE ';
|
||||
$sSQL .= 'class=\''.$this->sClass."' and type='".$this->sType."'";
|
||||
$sSQL .= 'class = :class and type = :type';
|
||||
$sSQL .= ' AND '.$this->oContext->withinSQL('geometry');
|
||||
$sSQL .= ' AND linked_place_id is null';
|
||||
if ($this->oContext->sqlCountryList) {
|
||||
@@ -553,7 +560,10 @@ class SearchDescription
|
||||
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid').' ASC';
|
||||
$sSQL .= " LIMIT $iLimit";
|
||||
Debug::printSQL($sSQL);
|
||||
$aDBResults = chksql($oDB->getCol($sSQL));
|
||||
$aDBResults = $oDB->getCol(
|
||||
$sSQL,
|
||||
array(':class' => $this->sClass, ':type' => $this->sType)
|
||||
);
|
||||
}
|
||||
|
||||
$aResults = array();
|
||||
@@ -572,20 +582,23 @@ class SearchDescription
|
||||
$sSQL .= ', search_name s ';
|
||||
$sSQL .= 'WHERE s.place_id = p.parent_place_id ';
|
||||
$sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)';
|
||||
$sSQL .= ' @> '.getArraySQL($this->aAddress).' AND ';
|
||||
$sSQL .= ' @> '.$oDB->getArraySQL($this->aAddress).' AND ';
|
||||
} else {
|
||||
$sSQL .= 'WHERE ';
|
||||
}
|
||||
|
||||
$sSQL .= "p.postcode = '".reset($this->aName)."'";
|
||||
$sSQL .= $this->countryCodeSQL(' AND p.country_code');
|
||||
if ($this->oContext->bViewboxBounded) {
|
||||
$sSQL .= ' AND ST_Intersects('.$this->oContext->sqlViewboxSmall.', geometry)';
|
||||
}
|
||||
$sSQL .= $this->oContext->excludeSQL(' AND p.place_id');
|
||||
$sSQL .= " LIMIT $iLimit";
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aResults = array();
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId, Result::TABLE_POSTCODE);
|
||||
}
|
||||
|
||||
@@ -601,14 +614,14 @@ class SearchDescription
|
||||
// too many results are expected for the street, i.e. if the result
|
||||
// will be narrowed down by an address. Remeber that with ordering
|
||||
// every single result has to be checked.
|
||||
if ($this->sHouseNumber && (!empty($this->aAddress) || $this->sPostcode)) {
|
||||
if ($this->sHouseNumber && ($this->bRareName || !empty($this->aAddress) || $this->sPostcode)) {
|
||||
$sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
|
||||
$aOrder[] = ' (';
|
||||
$aOrder[0] .= 'EXISTS(';
|
||||
$aOrder[0] .= ' SELECT place_id';
|
||||
$aOrder[0] .= ' FROM placex';
|
||||
$aOrder[0] .= ' WHERE parent_place_id = search_name.place_id';
|
||||
$aOrder[0] .= " AND transliteration(housenumber) ~* E'".$sHouseNumberRegex."'";
|
||||
$aOrder[0] .= " AND housenumber ~* E'".$sHouseNumberRegex."'";
|
||||
$aOrder[0] .= ' LIMIT 1';
|
||||
$aOrder[0] .= ') ';
|
||||
// also housenumbers from interpolation lines table are needed
|
||||
@@ -628,14 +641,14 @@ class SearchDescription
|
||||
}
|
||||
|
||||
if (!empty($this->aName)) {
|
||||
$aTerms[] = 'name_vector @> '.getArraySQL($this->aName);
|
||||
$aTerms[] = 'name_vector @> '.$oDB->getArraySQL($this->aName);
|
||||
}
|
||||
if (!empty($this->aAddress)) {
|
||||
// For infrequent name terms disable index usage for address
|
||||
if ($this->bRareName) {
|
||||
$aTerms[] = 'array_cat(nameaddress_vector,ARRAY[]::integer[]) @> '.getArraySQL($this->aAddress);
|
||||
$aTerms[] = 'array_cat(nameaddress_vector,ARRAY[]::integer[]) @> '.$oDB->getArraySQL($this->aAddress);
|
||||
} else {
|
||||
$aTerms[] = 'nameaddress_vector @> '.getArraySQL($this->aAddress);
|
||||
$aTerms[] = 'nameaddress_vector @> '.$oDB->getArraySQL($this->aAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,13 +658,10 @@ class SearchDescription
|
||||
}
|
||||
|
||||
if ($this->sHouseNumber) {
|
||||
$aTerms[] = 'address_rank between 16 and 27';
|
||||
$aTerms[] = 'address_rank between 16 and 30';
|
||||
} elseif (!$this->sClass || $this->iOperator == Operator::NAME) {
|
||||
if ($iMinAddressRank > 0) {
|
||||
$aTerms[] = 'address_rank >= '.$iMinAddressRank;
|
||||
}
|
||||
if ($iMaxAddressRank < 30) {
|
||||
$aTerms[] = 'address_rank <= '.$iMaxAddressRank;
|
||||
$aTerms[] = "((address_rank between $iMinAddressRank and $iMaxAddressRank) or (search_rank between $iMinAddressRank and $iMaxAddressRank))";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,10 +697,11 @@ class SearchDescription
|
||||
$sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
|
||||
$aOrder[] = "$sImportanceSQL DESC";
|
||||
|
||||
if (!empty($this->aFullNameAddress)) {
|
||||
$aFullNameAddress = $this->oContext->getFullNameTerms();
|
||||
if (!empty($aFullNameAddress)) {
|
||||
$sExactMatchSQL = ' ( ';
|
||||
$sExactMatchSQL .= ' SELECT count(*) FROM ( ';
|
||||
$sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')';
|
||||
$sExactMatchSQL .= ' SELECT unnest('.$oDB->getArraySQL($aFullNameAddress).')';
|
||||
$sExactMatchSQL .= ' INTERSECT ';
|
||||
$sExactMatchSQL .= ' SELECT unnest(nameaddress_vector)';
|
||||
$sExactMatchSQL .= ' ) s';
|
||||
@@ -701,13 +712,13 @@ class SearchDescription
|
||||
}
|
||||
|
||||
if ($this->sHouseNumber || $this->sClass) {
|
||||
$iLimit = 20;
|
||||
$iLimit = 40;
|
||||
}
|
||||
|
||||
$aResults = array();
|
||||
|
||||
if (!empty($aTerms)) {
|
||||
$sSQL = 'SELECT place_id,'.$sExactMatchSQL;
|
||||
$sSQL = 'SELECT place_id, address_rank,'.$sExactMatchSQL;
|
||||
$sSQL .= ' FROM search_name';
|
||||
$sSQL .= ' WHERE '.join(' and ', $aTerms);
|
||||
$sSQL .= ' ORDER BY '.join(', ', $aOrder);
|
||||
@@ -715,14 +726,12 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aDBResults = chksql(
|
||||
$oDB->getAll($sSQL),
|
||||
'Could not get places for search terms.'
|
||||
);
|
||||
$aDBResults = $oDB->getAll($sSQL, null, 'Could not get places for search terms.');
|
||||
|
||||
foreach ($aDBResults as $aResult) {
|
||||
$oResult = new Result($aResult['place_id']);
|
||||
$oResult->iExactMatches = $aResult['exactmatch'];
|
||||
$oResult->iAddressRank = $aResult['address_rank'];
|
||||
$aResults[$aResult['place_id']] = $oResult;
|
||||
}
|
||||
}
|
||||
@@ -742,13 +751,13 @@ class SearchDescription
|
||||
$sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
|
||||
$sSQL = 'SELECT place_id FROM placex ';
|
||||
$sSQL .= 'WHERE parent_place_id in ('.$sPlaceIDs.')';
|
||||
$sSQL .= " AND transliteration(housenumber) ~* E'".$sHouseNumberRegex."'";
|
||||
$sSQL .= " AND housenumber ~* E'".$sHouseNumberRegex."'";
|
||||
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
// XXX should inherit the exactMatches from its parent
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
|
||||
@@ -774,7 +783,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$oResult = new Result($iPlaceId, Result::TABLE_OSMLINE);
|
||||
$oResult->iHouseNumber = $iHousenumber;
|
||||
$aResults[$iPlaceId] = $oResult;
|
||||
@@ -790,7 +799,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId, Result::TABLE_AUX);
|
||||
}
|
||||
}
|
||||
@@ -811,7 +820,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$oResult = new Result($iPlaceId, Result::TABLE_TIGER);
|
||||
$oResult->iHouseNumber = $iHousenumber;
|
||||
$aResults[$iPlaceId] = $oResult;
|
||||
@@ -845,7 +854,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
}
|
||||
@@ -853,12 +862,11 @@ class SearchDescription
|
||||
// NEAR and IN are handled the same
|
||||
if ($this->iOperator == Operator::TYPE || $this->iOperator == Operator::NEAR) {
|
||||
$sClassTable = $this->poiTable();
|
||||
$sSQL = "SELECT count(*) FROM pg_tables WHERE tablename = '$sClassTable'";
|
||||
$bCacheTable = (bool) chksql($oDB->getOne($sSQL));
|
||||
$bCacheTable = $oDB->tableExists($sClassTable);
|
||||
|
||||
$sSQL = "SELECT min(rank_search) FROM placex WHERE place_id in ($sPlaceIDs)";
|
||||
Debug::printSQL($sSQL);
|
||||
$iMaxRank = (int)chksql($oDB->getOne($sSQL));
|
||||
$iMaxRank = (int) $oDB->getOne($sSQL);
|
||||
|
||||
// For state / country level searches the normal radius search doesn't work very well
|
||||
$sPlaceGeom = false;
|
||||
@@ -871,7 +879,7 @@ class SearchDescription
|
||||
$sSQL .= ' ORDER BY rank_search ASC ';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
$sPlaceGeom = chksql($oDB->getOne($sSQL));
|
||||
$sPlaceGeom = $oDB->getOne($sSQL);
|
||||
}
|
||||
|
||||
if ($sPlaceGeom) {
|
||||
@@ -881,7 +889,7 @@ class SearchDescription
|
||||
$sSQL = 'SELECT place_id FROM placex';
|
||||
$sSQL .= " WHERE place_id in ($sPlaceIDs) and rank_search < $iMaxRank";
|
||||
Debug::printSQL($sSQL);
|
||||
$aPlaceIDs = chksql($oDB->getCol($sSQL));
|
||||
$aPlaceIDs = $oDB->getCol($sSQL);
|
||||
$sPlaceIDs = join(',', $aPlaceIDs);
|
||||
}
|
||||
|
||||
@@ -927,7 +935,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
} else {
|
||||
@@ -959,7 +967,7 @@ class SearchDescription
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach (chksql($oDB->getCol($sSQL)) as $iPlaceId) {
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
}
|
||||
@@ -1011,7 +1019,7 @@ class SearchDescription
|
||||
'Name terms (stop words)' => $this->aNameNonSearch,
|
||||
'Address terms' => $this->aAddress,
|
||||
'Address terms (stop words)' => $this->aAddressNonSearch,
|
||||
'Address terms (full words)' => $this->aFullNameAddress,
|
||||
'Address terms (full words)' => $this->aFullNameAddress ?? '',
|
||||
'Special search' => $this->iOperator,
|
||||
'Class' => $this->sClass,
|
||||
'Type' => $this->sType,
|
||||
@@ -1023,7 +1031,7 @@ class SearchDescription
|
||||
public function dumpAsHtmlTableRow(&$aWordIDs)
|
||||
{
|
||||
$kf = function ($k) use (&$aWordIDs) {
|
||||
return $aWordIDs[$k];
|
||||
return $aWordIDs[$k] ?? '['.$k.']';
|
||||
};
|
||||
|
||||
echo '<tr>';
|
||||
85
lib-php/Shell.php
Normal file
85
lib-php/Shell.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
class Shell
|
||||
{
|
||||
public function __construct($sBaseCmd, ...$aParams)
|
||||
{
|
||||
if (!$sBaseCmd) {
|
||||
throw new \Exception('Command missing in new() call');
|
||||
}
|
||||
$this->baseCmd = $sBaseCmd;
|
||||
$this->aParams = array();
|
||||
$this->aEnv = null; // null = use the same environment as the current PHP process
|
||||
|
||||
$this->stdoutString = null;
|
||||
|
||||
foreach ($aParams as $sParam) {
|
||||
$this->addParams($sParam);
|
||||
}
|
||||
}
|
||||
|
||||
public function addParams(...$aParams)
|
||||
{
|
||||
foreach ($aParams as $sParam) {
|
||||
if (isset($sParam) && $sParam !== null && $sParam !== '') {
|
||||
array_push($this->aParams, $sParam);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addEnvPair($sKey, $sVal)
|
||||
{
|
||||
if (isset($sKey) && $sKey && isset($sVal)) {
|
||||
if (!isset($this->aEnv)) $this->aEnv = $_ENV;
|
||||
$this->aEnv = array_merge($this->aEnv, array($sKey => $sVal), $_ENV);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function escapedCmd()
|
||||
{
|
||||
$aEscaped = array_map(function ($sParam) {
|
||||
return $this->escapeParam($sParam);
|
||||
}, array_merge(array($this->baseCmd), $this->aParams));
|
||||
|
||||
return join(' ', $aEscaped);
|
||||
}
|
||||
|
||||
public function run($bExitOnFail = false)
|
||||
{
|
||||
$sCmd = $this->escapedCmd();
|
||||
// $aEnv does not need escaping, proc_open seems to handle it fine
|
||||
|
||||
$aFDs = array(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => STDOUT,
|
||||
2 => STDERR
|
||||
);
|
||||
$aPipes = null;
|
||||
$hProc = @proc_open($sCmd, $aFDs, $aPipes, null, $this->aEnv);
|
||||
if (!is_resource($hProc)) {
|
||||
throw new \Exception('Unable to run command: ' . $sCmd);
|
||||
}
|
||||
|
||||
fclose($aPipes[0]); // no stdin
|
||||
|
||||
$iStat = proc_close($hProc);
|
||||
|
||||
if ($iStat != 0 && $bExitOnFail) {
|
||||
exit($iStat);
|
||||
}
|
||||
|
||||
return $iStat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function escapeParam($sParam)
|
||||
{
|
||||
if (preg_match('/^-*\w+$/', $sParam)) return $sParam;
|
||||
return escapeshellarg($sParam);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Nominatim;
|
||||
|
||||
use Exception;
|
||||
use PEAR;
|
||||
|
||||
class Status
|
||||
{
|
||||
@@ -16,12 +15,18 @@ class Status
|
||||
|
||||
public function status()
|
||||
{
|
||||
if (!$this->oDB || PEAR::isError($this->oDB)) {
|
||||
if (!$this->oDB) {
|
||||
throw new Exception('No database', 700);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->oDB->connect();
|
||||
} catch (\Nominatim\DatabaseError $e) {
|
||||
throw new Exception('Database connection failed', 700);
|
||||
}
|
||||
|
||||
$sStandardWord = $this->oDB->getOne("SELECT make_standard_name('a')");
|
||||
if (PEAR::isError($sStandardWord)) {
|
||||
if ($sStandardWord === false) {
|
||||
throw new Exception('Module failed', 701);
|
||||
}
|
||||
|
||||
@@ -32,7 +37,7 @@ class Status
|
||||
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, ';
|
||||
$sSQL .= "operator, search_name_count FROM word WHERE word_token IN (' a')";
|
||||
$iWordID = $this->oDB->getOne($sSQL);
|
||||
if (PEAR::isError($iWordID)) {
|
||||
if ($iWordID === false) {
|
||||
throw new Exception('Query failed', 703);
|
||||
}
|
||||
if (!$iWordID) {
|
||||
@@ -45,10 +50,16 @@ class Status
|
||||
$sSQL = 'SELECT EXTRACT(EPOCH FROM lastimportdate) FROM import_status LIMIT 1';
|
||||
$iDataDateEpoch = $this->oDB->getOne($sSQL);
|
||||
|
||||
if (PEAR::isError($iDataDateEpoch)) {
|
||||
throw Exception('Data date query failed '.$iDataDateEpoch->getMessage(), 705);
|
||||
if ($iDataDateEpoch === false) {
|
||||
throw new Exception('Import date is not available', 705);
|
||||
}
|
||||
|
||||
return $iDataDateEpoch;
|
||||
}
|
||||
|
||||
public function databaseVersion()
|
||||
{
|
||||
$sSQL = 'SELECT value FROM nominatim_properties WHERE property = \'database_version\'';
|
||||
return $this->oDB->getOne($sSQL);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/TokenCountry.php');
|
||||
require_once(CONST_BasePath.'/lib/TokenHousenumber.php');
|
||||
require_once(CONST_BasePath.'/lib/TokenPostcode.php');
|
||||
require_once(CONST_BasePath.'/lib/TokenSpecialTerm.php');
|
||||
require_once(CONST_BasePath.'/lib/TokenWord.php');
|
||||
require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
|
||||
require_once(CONST_LibDir.'/TokenCountry.php');
|
||||
require_once(CONST_LibDir.'/TokenHousenumber.php');
|
||||
require_once(CONST_LibDir.'/TokenPostcode.php');
|
||||
require_once(CONST_LibDir.'/TokenSpecialTerm.php');
|
||||
require_once(CONST_LibDir.'/TokenWord.php');
|
||||
require_once(CONST_LibDir.'/SpecialSearchOperator.php');
|
||||
|
||||
/**
|
||||
* Saves information about the tokens that appear in a search query.
|
||||
@@ -55,6 +55,18 @@ class TokenList
|
||||
return isset($this->aTokens[$sWord]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are partial or full tokens for the given word.
|
||||
*
|
||||
* @param string $sWord Token word to look for.
|
||||
*
|
||||
* @return bool True if there is one or more token for the token word.
|
||||
*/
|
||||
public function containsAny($sWord)
|
||||
{
|
||||
return isset($this->aTokens[$sWord]) || isset($this->aTokens[' '.$sWord]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of tokens for the given token word.
|
||||
*
|
||||
@@ -68,10 +80,25 @@ class TokenList
|
||||
return isset($this->aTokens[$sWord]) ? $this->aTokens[$sWord] : array();
|
||||
}
|
||||
|
||||
public function getFullWordIDs()
|
||||
{
|
||||
$ids = array();
|
||||
|
||||
foreach ($this->aTokens as $aTokenList) {
|
||||
foreach ($aTokenList as $oToken) {
|
||||
if (is_a($oToken, '\Nominatim\Token\Word') && !$oToken->bPartial) {
|
||||
$ids[$oToken->iId] = $oToken->iId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add token information from the word table in the database.
|
||||
*
|
||||
* @param object $oDB Database connection.
|
||||
* @param object $oDB Nominatim::DB instance.
|
||||
* @param string[] $aTokens List of tokens to look up in the database.
|
||||
* @param string[] $aCountryCodes List of country restrictions.
|
||||
* @param string $sNormQuery Normalized query string.
|
||||
@@ -85,11 +112,11 @@ class TokenList
|
||||
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code,';
|
||||
$sSQL .= ' operator, coalesce(search_name_count, 0) as count';
|
||||
$sSQL .= ' FROM word WHERE word_token in (';
|
||||
$sSQL .= join(',', array_map('getDBQuoted', $aTokens)).')';
|
||||
$sSQL .= join(',', $oDB->getDBQuotedList($aTokens)).')';
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aDBWords = chksql($oDB->getAll($sSQL), 'Could not get word tokens.');
|
||||
$aDBWords = $oDB->getAll($sSQL, null, 'Could not get word tokens.');
|
||||
|
||||
foreach ($aDBWords as $aWord) {
|
||||
$oToken = null;
|
||||
@@ -139,7 +166,8 @@ class TokenList
|
||||
$oToken = new Token\Word(
|
||||
$iId,
|
||||
$aWord['word_token'][0] != ' ',
|
||||
(int) $aWord['count']
|
||||
(int) $aWord['count'],
|
||||
substr_count($aWord['word_token'], ' ')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php');
|
||||
require_once(CONST_LibDir.'/SpecialSearchOperator.php');
|
||||
|
||||
/**
|
||||
* A word token describing a place type.
|
||||
@@ -13,12 +13,15 @@ class Word
|
||||
public $bPartial;
|
||||
/// Number of appearances in the database.
|
||||
public $iSearchNameCount;
|
||||
/// Number of terms in the word.
|
||||
public $iTermCount;
|
||||
|
||||
public function __construct($iId, $bPartial, $iSearchNameCount)
|
||||
public function __construct($iId, $bPartial, $iSearchNameCount, $iTermCount)
|
||||
{
|
||||
$this->iId = $iId;
|
||||
$this->bPartial = $bPartial;
|
||||
$this->iSearchNameCount = $iSearchNameCount;
|
||||
$this->iTermCount = $iTermCount;
|
||||
}
|
||||
|
||||
public function debugInfo()
|
||||
10
lib-php/admin/check_import_finished.php
Normal file
10
lib-php/admin/check_import_finished.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
|
||||
loadSettings(getcwd());
|
||||
|
||||
(new \Nominatim\Shell(getSetting('NOMINATIM_TOOL')))
|
||||
->addParams('admin', '--check-database')
|
||||
->run();
|
||||
9
utils/country_languages.php → lib-php/admin/country_languages.php
Executable file → Normal file
9
utils/country_languages.php → lib-php/admin/country_languages.php
Executable file → Normal file
@@ -1,8 +1,7 @@
|
||||
#!@PHP_BIN@ -Cq
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
|
||||
ini_set('memory_limit', '800M');
|
||||
ini_set('display_errors', 'stderr');
|
||||
@@ -13,10 +12,12 @@ $aCMDOptions
|
||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
include(CONST_InstallPath.'/settings/phrase_settings.php');
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
setupHTTPProxy();
|
||||
|
||||
if (true) {
|
||||
$sURL = 'https://wiki.openstreetmap.org/wiki/Special:Export/Nominatim/Country_Codes';
|
||||
43
utils/export.php → lib-php/admin/export.php
Executable file → Normal file
43
utils/export.php → lib-php/admin/export.php
Executable file → Normal file
@@ -1,12 +1,11 @@
|
||||
#!@PHP_BIN@ -Cq
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
// Script to extract structured city and street data
|
||||
// from a running nominatim instance as CSV data
|
||||
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-cmd.php');
|
||||
require_once(CONST_BasePath.'/lib/ParameterParser.php');
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/ParameterParser.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions = array(
|
||||
@@ -23,6 +22,7 @@
|
||||
array('restrict-to-osm-node', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM node'),
|
||||
array('restrict-to-osm-way', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM way'),
|
||||
array('restrict-to-osm-relation', '', 0, 1, 1, 1, 'int', 'Export only objects that are children of this OSM relation'),
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
"\nAddress ranks: continent, country, state, county, city, suburb, street, path",
|
||||
'Additional output types: postcode, placeid (placeid for each object)',
|
||||
"\noutput-format must be a semicolon-separated list of address ranks. Multiple ranks",
|
||||
@@ -32,6 +32,8 @@
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
|
||||
$aRankmap = array(
|
||||
'continent' => 1,
|
||||
'country' => 4,
|
||||
@@ -43,7 +45,8 @@
|
||||
'path' => 27
|
||||
);
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB->connect();
|
||||
|
||||
if (isset($aCMDResult['output-type'])) {
|
||||
if (!isset($aRankmap[$aCMDResult['output-type']])) fail('unknown output-type: '.$aCMDResult['output-type']);
|
||||
@@ -57,7 +60,7 @@
|
||||
$oParams = new Nominatim\ParameterParser();
|
||||
if (!isset($aCMDResult['language'])) $aCMDResult['language'] = 'xx';
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages($aCMDResult['language']);
|
||||
$sLanguagePrefArraySQL = 'ARRAY['.join(',', array_map('getDBQuoted', $aLangPrefOrder)).']';
|
||||
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
||||
|
||||
// output formatting: build up a lookup table that maps address ranks to columns
|
||||
$aColumnMapping = array();
|
||||
@@ -97,7 +100,7 @@
|
||||
$sPlacexSQL .= ' and rank_address = '.$iOutputRank;
|
||||
|
||||
if (isset($aCMDResult['restrict-to-country'])) {
|
||||
$sPlacexSQL .= ' and country_code = '.getDBQuoted($aCMDResult['restrict-to-country']);
|
||||
$sPlacexSQL .= ' and country_code = '.$oDB->getDBQuoted($aCMDResult['restrict-to-country']);
|
||||
}
|
||||
|
||||
// restriction to parent place id
|
||||
@@ -117,11 +120,8 @@
|
||||
$sOsmId = $aCMDResult['restrict-to-osm-relation'];
|
||||
}
|
||||
if ($sOsmType) {
|
||||
$sSQL = 'select place_id from placex where';
|
||||
$sSQL .= ' osm_type = '.getDBQuoted($sOsmType);
|
||||
$sSQL .= ' and osm_id = '.$sOsmId;
|
||||
$sParentId = $oDB->getOne($sSQL);
|
||||
if (PEAR::isError($sParentId)) fail(pg_last_error($oDB->connection));
|
||||
$sSQL = 'select place_id from placex where osm_type = :osm_type and osm_id = :osm_id';
|
||||
$sParentId = $oDB->getOne($sSQL, array('osm_type' => $sOsmType, 'osm_id' => $sOsmId));
|
||||
if (!$sParentId) fail('Could not find place '.$sOsmType.' '.$sOsmId);
|
||||
}
|
||||
if ($sParentId) {
|
||||
@@ -133,18 +133,15 @@
|
||||
// Iterate over placeids
|
||||
// to get further hierarchical information
|
||||
//var_dump($sPlacexSQL);
|
||||
$aRes =& $oDB->query($sPlacexSQL);
|
||||
if (PEAR::isError($aRes)) fail(pg_last_error($oDB->connection));
|
||||
$oResults = $oDB->getQueryStatement($sPlacexSQL);
|
||||
$fOutstream = fopen('php://output', 'w');
|
||||
while ($aRes->fetchInto($aRow)) {
|
||||
//var_dump($aRow);
|
||||
while ($aRow = $oResults->fetch()) {
|
||||
//var_dump($aRow);
|
||||
$iPlaceID = $aRow['place_id'];
|
||||
$sSQL = "select rank_address,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata($iPlaceID, -1)";
|
||||
$sSQL = "select rank_address,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata(:place_id, -1)";
|
||||
$sSQL .= ' WHERE isaddress';
|
||||
$sSQL .= ' order by rank_address desc,isaddress desc';
|
||||
$aAddressLines = $oDB->getAll($sSQL);
|
||||
if (PEAR::IsError($aAddressLines)) fail(pg_last_error($oDB->connection));
|
||||
|
||||
$aAddressLines = $oDB->getAll($sSQL, array('place_id' => $iPlaceID));
|
||||
|
||||
$aOutput = array_fill(0, $iNumCol, '');
|
||||
// output address parts
|
||||
@@ -159,10 +156,10 @@
|
||||
$sSQL = 'select array_agg(px.postcode) from placex px join place_addressline pa ';
|
||||
$sSQL .= 'on px.place_id = pa.address_place_id ';
|
||||
$sSQL .= 'where pa.cached_rank_address in (5,11) ';
|
||||
$sSQL .= 'and pa.place_id in (select place_id from place_addressline where address_place_id in ('.substr($aRow['place_ids'], 1, -1).')) ';
|
||||
$sSQL .= 'and pa.place_id in (select place_id from place_addressline where address_place_id in (:first_place_id)) ';
|
||||
$sSQL .= 'group by postcode order by count(*) desc limit 1';
|
||||
$sRes = $oDB->getOne($sSQL);
|
||||
if (PEAR::IsError($sRes)) fail(pg_last_error($oDB->connection));
|
||||
$sRes = $oDB->getOne($sSQL, array('first_place_id' => substr($aRow['place_ids'], 1, -1)));
|
||||
|
||||
$aOutput[$aColumnMapping['postcode']] = substr($sRes, 1, -1);
|
||||
} else {
|
||||
$aOutput[$aColumnMapping['postcode']] = $aRow['postcode'];
|
||||
93
lib-php/admin/query.php
Normal file
93
lib-php/admin/query.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/Geocode.php');
|
||||
require_once(CONST_LibDir.'/ParameterParser.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions
|
||||
= array(
|
||||
'Query database from command line. Returns search result as JSON.',
|
||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||
|
||||
array('search', '', 0, 1, 1, 1, 'string', 'Search for given term or coordinate'),
|
||||
array('country', '', 0, 1, 1, 1, 'string', 'Structured search: country'),
|
||||
array('state', '', 0, 1, 1, 1, 'string', 'Structured search: state'),
|
||||
array('county', '', 0, 1, 1, 1, 'string', 'Structured search: county'),
|
||||
array('city', '', 0, 1, 1, 1, 'string', 'Structured search: city'),
|
||||
array('street', '', 0, 1, 1, 1, 'string', 'Structured search: street'),
|
||||
array('amenity', '', 0, 1, 1, 1, 'string', 'Structured search: amenity'),
|
||||
array('postalcode', '', 0, 1, 1, 1, 'string', 'Structured search: postal code'),
|
||||
|
||||
array('accept-language', '', 0, 1, 1, 1, 'string', 'Preferred language order for showing search results'),
|
||||
array('bounded', '', 0, 1, 0, 0, 'bool', 'Restrict results to given viewbox'),
|
||||
array('nodedupe', '', 0, 1, 0, 0, 'bool', 'Do not remove duplicate results'),
|
||||
array('limit', '', 0, 1, 1, 1, 'int', 'Maximum number of results returned (default: 10)'),
|
||||
array('exclude_place_ids', '', 0, 1, 1, 1, 'string', 'Comma-separated list of place ids to exclude from results'),
|
||||
array('featureType', '', 0, 1, 1, 1, 'string', 'Restrict results to certain features (country, state,city,settlement)'),
|
||||
array('countrycodes', '', 0, 1, 1, 1, 'string', 'Comma-separated list of countries to restrict search to'),
|
||||
array('viewbox', '', 0, 1, 1, 1, 'string', 'Prefer results in given view box'),
|
||||
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
|
||||
@define('CONST_Database_DSN', getSetting('DATABASE_DSN'));
|
||||
@define('CONST_Default_Language', getSetting('DEFAULT_LANGUAGE', false));
|
||||
@define('CONST_Log_DB', getSettingBool('LOG_DB'));
|
||||
@define('CONST_Log_File', getSetting('LOG_FILE', false));
|
||||
@define('CONST_Max_Word_Frequency', getSetting('MAX_WORD_FREQUENCY'));
|
||||
@define('CONST_NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
|
||||
@define('CONST_Places_Max_ID_count', getSetting('LOOKUP_MAX_COUNT'));
|
||||
@define('CONST_PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
|
||||
@define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
|
||||
@define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
|
||||
@define('CONST_Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
|
||||
@define('CONST_Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
|
||||
@define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
|
||||
@define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
|
||||
|
||||
|
||||
$oDB = new Nominatim\DB;
|
||||
$oDB->connect();
|
||||
|
||||
if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false';
|
||||
|
||||
$oParams = new Nominatim\ParameterParser($aCMDResult);
|
||||
|
||||
$aSearchParams = array(
|
||||
'search',
|
||||
'amenity',
|
||||
'street',
|
||||
'city',
|
||||
'county',
|
||||
'state',
|
||||
'country',
|
||||
'postalcode'
|
||||
);
|
||||
|
||||
if (!$oParams->hasSetAny($aSearchParams)) {
|
||||
showUsage($aCMDOptions, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
$oGeocode = new Nominatim\Geocode($oDB);
|
||||
|
||||
$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false));
|
||||
$oGeocode->setReverseInPlan(true);
|
||||
$oGeocode->loadParamArray($oParams);
|
||||
|
||||
if ($oParams->getBool('search')) {
|
||||
$oGeocode->setQuery($aCMDResult['search']);
|
||||
} else {
|
||||
$oGeocode->setQueryFromParams($oParams);
|
||||
}
|
||||
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
|
||||
echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n";
|
||||
218
lib-php/admin/setup.php
Normal file
218
lib-php/admin/setup.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/setup/SetupClass.php');
|
||||
require_once(CONST_LibDir.'/setup_functions.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
use Nominatim\Setup\SetupFunctions as SetupFunctions;
|
||||
|
||||
// (long-opt, short-opt, min-occurs, max-occurs, num-arguments, num-arguments, type, help)
|
||||
$aCMDOptions
|
||||
= array(
|
||||
'Create and setup nominatim search system',
|
||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||
|
||||
array('osm-file', '', 0, 1, 1, 1, 'realpath', 'File to import'),
|
||||
array('threads', '', 0, 1, 1, 1, 'int', 'Number of threads (where possible)'),
|
||||
|
||||
array('all', '', 0, 1, 0, 0, 'bool', 'Do the complete process'),
|
||||
|
||||
array('create-db', '', 0, 1, 0, 0, 'bool', 'Create nominatim db'),
|
||||
array('setup-db', '', 0, 1, 0, 0, 'bool', 'Build a blank nominatim db'),
|
||||
array('import-data', '', 0, 1, 0, 0, 'bool', 'Import a osm file'),
|
||||
array('osm2pgsql-cache', '', 0, 1, 1, 1, 'int', 'Cache size used by osm2pgsql'),
|
||||
array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Do not create search tables and indexes'),
|
||||
array('create-functions', '', 0, 1, 0, 0, 'bool', 'Create functions'),
|
||||
array('enable-diff-updates', '', 0, 1, 0, 0, 'bool', 'Turn on the code required to make diff updates work'),
|
||||
array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'),
|
||||
array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'),
|
||||
array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'),
|
||||
array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'),
|
||||
array('create-partition-functions', '', 0, 1, 0, 0, 'bool', 'Create required partition triggers'),
|
||||
array('no-partitions', '', 0, 1, 0, 0, 'bool', 'Do not partition search indices (speeds up import of single country extracts)'),
|
||||
array('import-wikipedia-articles', '', 0, 1, 0, 0, 'bool', 'Import wikipedia article dump'),
|
||||
array('load-data', '', 0, 1, 0, 0, 'bool', 'Copy data to live tables from import table'),
|
||||
array('disable-token-precalc', '', 0, 1, 0, 0, 'bool', 'Disable name precalculation (EXPERT)'),
|
||||
array('import-tiger-data', '', 0, 1, 0, 0, 'bool', 'Import tiger data (not included in \'all\')'),
|
||||
array('calculate-postcodes', '', 0, 1, 0, 0, 'bool', 'Calculate postcode centroids'),
|
||||
array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'),
|
||||
array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse operations during index (EXPERT)'),
|
||||
array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
|
||||
array('create-country-names', '', 0, 1, 0, 0, 'bool', 'Create default list of searchable country names'),
|
||||
array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'),
|
||||
array('setup-website', '', 0, 1, 0, 0, 'bool', 'Used to compile environment variables for the website'),
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
);
|
||||
|
||||
// $aCMDOptions passed to getCmdOpt by reference
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
setupHTTPProxy();
|
||||
|
||||
$bDidSomething = false;
|
||||
|
||||
$oNominatimCmd = new \Nominatim\Shell(getSetting('NOMINATIM_TOOL'));
|
||||
|
||||
// by default, use all but one processor, but never more than 15.
|
||||
$iInstances = max(1, $aCMDResult['threads'] ?? (min(16, getProcessorCount()) - 1));
|
||||
|
||||
function run($oCmd)
|
||||
{
|
||||
global $iInstances;
|
||||
global $aCMDResult;
|
||||
$oCmd->addParams('--threads', $iInstances);
|
||||
if ($aCMDResult['ignore-errors'] ?? false) {
|
||||
$oCmd->addParams('--ignore-errors');
|
||||
}
|
||||
if ($aCMDResult['quiet'] ?? false) {
|
||||
$oCmd->addParams('--quiet');
|
||||
}
|
||||
if ($aCMDResult['verbose'] ?? false) {
|
||||
$oCmd->addParams('--verbose');
|
||||
}
|
||||
$oCmd->run(true);
|
||||
}
|
||||
|
||||
|
||||
//*******************************************************
|
||||
// Making some sanity check:
|
||||
// Check if osm-file is set and points to a valid file
|
||||
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
|
||||
// to remain in /lib/setup_functions.php function
|
||||
checkInFile($aCMDResult['osm-file']);
|
||||
}
|
||||
|
||||
// ******************************************************
|
||||
// instantiate Setup class
|
||||
$oSetup = new SetupFunctions($aCMDResult);
|
||||
|
||||
// *******************************************************
|
||||
// go through complete process if 'all' is selected or start selected functions
|
||||
if ($aCMDResult['create-db'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
run((clone($oNominatimCmd))->addParams('transition', '--create-db'));
|
||||
}
|
||||
|
||||
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oCmd = (clone($oNominatimCmd))->addParams('transition', '--setup-db');
|
||||
|
||||
if ($aCMDResult['no-partitions'] ?? false) {
|
||||
$oCmd->addParams('--no-partitions');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oCmd = (clone($oNominatimCmd))
|
||||
->addParams('transition', '--import-data')
|
||||
->addParams('--osm-file', $aCMDResult['osm-file']);
|
||||
if ($aCMDResult['drop'] ?? false) {
|
||||
$oCmd->addParams('--drop');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-functions'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oSetup->createSqlFunctions();
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-tables'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oCmd = (clone($oNominatimCmd))->addParams('transition', '--create-tables');
|
||||
|
||||
if ($aCMDResult['reverse-only'] ?? false) {
|
||||
$oCmd->addParams('--reverse-only');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-partition-tables'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
run((clone($oNominatimCmd))->addParams('transition', '--create-partition-tables'));
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-partition-functions'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oSetup->createSqlFunctions(); // also create partition functions
|
||||
}
|
||||
|
||||
if ($aCMDResult['import-wikipedia-articles'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
// ignore errors!
|
||||
(clone($oNominatimCmd))->addParams('refresh', '--wiki-data')->run();
|
||||
}
|
||||
|
||||
if ($aCMDResult['load-data'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
run((clone($oNominatimCmd))->addParams('transition', '--load-data'));
|
||||
}
|
||||
|
||||
if ($aCMDResult['import-tiger-data']) {
|
||||
$bDidSomething = true;
|
||||
$sTigerPath = getSetting('TIGER_DATA_PATH', CONST_InstallDir.'/tiger');
|
||||
run((clone($oNominatimCmd))->addParams('transition', '--tiger-data', $sTigerPath));
|
||||
}
|
||||
|
||||
if ($aCMDResult['calculate-postcodes'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oSetup->calculatePostcodes($aCMDResult['all']);
|
||||
}
|
||||
|
||||
if ($aCMDResult['index'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
$oCmd = (clone($oNominatimCmd))->addParams('transition', '--index');
|
||||
if ($aCMDResult['index-noanalyse'] ?? false) {
|
||||
$oCmd->addParams('--no-analyse');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aCMDResult['drop']) {
|
||||
$bDidSomething = true;
|
||||
run((clone($oNominatimCmd))->addParams('freeze'));
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-search-indices'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
|
||||
$oCmd = (clone($oNominatimCmd))->addParams('transition', '--create-search-indices');
|
||||
|
||||
if ($aCMDResult['drop'] ?? false) {
|
||||
$oCmd->addParams('--drop');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
run(clone($oNominatimCmd))->addParams('transition', '--create-country-names');
|
||||
}
|
||||
|
||||
if ($aCMDResult['setup-website'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
run((clone($oNominatimCmd))->addParams('refresh', '--website'));
|
||||
}
|
||||
|
||||
// ******************************************************
|
||||
// If we did something, repeat the warnings
|
||||
if (!$bDidSomething) {
|
||||
showUsage($aCMDOptions, true);
|
||||
} else {
|
||||
echo "Summary of warnings:\n\n";
|
||||
repeatWarnings();
|
||||
echo "\n";
|
||||
info('Setup finished.');
|
||||
}
|
||||
11
lib-php/admin/specialphrases.php
Normal file
11
lib-php/admin/specialphrases.php
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
|
||||
loadSettings(getcwd());
|
||||
|
||||
(new \Nominatim\Shell(getSetting('NOMINATIM_TOOL')))
|
||||
->addParams('special-phrases', '--import-from-wiki')
|
||||
->run();
|
||||
236
lib-php/admin/update.php
Normal file
236
lib-php/admin/update.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/setup_functions.php');
|
||||
require_once(CONST_LibDir.'/setup/SetupClass.php');
|
||||
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
use Nominatim\Setup\SetupFunctions as SetupFunctions;
|
||||
|
||||
// (long-opt, short-opt, min-occurs, max-occurs, num-arguments, num-arguments, type, help)
|
||||
$aCMDOptions
|
||||
= array(
|
||||
'Import / update / index osm data',
|
||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||
|
||||
array('init-updates', '', 0, 1, 0, 0, 'bool', 'Set up database for updating'),
|
||||
array('check-for-updates', '', 0, 1, 0, 0, 'bool', 'Check if new updates are available'),
|
||||
array('no-update-functions', '', 0, 1, 0, 0, 'bool', 'Do not update trigger functions to support differential updates (assuming the diff update logic is already present)'),
|
||||
array('import-osmosis', '', 0, 1, 0, 0, 'bool', 'Import updates once'),
|
||||
array('import-osmosis-all', '', 0, 1, 0, 0, 'bool', 'Import updates forever'),
|
||||
array('no-index', '', 0, 1, 0, 0, 'bool', 'Do not index the new data'),
|
||||
|
||||
array('calculate-postcodes', '', 0, 1, 0, 0, 'bool', 'Update postcode centroid table'),
|
||||
|
||||
array('import-file', '', 0, 1, 1, 1, 'realpath', 'Re-import data from an OSM file'),
|
||||
array('import-diff', '', 0, 1, 1, 1, 'realpath', 'Import a diff (osc) file from local file system'),
|
||||
array('osm2pgsql-cache', '', 0, 1, 1, 1, 'int', 'Cache size used by osm2pgsql'),
|
||||
|
||||
array('import-node', '', 0, 1, 1, 1, 'int', 'Re-import node'),
|
||||
array('import-way', '', 0, 1, 1, 1, 'int', 'Re-import way'),
|
||||
array('import-relation', '', 0, 1, 1, 1, 'int', 'Re-import relation'),
|
||||
array('import-from-main-api', '', 0, 1, 0, 0, 'bool', 'Use OSM API instead of Overpass to download objects'),
|
||||
|
||||
array('index', '', 0, 1, 0, 0, 'bool', 'Index'),
|
||||
array('index-rank', '', 0, 1, 1, 1, 'int', 'Rank to start indexing from'),
|
||||
array('index-instances', '', 0, 1, 1, 1, 'int', 'Number of indexing instances (threads)'),
|
||||
|
||||
array('recompute-word-counts', '', 0, 1, 0, 0, 'bool', 'Compute frequency of full-word search terms'),
|
||||
array('update-address-levels', '', 0, 1, 0, 0, 'bool', 'Reimport address level configuration (EXPERT)'),
|
||||
array('recompute-importance', '', 0, 1, 0, 0, 'bool', 'Recompute place importances'),
|
||||
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
);
|
||||
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
setupHTTPProxy();
|
||||
|
||||
if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
|
||||
if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0;
|
||||
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB->connect();
|
||||
$fPostgresVersion = $oDB->getPostgresVersion();
|
||||
|
||||
$aDSNInfo = Nominatim\DB::parseDSN(getSetting('DATABASE_DSN'));
|
||||
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
|
||||
|
||||
// cache memory to be used by osm2pgsql, should not be more than the available memory
|
||||
$iCacheMemory = (isset($aResult['osm2pgsql-cache'])?$aResult['osm2pgsql-cache']:2000);
|
||||
if ($iCacheMemory + 500 > getTotalMemoryMB()) {
|
||||
$iCacheMemory = getCacheMemoryMB();
|
||||
echo "WARNING: resetting cache memory to $iCacheMemory\n";
|
||||
}
|
||||
|
||||
$oOsm2pgsqlCmd = (new \Nominatim\Shell(getOsm2pgsqlBinary()))
|
||||
->addParams('--hstore')
|
||||
->addParams('--latlong')
|
||||
->addParams('--append')
|
||||
->addParams('--slim')
|
||||
->addParams('--with-forward-dependencies', 'false')
|
||||
->addParams('--log-progress', 'true')
|
||||
->addParams('--number-processes', 1)
|
||||
->addParams('--cache', $iCacheMemory)
|
||||
->addParams('--output', 'gazetteer')
|
||||
->addParams('--style', getImportStyle())
|
||||
->addParams('--database', $aDSNInfo['database'])
|
||||
->addParams('--port', $aDSNInfo['port']);
|
||||
|
||||
if (isset($aDSNInfo['hostspec']) && $aDSNInfo['hostspec']) {
|
||||
$oOsm2pgsqlCmd->addParams('--host', $aDSNInfo['hostspec']);
|
||||
}
|
||||
if (isset($aDSNInfo['username']) && $aDSNInfo['username']) {
|
||||
$oOsm2pgsqlCmd->addParams('--user', $aDSNInfo['username']);
|
||||
}
|
||||
if (isset($aDSNInfo['password']) && $aDSNInfo['password']) {
|
||||
$oOsm2pgsqlCmd->addEnvPair('PGPASSWORD', $aDSNInfo['password']);
|
||||
}
|
||||
if (getSetting('FLATNODE_FILE')) {
|
||||
$oOsm2pgsqlCmd->addParams('--flat-nodes', getSetting('FLATNODE_FILE'));
|
||||
}
|
||||
if ($fPostgresVersion >= 11.0) {
|
||||
$oOsm2pgsqlCmd->addEnvPair(
|
||||
'PGOPTIONS',
|
||||
'-c jit=off -c max_parallel_workers_per_gather=0'
|
||||
);
|
||||
}
|
||||
|
||||
$oNominatimCmd = new \Nominatim\Shell(getSetting('NOMINATIM_TOOL'));
|
||||
|
||||
function run($oCmd)
|
||||
{
|
||||
global $aCMDResult;
|
||||
if ($aCMDResult['quiet'] ?? false) {
|
||||
$oCmd->addParams('--quiet');
|
||||
}
|
||||
if ($aCMDResult['verbose'] ?? false) {
|
||||
$oCmd->addParams('--verbose');
|
||||
}
|
||||
$oCmd->run(true);
|
||||
}
|
||||
|
||||
|
||||
if ($aResult['init-updates']) {
|
||||
$oCmd = (clone($oNominatimCmd))->addParams('replication', '--init');
|
||||
|
||||
if ($aResult['no-update-functions']) {
|
||||
$oCmd->addParams('--no-update-functions');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
|
||||
if ($aResult['check-for-updates']) {
|
||||
exit((clone($oNominatimCmd))->addParams('replication', '--check-for-updates')->run());
|
||||
}
|
||||
|
||||
if (isset($aResult['import-diff']) || isset($aResult['import-file'])) {
|
||||
// import diffs and files directly (e.g. from osmosis --rri)
|
||||
$sNextFile = isset($aResult['import-diff']) ? $aResult['import-diff'] : $aResult['import-file'];
|
||||
|
||||
if (!file_exists($sNextFile)) {
|
||||
fail("Cannot open $sNextFile\n");
|
||||
}
|
||||
|
||||
// Import the file
|
||||
$oCMD = (clone $oOsm2pgsqlCmd)->addParams($sNextFile);
|
||||
echo $oCMD->escapedCmd()."\n";
|
||||
$iRet = $oCMD->run();
|
||||
|
||||
if ($iRet) {
|
||||
fail("Error from osm2pgsql, $iRet\n");
|
||||
}
|
||||
|
||||
// Don't update the import status - we don't know what this file contains
|
||||
}
|
||||
|
||||
if ($aResult['calculate-postcodes']) {
|
||||
run((clone($oNominatimCmd))->addParams('refresh', '--postcodes'));
|
||||
}
|
||||
|
||||
$sTemporaryFile = CONST_InstallDir.'/osmosischange.osc';
|
||||
$bHaveDiff = false;
|
||||
$bUseOSMApi = isset($aResult['import-from-main-api']) && $aResult['import-from-main-api'];
|
||||
$sContentURL = '';
|
||||
if (isset($aResult['import-node']) && $aResult['import-node']) {
|
||||
if ($bUseOSMApi) {
|
||||
$sContentURL = 'https://www.openstreetmap.org/api/0.6/node/'.$aResult['import-node'];
|
||||
} else {
|
||||
$sContentURL = 'https://overpass-api.de/api/interpreter?data=node('.$aResult['import-node'].');out%20meta;';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($aResult['import-way']) && $aResult['import-way']) {
|
||||
if ($bUseOSMApi) {
|
||||
$sContentURL = 'https://www.openstreetmap.org/api/0.6/way/'.$aResult['import-way'].'/full';
|
||||
} else {
|
||||
$sContentURL = 'https://overpass-api.de/api/interpreter?data=(way('.$aResult['import-way'].');%3E;);out%20meta;';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($aResult['import-relation']) && $aResult['import-relation']) {
|
||||
if ($bUseOSMApi) {
|
||||
$sContentURL = 'https://www.openstreetmap.org/api/0.6/relation/'.$aResult['import-relation'].'/full';
|
||||
} else {
|
||||
$sContentURL = 'https://overpass-api.de/api/interpreter?data=(rel(id:'.$aResult['import-relation'].');%3E;);out%20meta;';
|
||||
}
|
||||
}
|
||||
|
||||
if ($sContentURL) {
|
||||
file_put_contents($sTemporaryFile, file_get_contents($sContentURL));
|
||||
$bHaveDiff = true;
|
||||
}
|
||||
|
||||
if ($bHaveDiff) {
|
||||
// import generated change file
|
||||
|
||||
$oCMD = (clone $oOsm2pgsqlCmd)->addParams($sTemporaryFile);
|
||||
echo $oCMD->escapedCmd()."\n";
|
||||
|
||||
$iRet = $oCMD->run();
|
||||
if ($iRet) {
|
||||
fail("osm2pgsql exited with error level $iRet\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ($aResult['recompute-word-counts']) {
|
||||
run((clone($oNominatimCmd))->addParams('refresh', '--word-counts'));
|
||||
}
|
||||
|
||||
if ($aResult['index']) {
|
||||
run((clone $oNominatimCmd)
|
||||
->addParams('index', '--minrank', $aResult['index-rank'])
|
||||
->addParams('--threads', $aResult['index-instances']));
|
||||
}
|
||||
|
||||
if ($aResult['update-address-levels']) {
|
||||
run((clone($oNominatimCmd))->addParams('refresh', '--address-levels'));
|
||||
}
|
||||
|
||||
if ($aResult['recompute-importance']) {
|
||||
run((clone($oNominatimCmd))->addParams('refresh', '--importance'));
|
||||
}
|
||||
|
||||
if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
||||
$oCmd = (clone($oNominatimCmd))
|
||||
->addParams('replication')
|
||||
->addParams('--threads', $aResult['index-instances']);
|
||||
|
||||
if (!$aResult['import-osmosis-all']) {
|
||||
$oCmd->addParams('--once');
|
||||
}
|
||||
|
||||
if ($aResult['no-index']) {
|
||||
$oCmd->addParams('--no-index');
|
||||
}
|
||||
|
||||
run($oCmd);
|
||||
}
|
||||
95
lib-php/admin/warm.php
Normal file
95
lib-php/admin/warm.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/log.php');
|
||||
require_once(CONST_LibDir.'/Geocode.php');
|
||||
require_once(CONST_LibDir.'/PlaceLookup.php');
|
||||
require_once(CONST_LibDir.'/ReverseGeocode.php');
|
||||
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions = array(
|
||||
'Tools to warm nominatim db',
|
||||
array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
|
||||
array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
|
||||
array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
|
||||
array('reverse-only', '', 0, 1, 0, 0, 'bool', 'Warm reverse only'),
|
||||
array('search-only', '', 0, 1, 0, 0, 'bool', 'Warm search only'),
|
||||
array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
|
||||
@define('CONST_Database_DSN', getSetting('DATABASE_DSN'));
|
||||
@define('CONST_Default_Language', getSetting('DEFAULT_LANGUAGE', false));
|
||||
@define('CONST_Log_DB', getSettingBool('LOG_DB'));
|
||||
@define('CONST_Log_File', getSetting('LOG_FILE', false));
|
||||
@define('CONST_Max_Word_Frequency', getSetting('MAX_WORD_FREQUENCY'));
|
||||
@define('CONST_NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
|
||||
@define('CONST_Places_Max_ID_count', getSetting('LOOKUP_MAX_COUNT'));
|
||||
@define('CONST_PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
|
||||
@define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
|
||||
@define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
|
||||
@define('CONST_Term_Normalization_Rules', getSetting('TERM_NORMALIZATION'));
|
||||
@define('CONST_Use_Aux_Location_data', getSettingBool('USE_AUX_LOCATION_DATA'));
|
||||
@define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
|
||||
@define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
|
||||
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB->connect();
|
||||
|
||||
$bVerbose = $aResult['verbose'];
|
||||
|
||||
function print_results($aResults, $bVerbose)
|
||||
{
|
||||
if ($bVerbose) {
|
||||
if ($aResults && count($aResults)) {
|
||||
echo $aResults[0]['langaddress']."\n";
|
||||
} else {
|
||||
echo "<not found>\n";
|
||||
}
|
||||
} else {
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$aResult['search-only']) {
|
||||
$oReverseGeocode = new Nominatim\ReverseGeocode($oDB);
|
||||
$oReverseGeocode->setZoom(20);
|
||||
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
$oPlaceLookup->setLanguagePreference(array('en'));
|
||||
|
||||
echo 'Warm reverse: ';
|
||||
if ($bVerbose) echo "\n";
|
||||
for ($i = 0; $i < 1000; $i++) {
|
||||
$fLat = rand(-9000, 9000) / 100;
|
||||
$fLon = rand(-18000, 18000) / 100;
|
||||
if ($bVerbose) echo "$fLat, $fLon = ";
|
||||
|
||||
$oLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
||||
$aSearchResults = $oLookup ? $oPlaceLookup->lookup(array($oLookup->iId => $oLookup)) : null;
|
||||
print_results($aSearchResults, $bVerbose);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
if (!$aResult['reverse-only']) {
|
||||
$oGeocode = new Nominatim\Geocode($oDB);
|
||||
|
||||
echo 'Warm search: ';
|
||||
if ($bVerbose) echo "\n";
|
||||
$sSQL = 'SELECT word FROM word WHERE word is not null ORDER BY search_name_count DESC LIMIT 1000';
|
||||
foreach ($oDB->getCol($sSQL) as $sWord) {
|
||||
if ($bVerbose) echo "$sWord = ";
|
||||
|
||||
$oGeocode->setLanguagePreference(array('en'));
|
||||
$oGeocode->setQuery($sWord);
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
print_results($aSearchResults, $bVerbose);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once(CONST_LibDir.'/Shell.php');
|
||||
|
||||
function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnknown = false)
|
||||
{
|
||||
@@ -120,15 +121,6 @@ function showUsage($aSpec, $bExit = false, $sError = false)
|
||||
exit;
|
||||
}
|
||||
|
||||
function chksql($oSql, $sMsg = false)
|
||||
{
|
||||
if (PEAR::isError($oSql)) {
|
||||
fail($sMsg || $oSql->getMessage(), $oSql->userinfo);
|
||||
}
|
||||
|
||||
return $oSql;
|
||||
}
|
||||
|
||||
function info($sMsg)
|
||||
{
|
||||
echo date('Y-m-d H:i:s == ').$sMsg."\n";
|
||||
@@ -155,32 +147,35 @@ function repeatWarnings()
|
||||
function runSQLScript($sScript, $bfatal = true, $bVerbose = false, $bIgnoreErrors = false)
|
||||
{
|
||||
// Convert database DSN to psql parameters
|
||||
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
|
||||
$aDSNInfo = \Nominatim\DB::parseDSN(getSetting('DATABASE_DSN'));
|
||||
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
|
||||
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
|
||||
|
||||
$oCmd = new \Nominatim\Shell('psql');
|
||||
$oCmd->addParams('--port', $aDSNInfo['port']);
|
||||
$oCmd->addParams('--dbname', $aDSNInfo['database']);
|
||||
if (isset($aDSNInfo['hostspec']) && $aDSNInfo['hostspec']) {
|
||||
$sCMD .= ' -h ' . $aDSNInfo['hostspec'];
|
||||
$oCmd->addParams('--host', $aDSNInfo['hostspec']);
|
||||
}
|
||||
if (isset($aDSNInfo['username']) && $aDSNInfo['username']) {
|
||||
$sCMD .= ' -U ' . $aDSNInfo['username'];
|
||||
$oCmd->addParams('--username', $aDSNInfo['username']);
|
||||
}
|
||||
$aProcEnv = null;
|
||||
if (isset($aDSNInfo['password']) && $aDSNInfo['password']) {
|
||||
$aProcEnv = array_merge(array('PGPASSWORD' => $aDSNInfo['password']), $_ENV);
|
||||
if (isset($aDSNInfo['password'])) {
|
||||
$oCmd->addEnvPair('PGPASSWORD', $aDSNInfo['password']);
|
||||
}
|
||||
if (!$bVerbose) {
|
||||
$sCMD .= ' -q';
|
||||
$oCmd->addParams('--quiet');
|
||||
}
|
||||
if ($bfatal && !$bIgnoreErrors) {
|
||||
$sCMD .= ' -v ON_ERROR_STOP=1';
|
||||
$oCmd->addParams('-v', 'ON_ERROR_STOP=1');
|
||||
}
|
||||
|
||||
$aDescriptors = array(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => STDOUT,
|
||||
2 => STDERR
|
||||
);
|
||||
$ahPipes = null;
|
||||
$hProcess = @proc_open($sCMD, $aDescriptors, $ahPipes, null, $aProcEnv);
|
||||
$hProcess = @proc_open($oCmd->escapedCmd(), $aDescriptors, $ahPipes, null, $oCmd->aEnv);
|
||||
if (!is_resource($hProcess)) {
|
||||
fail('unable to start pgsql');
|
||||
}
|
||||
@@ -201,22 +196,29 @@ function runSQLScript($sScript, $bfatal = true, $bVerbose = false, $bIgnoreError
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function runWithEnv($sCmd, $aEnv)
|
||||
function setupHTTPProxy()
|
||||
{
|
||||
$aFDs = array(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => STDOUT,
|
||||
2 => STDERR
|
||||
);
|
||||
$aPipes = null;
|
||||
$hProc = @proc_open($sCmd, $aFDs, $aPipes, null, $aEnv);
|
||||
if (!is_resource($hProc)) {
|
||||
fail('unable to run command:' . $sCmd);
|
||||
if (!getSettingBool('HTTP_PROXY')) {
|
||||
return;
|
||||
}
|
||||
|
||||
fclose($aPipes[0]); // no stdin
|
||||
$sProxy = 'tcp://'.getSetting('HTTP_PROXY_HOST').':'.getSetting('HTTP_PROXY_PROT');
|
||||
$aHeaders = array();
|
||||
|
||||
$iStat = proc_close($hProc);
|
||||
return $iStat;
|
||||
$sLogin = getSetting('HTTP_PROXY_LOGIN');
|
||||
$sPassword = getSetting('HTTP_PROXY_PASSWORD');
|
||||
|
||||
if ($sLogin && $sPassword) {
|
||||
$sAuth = base64_encode($sLogin.':'.$sPassword);
|
||||
$aHeaders = array('Proxy-Authorization: Basic '.$sAuth);
|
||||
}
|
||||
|
||||
$aProxyHeader = array(
|
||||
'proxy' => $sProxy,
|
||||
'request_fulluri' => true,
|
||||
'header' => $aHeaders
|
||||
);
|
||||
|
||||
$aContext = array('http' => $aProxyHeader, 'https' => $aProxyHeader);
|
||||
stream_context_set_default($aContext);
|
||||
}
|
||||
13
lib-php/dotenv_loader.php
Normal file
13
lib-php/dotenv_loader.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
require('Symfony/Component/Dotenv/autoload.php');
|
||||
|
||||
function loadDotEnv()
|
||||
{
|
||||
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
||||
$dotenv->load(CONST_ConfigDir.'/env.defaults');
|
||||
|
||||
if (file_exists('.env')) {
|
||||
$dotenv->load('.env');
|
||||
}
|
||||
}
|
||||
5
lib-php/init-cmd.php
Normal file
5
lib-php/init-cmd.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once('init.php');
|
||||
require_once('cmd.php');
|
||||
require_once('DebugNone.php');
|
||||
86
lib-php/init-website.php
Normal file
86
lib-php/init-website.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
require_once('init.php');
|
||||
require_once('ParameterParser.php');
|
||||
require_once(CONST_Debug ? 'DebugHtml.php' : 'DebugNone.php');
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* Error handling functions
|
||||
*
|
||||
*/
|
||||
|
||||
function userError($sMsg)
|
||||
{
|
||||
throw new Exception($sMsg, 400);
|
||||
}
|
||||
|
||||
|
||||
function exception_handler_json($exception)
|
||||
{
|
||||
http_response_code($exception->getCode());
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
include(CONST_LibDir.'/template/error-json.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
function exception_handler_xml($exception)
|
||||
{
|
||||
http_response_code($exception->getCode());
|
||||
header('Content-type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
|
||||
include(CONST_LibDir.'/template/error-xml.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
function shutdown_exception_handler_xml()
|
||||
{
|
||||
$error = error_get_last();
|
||||
if ($error !== null && $error['type'] === E_ERROR) {
|
||||
exception_handler_xml(new Exception($error['message'], 500));
|
||||
}
|
||||
}
|
||||
|
||||
function shutdown_exception_handler_json()
|
||||
{
|
||||
$error = error_get_last();
|
||||
if ($error !== null && $error['type'] === E_ERROR) {
|
||||
exception_handler_json(new Exception($error['message'], 500));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function set_exception_handler_by_format($sFormat = null)
|
||||
{
|
||||
// Multiple calls to register_shutdown_function will cause multiple callbacks
|
||||
// to be executed, we only want the last executed. Thus we don't want to register
|
||||
// one by default without an explicit $sFormat set.
|
||||
|
||||
if (!isset($sFormat)) {
|
||||
set_exception_handler('exception_handler_json');
|
||||
} elseif ($sFormat == 'xml') {
|
||||
set_exception_handler('exception_handler_xml');
|
||||
register_shutdown_function('shutdown_exception_handler_xml');
|
||||
} else {
|
||||
set_exception_handler('exception_handler_json');
|
||||
register_shutdown_function('shutdown_exception_handler_json');
|
||||
}
|
||||
}
|
||||
// set a default
|
||||
set_exception_handler_by_format();
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* HTTP Reply header setup
|
||||
*/
|
||||
|
||||
if (CONST_NoAccessControl) {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: OPTIONS,GET');
|
||||
if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
|
||||
header('Access-Control-Allow-Headers: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
|
||||
}
|
||||
}
|
||||
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
|
||||
|
||||
if (CONST_Debug) header('Content-type: text/html; charset=utf-8');
|
||||
4
lib-php/init.php
Normal file
4
lib-php/init.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
require_once(CONST_LibDir.'/lib.php');
|
||||
require_once(CONST_LibDir.'/DB.php');
|
||||
@@ -1,10 +1,53 @@
|
||||
<?php
|
||||
|
||||
function loadSettings($sProjectDir)
|
||||
{
|
||||
@define('CONST_InstallDir', $sProjectDir);
|
||||
// Temporary hack to set the direcory via environment instead of
|
||||
// the installed scripts. Neither setting is part of the official
|
||||
// set of settings.
|
||||
defined('CONST_DataDir') or define('CONST_DataDir', $_SERVER['NOMINATIM_DATADIR']);
|
||||
defined('CONST_SqlDir') or define('CONST_SqlDir', $_SERVER['NOMINATIM_SQLDIR']);
|
||||
defined('CONST_ConfigDir') or define('CONST_ConfigDir', $_SERVER['NOMINATIM_CONFIGDIR']);
|
||||
defined('CONST_Default_ModulePath') or define('CONST_Default_ModulePath', $_SERVER['NOMINATIM_DATABASE_MODULE_SRC_PATH']);
|
||||
}
|
||||
|
||||
function getSetting($sConfName, $sDefault = null)
|
||||
{
|
||||
$sValue = $_SERVER['NOMINATIM_'.$sConfName];
|
||||
|
||||
if ($sDefault !== null && !$sValue) {
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
function getSettingBool($sConfName)
|
||||
{
|
||||
$sVal = strtolower(getSetting($sConfName));
|
||||
|
||||
return strcmp($sVal, 'yes') == 0
|
||||
|| strcmp($sVal, 'true') == 0
|
||||
|| strcmp($sVal, '1') == 0;
|
||||
}
|
||||
|
||||
function getSettingConfig($sConfName, $sSystemConfig)
|
||||
{
|
||||
$sValue = $_SERVER['NOMINATIM_'.$sConfName];
|
||||
|
||||
if (!$sValue) {
|
||||
return CONST_ConfigDir.'/'.$sSystemConfig;
|
||||
}
|
||||
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
function fail($sError, $sUserError = false)
|
||||
{
|
||||
if (!$sUserError) $sUserError = $sError;
|
||||
error_log('ERROR: '.$sError);
|
||||
echo $sUserError."\n";
|
||||
var_dump($sUserError)."\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@@ -55,29 +98,32 @@ function byImportance($a, $b)
|
||||
if ($a['importance'] != $b['importance'])
|
||||
return ($a['importance'] > $b['importance']?-1:1);
|
||||
|
||||
return ($a['foundorder'] < $b['foundorder']?-1:1);
|
||||
return $a['foundorder'] <=> $b['foundorder'];
|
||||
}
|
||||
|
||||
|
||||
function javascript_renderData($xVal, $iOptions = 0)
|
||||
{
|
||||
$iOptions |= JSON_UNESCAPED_UNICODE;
|
||||
$sCallback = isset($_GET['json_callback']) ? $_GET['json_callback'] : '';
|
||||
if ($sCallback && !preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $sCallback)) {
|
||||
// Unset, we call javascript_renderData again during exception handling
|
||||
unset($_GET['json_callback']);
|
||||
throw new Exception('Invalid json_callback value', 400);
|
||||
}
|
||||
|
||||
$iOptions |= JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
|
||||
if (isset($_GET['pretty']) && in_array(strtolower($_GET['pretty']), array('1', 'true'))) {
|
||||
$iOptions |= JSON_PRETTY_PRINT;
|
||||
}
|
||||
|
||||
$jsonout = json_encode($xVal, $iOptions);
|
||||
|
||||
if (!isset($_GET['json_callback'])) {
|
||||
if ($sCallback) {
|
||||
header('Content-Type: application/javascript; charset=UTF-8');
|
||||
echo $_GET['json_callback'].'('.$jsonout.')';
|
||||
} else {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
echo $jsonout;
|
||||
} else {
|
||||
if (preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $_GET['json_callback'])) {
|
||||
header('Content-Type: application/javascript; charset=UTF-8');
|
||||
echo $_GET['json_callback'].'('.$jsonout.')';
|
||||
} else {
|
||||
header('HTTP/1.0 400 Bad Request');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +138,8 @@ function parseLatLon($sQuery)
|
||||
$fQueryLat = null;
|
||||
$fQueryLon = null;
|
||||
|
||||
if (preg_match('/\\s*([NS])[ ]+([0-9]+[0-9.]*)[° ]+([0-9.]+)?[′\']*[, ]+([EW])[ ]+([0-9]+)[° ]+([0-9]+[0-9.]*)[′\']*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6
|
||||
if (preg_match('/\\s*([NS])[\s]+([0-9]+[0-9.]*)[°\s]+([0-9.]+)?[′\']*[,\s]+([EW])[\s]+([0-9]+)[°\s]+([0-9]+[0-9.]*)[′\']*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6
|
||||
* degrees decimal minutes
|
||||
* N 40 26.767, W 79 58.933
|
||||
* N 40°26.767′, W 79°58.933′
|
||||
@@ -101,8 +147,8 @@ function parseLatLon($sQuery)
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60);
|
||||
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[5] + $aData[6]/60);
|
||||
} elseif (preg_match('/\\s*([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\']*[ ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\' ]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6
|
||||
} elseif (preg_match('/\\s*([0-9]+)[°\s]+([0-9]+[0-9.]*)?[′\']*[\s]+([NS])[,\s]+([0-9]+)[°\s]+([0-9]+[0-9.]*)?[′\'\s]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6
|
||||
* degrees decimal minutes
|
||||
* 40 26.767 N, 79 58.933 W
|
||||
* 40° 26.767′ N 79° 58.933′ W
|
||||
@@ -110,8 +156,8 @@ function parseLatLon($sQuery)
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[3]=='N'?1:-1) * ($aData[1] + $aData[2]/60);
|
||||
$fQueryLon = ($aData[6]=='E'?1:-1) * ($aData[4] + $aData[5]/60);
|
||||
} elseif (preg_match('/\\s*([NS])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*[, ]+([EW])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6 7 8
|
||||
} elseif (preg_match('/\\s*([NS])[\s]+([0-9]+)[°\s]+([0-9]+)[′\'\s]+([0-9]+)[″"]*[,\s]+([EW])[\s]+([0-9]+)[°\s]+([0-9]+)[′\'\s]+([0-9]+)[″"]*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6 7 8
|
||||
* degrees decimal seconds
|
||||
* N 40 26 46 W 79 58 56
|
||||
* N 40° 26′ 46″, W 79° 58′ 56″
|
||||
@@ -119,8 +165,8 @@ function parseLatLon($sQuery)
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60 + $aData[4]/3600);
|
||||
$fQueryLon = ($aData[5]=='E'?1:-1) * ($aData[6] + $aData[7]/60 + $aData[8]/3600);
|
||||
} elseif (preg_match('/\\s*([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+[0-9.]*)[″" ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+[0-9.]*)[″" ]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6 7 8
|
||||
} elseif (preg_match('/\\s*([0-9]+)[°\s]+([0-9]+)[′\'\s]+([0-9]+[0-9.]*)[″"\s]+([NS])[,\s]+([0-9]+)[°\s]+([0-9]+)[′\'\s]+([0-9]+[0-9.]*)[″"\s]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4 5 6 7 8
|
||||
* degrees decimal seconds
|
||||
* 40 26 46 N 79 58 56 W
|
||||
* 40° 26′ 46″ N, 79° 58′ 56″ W
|
||||
@@ -129,24 +175,24 @@ function parseLatLon($sQuery)
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[4]=='N'?1:-1) * ($aData[1] + $aData[2]/60 + $aData[3]/3600);
|
||||
$fQueryLon = ($aData[8]=='E'?1:-1) * ($aData[5] + $aData[6]/60 + $aData[7]/3600);
|
||||
} elseif (preg_match('/\\s*([NS])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*[, ]+([EW])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
} elseif (preg_match('/\\s*([NS])[\s]+([0-9]+[0-9]*\\.[0-9]+)[°]*[,\s]+([EW])[\s]+([0-9]+[0-9]*\\.[0-9]+)[°]*\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
* degrees decimal
|
||||
* N 40.446° W 79.982°
|
||||
*/
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2]);
|
||||
$fQueryLon = ($aData[3]=='E'?1:-1) * ($aData[4]);
|
||||
} elseif (preg_match('/\\s*([0-9]+[0-9]*\\.[0-9]+)[° ]+([NS])[, ]+([0-9]+[0-9]*\\.[0-9]+)[° ]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
} elseif (preg_match('/\\s*([0-9]+[0-9]*\\.[0-9]+)[°\s]+([NS])[,\s]+([0-9]+[0-9]*\\.[0-9]+)[°\s]+([EW])\\s*/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
* degrees decimal
|
||||
* 40.446° N 79.982° W
|
||||
*/
|
||||
$sFound = $aData[0];
|
||||
$fQueryLat = ($aData[2]=='N'?1:-1) * ($aData[1]);
|
||||
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[3]);
|
||||
} elseif (preg_match('/(\\s*\\[|^\\s*|\\s*)(-?[0-9]+[0-9]*\\.[0-9]+)[, ]+(-?[0-9]+[0-9]*\\.[0-9]+)(\\]\\s*|\\s*$|\\s*)/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
} elseif (preg_match('/(\\s*\\[|^\\s*|\\s*)(-?[0-9]+[0-9]*\\.[0-9]+)[,\s]+(-?[0-9]+[0-9]*\\.[0-9]+)(\\]\\s*|\\s*$|\\s*)/', $sQuery, $aData)) {
|
||||
/* 1 2 3 4
|
||||
* degrees decimal
|
||||
* 12.34, 56.78
|
||||
* 12.34 56.78
|
||||
@@ -162,50 +208,6 @@ function parseLatLon($sQuery)
|
||||
return array($sFound, $fQueryLat, $fQueryLon);
|
||||
}
|
||||
|
||||
|
||||
function geometryText2Points($geometry_as_text, $fRadius)
|
||||
{
|
||||
$aPolyPoints = null;
|
||||
if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
|
||||
//
|
||||
preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
|
||||
//
|
||||
} elseif (preg_match('#LINESTRING\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
|
||||
//
|
||||
preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
|
||||
//
|
||||
} elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
|
||||
//
|
||||
preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
|
||||
//
|
||||
} elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
|
||||
//
|
||||
$aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
|
||||
//
|
||||
}
|
||||
|
||||
if (isset($aPolyPoints)) {
|
||||
$aResultPoints = array();
|
||||
foreach ($aPolyPoints as $aPoint) {
|
||||
$aResultPoints[] = array($aPoint[1], $aPoint[2]);
|
||||
}
|
||||
return $aResultPoints;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function createPointsAroundCenter($fLon, $fLat, $fRadius)
|
||||
{
|
||||
$iSteps = max(8, min(100, ($fRadius * 40000)^2));
|
||||
$fStepSize = (2*pi())/$iSteps;
|
||||
$aPolyPoints = array();
|
||||
for ($f = 0; $f < 2*pi(); $f += $fStepSize) {
|
||||
$aPolyPoints[] = array('', $fLon+($fRadius*sin($f)), $fLat+($fRadius*cos($f)) );
|
||||
}
|
||||
return $aPolyPoints;
|
||||
}
|
||||
|
||||
function closestHouseNumber($aRow)
|
||||
{
|
||||
$fHouse = $aRow['startnumber']
|
||||
@@ -225,3 +227,10 @@ function closestHouseNumber($aRow)
|
||||
|
||||
return max(min($aRow['endnumber'], $iHn), $aRow['startnumber']);
|
||||
}
|
||||
|
||||
if (!function_exists('array_key_last')) {
|
||||
function array_key_last(array $array)
|
||||
{
|
||||
if (!empty($array)) return key(array_slice($array, -1, 1, true));
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,19 @@ function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
|
||||
$sUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
else $sUserAgent = '';
|
||||
$sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
|
||||
$sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
|
||||
$sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',', $aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
|
||||
$oDB->query($sSQL);
|
||||
$sSQL .= ' values (';
|
||||
$sSQL .= join(',', $oDB->getDBQuotedList(array(
|
||||
$sType,
|
||||
$hLog[0],
|
||||
$hLog[2],
|
||||
$hLog[1],
|
||||
$sUserAgent,
|
||||
join(',', $aLanguageList),
|
||||
$sOutputFormat,
|
||||
$hLog[3]
|
||||
)));
|
||||
$sSQL .= ')';
|
||||
$oDB->exec($sSQL);
|
||||
}
|
||||
|
||||
return $hLog;
|
||||
@@ -53,11 +63,11 @@ function logEnd(&$oDB, $hLog, $iNumResults)
|
||||
if (!$aEndTime[1]) $aEndTime[1] = '0';
|
||||
$sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
|
||||
|
||||
$sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
|
||||
$sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
|
||||
$sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
|
||||
$sSQL .= ' and query = '.getDBQuoted($hLog[2]);
|
||||
$oDB->query($sSQL);
|
||||
$sSQL = 'update new_query_log set endtime = '.$oDB->getDBQuoted($sEndTime).', results = '.$iNumResults;
|
||||
$sSQL .= ' where starttime = '.$oDB->getDBQuoted($hLog[0]);
|
||||
$sSQL .= ' and ipaddress = '.$oDB->getDBQuoted($hLog[1]);
|
||||
$sSQL .= ' and query = '.$oDB->getDBQuoted($hLog[2]);
|
||||
$oDB->exec($sSQL);
|
||||
}
|
||||
|
||||
if (CONST_Log_File) {
|
||||
19
lib-php/migration/PhraseSettingsToJson.php
Normal file
19
lib-php/migration/PhraseSettingsToJson.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$phpPhraseSettingsFile = $argv[1];
|
||||
$jsonPhraseSettingsFile = dirname($phpPhraseSettingsFile).'/'.basename($phpPhraseSettingsFile, '.php').'.json';
|
||||
|
||||
if (file_exists($phpPhraseSettingsFile) && !file_exists($jsonPhraseSettingsFile)) {
|
||||
include $phpPhraseSettingsFile;
|
||||
|
||||
$data = array();
|
||||
|
||||
if (isset($aTagsBlacklist))
|
||||
$data['blackList'] = $aTagsBlacklist;
|
||||
if (isset($aTagsWhitelist))
|
||||
$data['whiteList'] = $aTagsWhitelist;
|
||||
|
||||
$jsonFile = fopen($jsonPhraseSettingsFile, 'w');
|
||||
fwrite($jsonFile, json_encode($data));
|
||||
fclose($jsonFile);
|
||||
}
|
||||
18
lib-php/output.php
Normal file
18
lib-php/output.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
function formatOSMType($sType, $bIncludeExternal = true)
|
||||
{
|
||||
if ($sType == 'N') return 'node';
|
||||
if ($sType == 'W') return 'way';
|
||||
if ($sType == 'R') return 'relation';
|
||||
|
||||
if (!$bIncludeExternal) return '';
|
||||
|
||||
if ($sType == 'T') return 'way';
|
||||
if ($sType == 'I') return 'way';
|
||||
|
||||
// not handled: P, L
|
||||
|
||||
return '';
|
||||
}
|
||||
261
lib-php/setup/SetupClass.php
Executable file
261
lib-php/setup/SetupClass.php
Executable file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim\Setup;
|
||||
|
||||
require_once(CONST_LibDir.'/Shell.php');
|
||||
|
||||
class SetupFunctions
|
||||
{
|
||||
protected $iInstances;
|
||||
protected $aDSNInfo;
|
||||
protected $bQuiet;
|
||||
protected $bVerbose;
|
||||
protected $sIgnoreErrors;
|
||||
protected $bEnableDiffUpdates;
|
||||
protected $bEnableDebugStatements;
|
||||
protected $bDrop;
|
||||
protected $oDB = null;
|
||||
protected $oNominatimCmd;
|
||||
|
||||
public function __construct(array $aCMDResult)
|
||||
{
|
||||
// by default, use all but one processor, but never more than 15.
|
||||
$this->iInstances = isset($aCMDResult['threads'])
|
||||
? $aCMDResult['threads']
|
||||
: (min(16, getProcessorCount()) - 1);
|
||||
|
||||
if ($this->iInstances < 1) {
|
||||
$this->iInstances = 1;
|
||||
warn('resetting threads to '.$this->iInstances);
|
||||
}
|
||||
|
||||
// parse database string
|
||||
$this->aDSNInfo = \Nominatim\DB::parseDSN(getSetting('DATABASE_DSN'));
|
||||
if (!isset($this->aDSNInfo['port'])) {
|
||||
$this->aDSNInfo['port'] = 5432;
|
||||
}
|
||||
|
||||
// setting member variables based on command line options stored in $aCMDResult
|
||||
$this->bQuiet = isset($aCMDResult['quiet']) && $aCMDResult['quiet'];
|
||||
$this->bVerbose = $aCMDResult['verbose'];
|
||||
|
||||
//setting default values which are not set by the update.php array
|
||||
if (isset($aCMDResult['ignore-errors'])) {
|
||||
$this->sIgnoreErrors = $aCMDResult['ignore-errors'];
|
||||
} else {
|
||||
$this->sIgnoreErrors = false;
|
||||
}
|
||||
if (isset($aCMDResult['enable-debug-statements'])) {
|
||||
$this->bEnableDebugStatements = $aCMDResult['enable-debug-statements'];
|
||||
} else {
|
||||
$this->bEnableDebugStatements = false;
|
||||
}
|
||||
if (isset($aCMDResult['enable-diff-updates'])) {
|
||||
$this->bEnableDiffUpdates = $aCMDResult['enable-diff-updates'];
|
||||
} else {
|
||||
$this->bEnableDiffUpdates = false;
|
||||
}
|
||||
|
||||
$this->bDrop = isset($aCMDResult['drop']) && $aCMDResult['drop'];
|
||||
|
||||
$this->oNominatimCmd = new \Nominatim\Shell(getSetting('NOMINATIM_TOOL'));
|
||||
if ($this->bQuiet) {
|
||||
$this->oNominatimCmd->addParams('--quiet');
|
||||
}
|
||||
if ($this->bVerbose) {
|
||||
$this->oNominatimCmd->addParams('--verbose');
|
||||
}
|
||||
}
|
||||
|
||||
public function calculatePostcodes($bCMDResultAll)
|
||||
{
|
||||
info('Calculate Postcodes');
|
||||
$this->pgsqlRunScriptFile(CONST_SqlDir.'/postcode_tables.sql');
|
||||
|
||||
$sPostcodeFilename = CONST_InstallDir.'/gb_postcode_data.sql.gz';
|
||||
if (file_exists($sPostcodeFilename)) {
|
||||
$this->pgsqlRunScriptFile($sPostcodeFilename);
|
||||
} else {
|
||||
warn('optional external GB postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
|
||||
}
|
||||
|
||||
$sPostcodeFilename = CONST_InstallDir.'/us_postcode_data.sql.gz';
|
||||
if (file_exists($sPostcodeFilename)) {
|
||||
$this->pgsqlRunScriptFile($sPostcodeFilename);
|
||||
} else {
|
||||
warn('optional external US postcode table file ('.$sPostcodeFilename.') not found. Skipping.');
|
||||
}
|
||||
|
||||
|
||||
$this->db()->exec('TRUNCATE location_postcode');
|
||||
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, country_code,";
|
||||
$sSQL .= " upper(trim (both ' ' from address->'postcode')) as pc,";
|
||||
$sSQL .= ' ST_Centroid(ST_Collect(ST_Centroid(geometry)))';
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= " WHERE address ? 'postcode' AND address->'postcode' NOT SIMILAR TO '%(,|;)%'";
|
||||
$sSQL .= ' AND geometry IS NOT null';
|
||||
$sSQL .= ' GROUP BY country_code, pc';
|
||||
$this->db()->exec($sSQL);
|
||||
|
||||
// only add postcodes that are not yet available in OSM
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, 'us', postcode,";
|
||||
$sSQL .= ' ST_SetSRID(ST_Point(x,y),4326)';
|
||||
$sSQL .= ' FROM us_postcode WHERE postcode NOT IN';
|
||||
$sSQL .= ' (SELECT postcode FROM location_postcode';
|
||||
$sSQL .= " WHERE country_code = 'us')";
|
||||
$this->db()->exec($sSQL);
|
||||
|
||||
// add missing postcodes for GB (if available)
|
||||
$sSQL = 'INSERT INTO location_postcode';
|
||||
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
|
||||
$sSQL .= "SELECT nextval('seq_place'), 1, 'gb', postcode, geometry";
|
||||
$sSQL .= ' FROM gb_postcode WHERE postcode NOT IN';
|
||||
$sSQL .= ' (SELECT postcode FROM location_postcode';
|
||||
$sSQL .= " WHERE country_code = 'gb')";
|
||||
$this->db()->exec($sSQL);
|
||||
|
||||
if (!$bCMDResultAll) {
|
||||
$sSQL = "DELETE FROM word WHERE class='place' and type='postcode'";
|
||||
$sSQL .= 'and word NOT IN (SELECT postcode FROM location_postcode)';
|
||||
$this->db()->exec($sSQL);
|
||||
}
|
||||
|
||||
$sSQL = 'SELECT count(getorcreate_postcode_id(v)) FROM ';
|
||||
$sSQL .= '(SELECT distinct(postcode) as v FROM location_postcode) p';
|
||||
$this->db()->exec($sSQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the connection to the database.
|
||||
*
|
||||
* @return Database object.
|
||||
*
|
||||
* Creates a new connection if none exists yet. Otherwise reuses the
|
||||
* already established connection.
|
||||
*/
|
||||
private function db()
|
||||
{
|
||||
if (is_null($this->oDB)) {
|
||||
$this->oDB = new \Nominatim\DB();
|
||||
$this->oDB->connect();
|
||||
}
|
||||
|
||||
return $this->oDB;
|
||||
}
|
||||
|
||||
private function pgsqlRunScript($sScript, $bfatal = true)
|
||||
{
|
||||
runSQLScript(
|
||||
$sScript,
|
||||
$bfatal,
|
||||
$this->bVerbose,
|
||||
$this->sIgnoreErrors
|
||||
);
|
||||
}
|
||||
|
||||
public function createSqlFunctions()
|
||||
{
|
||||
$oCmd = (clone($this->oNominatimCmd))
|
||||
->addParams('refresh', '--functions');
|
||||
|
||||
if (!$this->bEnableDiffUpdates) {
|
||||
$oCmd->addParams('--no-diff-updates');
|
||||
}
|
||||
|
||||
if ($this->bEnableDebugStatements) {
|
||||
$oCmd->addParams('--enable-debug-statements');
|
||||
}
|
||||
|
||||
$oCmd->run(!$this->sIgnoreErrors);
|
||||
}
|
||||
|
||||
private function pgsqlRunScriptFile($sFilename)
|
||||
{
|
||||
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
|
||||
|
||||
$oCmd = (new \Nominatim\Shell('psql'))
|
||||
->addParams('--port', $this->aDSNInfo['port'])
|
||||
->addParams('--dbname', $this->aDSNInfo['database']);
|
||||
|
||||
if (!$this->bVerbose) {
|
||||
$oCmd->addParams('--quiet');
|
||||
}
|
||||
if (isset($this->aDSNInfo['hostspec'])) {
|
||||
$oCmd->addParams('--host', $this->aDSNInfo['hostspec']);
|
||||
}
|
||||
if (isset($this->aDSNInfo['username'])) {
|
||||
$oCmd->addParams('--username', $this->aDSNInfo['username']);
|
||||
}
|
||||
if (isset($this->aDSNInfo['password'])) {
|
||||
$oCmd->addEnvPair('PGPASSWORD', $this->aDSNInfo['password']);
|
||||
}
|
||||
$ahGzipPipes = null;
|
||||
if (preg_match('/\\.gz$/', $sFilename)) {
|
||||
$aDescriptors = array(
|
||||
0 => array('pipe', 'r'),
|
||||
1 => array('pipe', 'w'),
|
||||
2 => array('file', '/dev/null', 'a')
|
||||
);
|
||||
$oZcatCmd = new \Nominatim\Shell('zcat', $sFilename);
|
||||
|
||||
$hGzipProcess = proc_open($oZcatCmd->escapedCmd(), $aDescriptors, $ahGzipPipes);
|
||||
if (!is_resource($hGzipProcess)) fail('unable to start zcat');
|
||||
$aReadPipe = $ahGzipPipes[1];
|
||||
fclose($ahGzipPipes[0]);
|
||||
} else {
|
||||
$oCmd->addParams('--file', $sFilename);
|
||||
$aReadPipe = array('pipe', 'r');
|
||||
}
|
||||
$aDescriptors = array(
|
||||
0 => $aReadPipe,
|
||||
1 => array('pipe', 'w'),
|
||||
2 => array('file', '/dev/null', 'a')
|
||||
);
|
||||
$ahPipes = null;
|
||||
|
||||
$hProcess = proc_open($oCmd->escapedCmd(), $aDescriptors, $ahPipes, null, $oCmd->aEnv);
|
||||
if (!is_resource($hProcess)) fail('unable to start pgsql');
|
||||
// TODO: error checking
|
||||
while (!feof($ahPipes[1])) {
|
||||
echo fread($ahPipes[1], 4096);
|
||||
}
|
||||
fclose($ahPipes[1]);
|
||||
$iReturn = proc_close($hProcess);
|
||||
if ($iReturn > 0) {
|
||||
fail("pgsql returned with error code ($iReturn)");
|
||||
}
|
||||
if ($ahGzipPipes) {
|
||||
fclose($ahGzipPipes[1]);
|
||||
proc_close($hGzipProcess);
|
||||
}
|
||||
}
|
||||
|
||||
private function replaceSqlPatterns($sSql)
|
||||
{
|
||||
$sSql = str_replace('{www-user}', getSetting('DATABASE_WEBUSER'), $sSql);
|
||||
|
||||
$aPatterns = array(
|
||||
'{ts:address-data}' => getSetting('TABLESPACE_ADDRESS_DATA'),
|
||||
'{ts:address-index}' => getSetting('TABLESPACE_ADDRESS_INDEX'),
|
||||
'{ts:search-data}' => getSetting('TABLESPACE_SEARCH_DATA'),
|
||||
'{ts:search-index}' => getSetting('TABLESPACE_SEARCH_INDEX'),
|
||||
'{ts:aux-data}' => getSetting('TABLESPACE_AUX_DATA'),
|
||||
'{ts:aux-index}' => getSetting('TABLESPACE_AUX_INDEX')
|
||||
);
|
||||
|
||||
foreach ($aPatterns as $sPattern => $sTablespace) {
|
||||
if ($sTablespace) {
|
||||
$sSql = str_replace($sPattern, 'TABLESPACE "'.$sTablespace.'"', $sSql);
|
||||
} else {
|
||||
$sSql = str_replace($sPattern, '', $sSql);
|
||||
}
|
||||
}
|
||||
|
||||
return $sSql;
|
||||
}
|
||||
}
|
||||
34
lib-php/setup_functions.php
Executable file
34
lib-php/setup_functions.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
function checkInFile($sOSMFile)
|
||||
{
|
||||
if (!isset($sOSMFile)) {
|
||||
fail('missing --osm-file for data import');
|
||||
}
|
||||
|
||||
if (!file_exists($sOSMFile)) {
|
||||
fail('the path supplied to --osm-file does not exist');
|
||||
}
|
||||
|
||||
if (!is_readable($sOSMFile)) {
|
||||
fail('osm-file "' . $aCMDResult['osm-file'] . '" not readable');
|
||||
}
|
||||
}
|
||||
|
||||
function getOsm2pgsqlBinary()
|
||||
{
|
||||
$sBinary = getSetting('OSM2PGSQL_BINARY');
|
||||
|
||||
return $sBinary ? $sBinary : CONST_Default_Osm2pgsql;
|
||||
}
|
||||
|
||||
function getImportStyle()
|
||||
{
|
||||
$sStyle = getSetting('IMPORT_STYLE');
|
||||
|
||||
if (in_array($sStyle, array('admin', 'street', 'address', 'full', 'extratags'))) {
|
||||
return CONST_ConfigDir.'/import-'.$sStyle.'.style';
|
||||
}
|
||||
|
||||
return $sStyle;
|
||||
}
|
||||
@@ -30,27 +30,14 @@ if (empty($aPlace)) {
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress'];
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
|
||||
if ($aPlace['placename'] !== null) {
|
||||
$aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
|
||||
}
|
||||
|
||||
if (isset($aPlace['address'])) {
|
||||
$aFieldMappings = array(
|
||||
'house_number' => 'housenumber',
|
||||
'road' => 'street',
|
||||
'locality' => 'locality',
|
||||
'postcode' => 'postcode',
|
||||
'city' => 'city',
|
||||
'district' => 'district',
|
||||
'county' => 'county',
|
||||
'state' => 'state',
|
||||
'country' => 'country'
|
||||
);
|
||||
|
||||
$aAddressNames = $aPlace['address']->getAddressNames();
|
||||
foreach ($aFieldMappings as $sFrom => $sTo) {
|
||||
if (isset($aAddressNames[$sFrom])) {
|
||||
$aFilteredPlaces['properties']['geocoding'][$sTo] = $aAddressNames[$sFrom];
|
||||
}
|
||||
}
|
||||
$aPlace['address']->addGeocodeJsonAddressParts(
|
||||
$aFilteredPlaces['properties']['geocoding']
|
||||
);
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['admin']
|
||||
= $aPlace['address']->getAdminLevels();
|
||||
@@ -28,6 +28,9 @@ if (empty($aPlace)) {
|
||||
echo join(',', $aPlace['aBoundingBox']);
|
||||
echo '"';
|
||||
}
|
||||
echo " place_rank='".$aPlace['rank_search']."'";
|
||||
echo " address_rank='".$aPlace['rank_address']."'";
|
||||
|
||||
|
||||
if (isset($aPlace['asgeojson'])) {
|
||||
echo ' geojson=\'';
|
||||
@@ -26,14 +26,15 @@ $aPlaceDetails['calculated_importance'] = (float) $aPointDetails['calculated_imp
|
||||
|
||||
$aPlaceDetails['extratags'] = $aPointDetails['aExtraTags'];
|
||||
$aPlaceDetails['calculated_wikipedia'] = $aPointDetails['wikipedia'];
|
||||
if ($aPointDetails['icon']) {
|
||||
$aPlaceDetails['icon'] = CONST_Website_BaseURL.'images/mapicons/'.$aPointDetails['icon'].'.n.32.png';
|
||||
$sIcon = Nominatim\ClassTypes\getIconFile($aPointDetails);
|
||||
if (isset($sIcon)) {
|
||||
$aPlaceDetails['icon'] = $sIcon;
|
||||
}
|
||||
|
||||
$aPlaceDetails['rank_address'] = (int) $aPointDetails['rank_address'];
|
||||
$aPlaceDetails['rank_search'] = (int) $aPointDetails['rank_search'];
|
||||
|
||||
$aPlaceDetails['isarea'] = ($aPointDetails['isarea'] == 't');
|
||||
$aPlaceDetails['isarea'] = $aPointDetails['isarea'];
|
||||
$aPlaceDetails['centroid'] = array(
|
||||
'type' => 'Point',
|
||||
'coordinates' => array( (float) $aPointDetails['lon'], (float) $aPointDetails['lat'] )
|
||||
@@ -47,11 +48,13 @@ $funcMapAddressLine = function ($aFull) {
|
||||
'place_id' => isset($aFull['place_id']) ? (int) $aFull['place_id'] : null,
|
||||
'osm_id' => isset($aFull['osm_id']) ? (int) $aFull['osm_id'] : null,
|
||||
'osm_type' => isset($aFull['osm_type']) ? $aFull['osm_type'] : null,
|
||||
'place_type' => isset($aFull['place_type']) ? $aFull['place_type'] : null,
|
||||
'class' => $aFull['class'],
|
||||
'type' => $aFull['type'],
|
||||
'admin_level' => isset($aFull['admin_level']) ? (int) $aFull['admin_level'] : null,
|
||||
'rank_address' => $aFull['rank_address'] ? (int) $aFull['rank_address'] : null,
|
||||
'distance' => (float) $aFull['distance']
|
||||
'distance' => (float) $aFull['distance'],
|
||||
'isaddress' => isset($aFull['isaddress']) ? (bool) $aFull['isaddress'] : null
|
||||
);
|
||||
|
||||
return $aMapped;
|
||||
11
lib-php/template/error-json.php
Normal file
11
lib-php/template/error-json.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$error = array(
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
);
|
||||
|
||||
if (CONST_Debug) {
|
||||
$error['details'] = $exception->getFile() . '('. $exception->getLine() . ')';
|
||||
}
|
||||
|
||||
echo javascript_renderData(array('error' => $error));
|
||||
7
lib-php/template/error-xml.php
Normal file
7
lib-php/template/error-xml.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<error>
|
||||
<code><?php echo $exception->getCode() ?></code>
|
||||
<message><?php echo $exception->getMessage() ?></message>
|
||||
<?php if (CONST_Debug) { ?>
|
||||
<details><?php echo $exception->getFile() . '('. $exception->getLine() . ')' ?></details>
|
||||
<?php } ?>
|
||||
</error>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user