mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
Compare commits
995 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e39e51e531 | ||
|
|
d545554615 | ||
|
|
07120f9af5 | ||
|
|
2a5c6b1570 | ||
|
|
6f6ebbd7be | ||
|
|
2635389a87 | ||
|
|
e022d41a01 | ||
|
|
fa084d2029 | ||
|
|
145322661c | ||
|
|
22dbee27c8 | ||
|
|
21381a0d35 | ||
|
|
10ac54b000 | ||
|
|
dfde14255a | ||
|
|
27657000b0 | ||
|
|
6b265a5fa6 | ||
|
|
64c1a4fc8c | ||
|
|
ec47459410 | ||
|
|
c55c3657c3 | ||
|
|
8b56b55761 | ||
|
|
9056c9276f | ||
|
|
09ae312f09 | ||
|
|
d6960c72e4 | ||
|
|
b529e054cf | ||
|
|
b4a4ca81d1 | ||
|
|
c284df2dc9 | ||
|
|
18b2a4c204 | ||
|
|
e1303fb592 | ||
|
|
bd25cf04ed | ||
|
|
ce1f4cbbdc | ||
|
|
e0aea0f27a | ||
|
|
9848c4c56c | ||
|
|
cb8149f8ea | ||
|
|
0e74e82a38 | ||
|
|
15e09f2b24 | ||
|
|
2de8256863 | ||
|
|
aff43fb1a3 | ||
|
|
cafd8e2b1e | ||
|
|
3794080327 | ||
|
|
4e2683f068 | ||
|
|
6e5f595d48 | ||
|
|
2c24ba6d2d | ||
|
|
3bb27fbee6 | ||
|
|
ef1b52eee5 | ||
|
|
f917fa67aa | ||
|
|
386b4c82da | ||
|
|
a987f22cfb | ||
|
|
558c42ec83 | ||
|
|
309ac46b98 | ||
|
|
399b04596e | ||
|
|
75513a23a8 | ||
|
|
e672de036e | ||
|
|
6533af6a91 | ||
|
|
d3372e69ec | ||
|
|
f3809a52e8 | ||
|
|
c5f5ab5363 | ||
|
|
26dfb868e9 | ||
|
|
d5b6042118 | ||
|
|
1115705cbc | ||
|
|
161d17d85b | ||
|
|
5a2ebfcd4a | ||
|
|
06a974df36 | ||
|
|
2762c45569 | ||
|
|
fd85483ce3 | ||
|
|
0a2d0c3b5c | ||
|
|
de7f9a4bd9 | ||
|
|
c5836c8090 | ||
|
|
dcdda314e2 | ||
|
|
a9edd57fe2 | ||
|
|
cbd9fad94b | ||
|
|
bc1009f8c2 | ||
|
|
719b66e5ed | ||
|
|
5f09ba4e10 | ||
|
|
517a0cb673 | ||
|
|
7c79b07817 | ||
|
|
23eed4ff2f | ||
|
|
4559886d83 | ||
|
|
bfc706a596 | ||
|
|
9805a461eb | ||
|
|
bcf8433ba8 | ||
|
|
746dd057b9 | ||
|
|
b710297d05 | ||
|
|
0a8e8cec0f | ||
|
|
96e5a23727 | ||
|
|
611b925368 | ||
|
|
cab2a74740 | ||
|
|
fa3ac22a8f | ||
|
|
95d1048789 | ||
|
|
38b2b8a143 | ||
|
|
3d0bc85b4d | ||
|
|
25a391070b | ||
|
|
926c4a7d04 | ||
|
|
5683f55646 | ||
|
|
671f4e943e | ||
|
|
282c0da941 | ||
|
|
78648f1faf | ||
|
|
8d9b5e4775 | ||
|
|
996026e5ed | ||
|
|
2c7e1db5f6 | ||
|
|
2171b38551 | ||
|
|
afdbdb02a1 | ||
|
|
8adeaa2c7e | ||
|
|
d15f605129 | ||
|
|
252fe42612 | ||
|
|
67e1c7dc72 | ||
|
|
c29ffc38e6 | ||
|
|
4d61cc87cf | ||
|
|
2350018106 | ||
|
|
8fc3dd9457 | ||
|
|
d97ca9fcb2 | ||
|
|
e523da9e12 | ||
|
|
67706cec4e | ||
|
|
fac8c32cda | ||
|
|
1c6f426363 | ||
|
|
8cba65809c | ||
|
|
77ed4f98bb | ||
|
|
848e5ac5de | ||
|
|
9448c5e16f | ||
|
|
0722495434 | ||
|
|
d545c6d73c | ||
|
|
f69fea4210 | ||
|
|
4cd0a4ced4 | ||
|
|
0804cc0cff | ||
|
|
faeee7528f | ||
|
|
261e0cfd5a | ||
|
|
66ecb56cea | ||
|
|
79bd54f610 | ||
|
|
30cef4d5fd | ||
|
|
8d52032263 | ||
|
|
4a5786334b | ||
|
|
587698a6f3 | ||
|
|
927d2cc824 | ||
|
|
7f9cb4e68d | ||
|
|
d48ea4f22c | ||
|
|
412bd2ec20 | ||
|
|
1c189060c2 | ||
|
|
4a00a3c0f5 | ||
|
|
8366e4ca83 | ||
|
|
283db76e45 | ||
|
|
8a36ed4f6f | ||
|
|
d0f45155c8 | ||
|
|
9fc235d670 | ||
|
|
42c549274f | ||
|
|
2e56182a7f | ||
|
|
7932b1849b | ||
|
|
886374d779 | ||
|
|
d42e2e391f | ||
|
|
f264eaeda2 | ||
|
|
35fd74af6d | ||
|
|
4b53cf1464 | ||
|
|
26e78efbb9 | ||
|
|
157f0b8a83 | ||
|
|
d743cf308e | ||
|
|
f4cdcb995c | ||
|
|
75139961a3 | ||
|
|
3e2dd59a94 | ||
|
|
c01386b5b4 | ||
|
|
9cb8447673 | ||
|
|
e67355ab0e | ||
|
|
9cb9b670d1 | ||
|
|
3e725bb2db | ||
|
|
cc45930ef9 | ||
|
|
3266daa8fd | ||
|
|
ce17b0eeca | ||
|
|
17a65d82bb | ||
|
|
cc7646665c | ||
|
|
82216ebf8b | ||
|
|
49e0d83d5d | ||
|
|
673c3c7a55 | ||
|
|
5135041405 | ||
|
|
42631b85c7 | ||
|
|
9f6f12cfeb | ||
|
|
6c4c9ec1f2 | ||
|
|
4bb4db0668 | ||
|
|
505fdd02ca | ||
|
|
a873f260cf | ||
|
|
b45f761227 | ||
|
|
d7a3039c2a | ||
|
|
6c5589c9d2 | ||
|
|
645ea5a057 | ||
|
|
2755ebe883 | ||
|
|
4b829b5ff9 | ||
|
|
ed19340af0 | ||
|
|
2d05ff0190 | ||
|
|
0d338fa4c0 | ||
|
|
15a66e7b7d | ||
|
|
3a21999a17 | ||
|
|
08dcd05d7b | ||
|
|
2337cc653b | ||
|
|
0deb9262c9 | ||
|
|
9bc5be837b | ||
|
|
b79d5494f9 | ||
|
|
ded2c5bf68 | ||
|
|
bd2c64876f | ||
|
|
7c66fef63f | ||
|
|
4ad8818809 | ||
|
|
2f4342810d | ||
|
|
36df56b093 | ||
|
|
d0a1e8e311 | ||
|
|
1b50381852 | ||
|
|
3443d2c129 | ||
|
|
1f83efa8f2 | ||
|
|
a7bd39b62a | ||
|
|
1177b30a60 | ||
|
|
10e56e0de7 | ||
|
|
6f3339cc49 | ||
|
|
771be0e056 | ||
|
|
71ad4fc406 | ||
|
|
6a5695d059 | ||
|
|
aaf0e7db06 | ||
|
|
7aa0aba382 | ||
|
|
9af190a43c | ||
|
|
2e46bc0aea | ||
|
|
a413aae8a3 | ||
|
|
317cc5c544 | ||
|
|
41bf162306 | ||
|
|
43c27dffd2 | ||
|
|
8f299838f7 | ||
|
|
146a0b29c0 | ||
|
|
964bc7fbe0 | ||
|
|
75aa3cc9bd | ||
|
|
0843fefad3 | ||
|
|
371a780ef4 | ||
|
|
c7db69a30c | ||
|
|
b48cda7173 | ||
|
|
0608cf1476 | ||
|
|
f335e78d1e | ||
|
|
dcfb228c9a | ||
|
|
dc99bbb0af | ||
|
|
c42273a4db | ||
|
|
3bf489cd7c | ||
|
|
d8240f9ee4 | ||
|
|
2448cf2a14 | ||
|
|
004883bdb1 | ||
|
|
11a1191ba0 | ||
|
|
ff66595f7a | ||
|
|
9de2a342e8 | ||
|
|
562f8bc84a | ||
|
|
d69411f414 | ||
|
|
39ccb15880 | ||
|
|
d2c56f9f96 | ||
|
|
7f1a0ce94a | ||
|
|
32dbf83747 | ||
|
|
d9d8b9c526 | ||
|
|
9036bf3398 | ||
|
|
bef5cea48e | ||
|
|
84abf7c95a | ||
|
|
1f0e1bec0e | ||
|
|
8f88613a6b | ||
|
|
e5f332bd71 | ||
|
|
07589cfc34 | ||
|
|
68e0306e62 | ||
|
|
5751686fdc | ||
|
|
2af20f8df8 | ||
|
|
60c1301fca | ||
|
|
b8a7319212 | ||
|
|
6ef4d04b46 | ||
|
|
1dce2b98b4 | ||
|
|
86c4897c9b | ||
|
|
2237603677 | ||
|
|
6e81596609 | ||
|
|
4607c7ed04 | ||
|
|
63638eb447 | ||
|
|
c92ac84679 | ||
|
|
ed9cd9f0e5 | ||
|
|
7d30dbebc5 | ||
|
|
8f03c80ce8 | ||
|
|
ee0366af88 | ||
|
|
683a3cb3ec | ||
|
|
f8bca4fbcb | ||
|
|
1e2a1d9ce5 | ||
|
|
1feac2069b | ||
|
|
26ee6b6dde | ||
|
|
c150ca4889 | ||
|
|
e717e349d0 | ||
|
|
e158017086 | ||
|
|
36d068871d | ||
|
|
6c67a4b500 | ||
|
|
86b43dc605 | ||
|
|
300921a93e | ||
|
|
35b52c4656 | ||
|
|
878302a622 | ||
|
|
55277738d4 | ||
|
|
2f54732500 | ||
|
|
41da298b18 | ||
|
|
ebcf8c2b6b | ||
|
|
1facfd019b | ||
|
|
00e3a752c9 | ||
|
|
d03fd3f883 | ||
|
|
fa3d13ac7e | ||
|
|
434bd5a5bb | ||
|
|
9aca389bda | ||
|
|
69ce42b22c | ||
|
|
114cc776be | ||
|
|
5e5cff897f | ||
|
|
a8bedb6ab9 | ||
|
|
81430bd3bd | ||
|
|
93203f355a | ||
|
|
b730d286ad | ||
|
|
3f2296e3ea | ||
|
|
2b7eb4906a | ||
|
|
db1aa4d02e | ||
|
|
ad88d7a3e0 | ||
|
|
e42c1c9c7a | ||
|
|
556bb2386d | ||
|
|
1e58cef174 | ||
|
|
01010e443f | ||
|
|
da0a7a765e | ||
|
|
9769a0dcdb | ||
|
|
fbff4fa218 | ||
|
|
d17ec56e54 | ||
|
|
9a5f75dba7 | ||
|
|
ca149fb796 | ||
|
|
08f19e074b | ||
|
|
36388cafe9 | ||
|
|
8191c747b9 | ||
|
|
d078763fa1 | ||
|
|
412ead5f2d | ||
|
|
513175ce23 | ||
|
|
8db6dd995a | ||
|
|
4be6970bd4 | ||
|
|
fa681ce246 | ||
|
|
dd5cd97713 | ||
|
|
89d47d26f0 | ||
|
|
d574ceb598 | ||
|
|
92e2f5ca8e | ||
|
|
f2bc792178 | ||
|
|
8ed096f938 | ||
|
|
3405dbf90e | ||
|
|
ee0c5e24bb | ||
|
|
b320f1c7e3 | ||
|
|
6c6b1c0606 | ||
|
|
a5f5add630 | ||
|
|
8557105c40 | ||
|
|
24e7ffb289 | ||
|
|
0b9bcfe01d | ||
|
|
1a0e8f810b | ||
|
|
7698f0672d | ||
|
|
da064ea702 | ||
|
|
0c65289a80 | ||
|
|
95c90a785f | ||
|
|
42c3754dcd | ||
|
|
b742200442 | ||
|
|
3ac70f7cc2 | ||
|
|
104722a56a | ||
|
|
1924beeb20 | ||
|
|
70f6f9a711 | ||
|
|
f1ceefe9a6 | ||
|
|
e1fc1566f3 | ||
|
|
189f74a40d | ||
|
|
370c9b38c0 | ||
|
|
df65c10360 | ||
|
|
4573389da7 | ||
|
|
5c55c1d8a1 | ||
|
|
a1d4e53eb8 | ||
|
|
16b6484c65 | ||
|
|
2156fd4909 | ||
|
|
7f5fbe1dc7 | ||
|
|
2e9090d121 | ||
|
|
23f2690c54 | ||
|
|
5226cd2a0b | ||
|
|
c7e8a82d68 | ||
|
|
77bec1261e | ||
|
|
dfcb24061e | ||
|
|
f85b0c6208 | ||
|
|
e490a30a4a | ||
|
|
654b652530 | ||
|
|
8f4426fbc8 | ||
|
|
32c1e59622 | ||
|
|
e56957f047 | ||
|
|
3cc357bffa | ||
|
|
388faa2c54 | ||
|
|
ce9ed993c8 | ||
|
|
929a13d4cd | ||
|
|
56f0d678e3 | ||
|
|
02645277c8 | ||
|
|
5f4e98e0d9 | ||
|
|
e9e14834bc | ||
|
|
5a57d6308e | ||
|
|
cb73d562d5 | ||
|
|
6c61690ef3 | ||
|
|
bf1f6a997c | ||
|
|
90b29aa808 | ||
|
|
31d0468cd2 | ||
|
|
38f467bae3 | ||
|
|
5c7c4bb9a8 | ||
|
|
9646ec4edd | ||
|
|
c665796c52 | ||
|
|
a72e2ecb3f | ||
|
|
0c47558729 | ||
|
|
93b9288c30 | ||
|
|
9d31a67116 | ||
|
|
cf19036ce6 | ||
|
|
7219ee6532 | ||
|
|
d7bc846c3c | ||
|
|
1adb0a9886 | ||
|
|
8aa01c9c8e | ||
|
|
23dabad0b0 | ||
|
|
45c675bd78 | ||
|
|
860c6ecbcc | ||
|
|
3f38091421 | ||
|
|
7704b3fc7b | ||
|
|
151b3c4021 | ||
|
|
610af95ed1 | ||
|
|
018ef5bd53 | ||
|
|
200eae3bc0 | ||
|
|
9321e425a4 | ||
|
|
9395c0dadc | ||
|
|
a40065878b | ||
|
|
e8d3c0a99a | ||
|
|
2e6ff1b750 | ||
|
|
15f9e397dd | ||
|
|
87a109d0e9 | ||
|
|
f3ffbe167d | ||
|
|
89a34e7508 | ||
|
|
f6fc750f08 | ||
|
|
c32f686c62 | ||
|
|
2ca83efc36 | ||
|
|
06796745ff | ||
|
|
093d531509 | ||
|
|
a915815e4d | ||
|
|
de3c28104c | ||
|
|
d9d13a6204 | ||
|
|
d1f5820711 | ||
|
|
7592f8f189 | ||
|
|
ffbb61713a | ||
|
|
6f51c1ba33 | ||
|
|
cd861345b7 | ||
|
|
823502a40a | ||
|
|
4efad0bb95 | ||
|
|
922352e215 | ||
|
|
8a0b2dc0be | ||
|
|
7eced34e20 | ||
|
|
64d00c1c8e | ||
|
|
6d48798d45 | ||
|
|
0e186835b9 | ||
|
|
b607eb9678 | ||
|
|
85a68f1e56 | ||
|
|
45d13bc295 | ||
|
|
2231401483 | ||
|
|
2abe9e6fd9 | ||
|
|
20f56dfc77 | ||
|
|
67664406da | ||
|
|
0ed60d29cb | ||
|
|
04ee39467a | ||
|
|
1f3edf6eba | ||
|
|
a15c197547 | ||
|
|
13dbeb75c7 | ||
|
|
6aded60045 | ||
|
|
8dfdf64dd5 | ||
|
|
41e8bddaa9 | ||
|
|
fd3dec8efe | ||
|
|
55ee08f42b | ||
|
|
b6ff697ff0 | ||
|
|
925ac1e1b9 | ||
|
|
77acc1c2be | ||
|
|
ebe489c227 | ||
|
|
9c152a030a | ||
|
|
b310c86c55 | ||
|
|
c9ff7d2130 | ||
|
|
52456230cc | ||
|
|
4422533adb | ||
|
|
c4b13f2b7f | ||
|
|
4f05a03d13 | ||
|
|
7a2e586cce | ||
|
|
98ce424650 | ||
|
|
3059a3da4e | ||
|
|
d63d7cb9a8 | ||
|
|
f3f542e864 | ||
|
|
93ada250f7 | ||
|
|
d8e3ba3b54 | ||
|
|
a46348da38 | ||
|
|
36cf0eb922 | ||
|
|
63a9bc94f7 | ||
|
|
2dafc4cf4f | ||
|
|
68d09f9cad | ||
|
|
b98d3d3f00 | ||
|
|
3683cf7ddc | ||
|
|
84e5e601e1 | ||
|
|
a1da149211 | ||
|
|
74405e9684 | ||
|
|
2fac507453 | ||
|
|
51ed55cc32 | ||
|
|
de2a3bd5f8 | ||
|
|
981e9700be | ||
|
|
b52ce4f9f2 | ||
|
|
64c591da7f | ||
|
|
2387648a85 | ||
|
|
846ecff0c5 | ||
|
|
26a5b59c28 | ||
|
|
6ddb39fda3 | ||
|
|
1fdcec985a | ||
|
|
30f526c943 | ||
|
|
253127cb9f | ||
|
|
3237ca587f | ||
|
|
0dbc0ae6d5 | ||
|
|
7461ff4680 | ||
|
|
afc714e1d3 | ||
|
|
3bc0db8d91 | ||
|
|
d573da5b2c | ||
|
|
ecd5a3fdf9 | ||
|
|
543d63e7a9 | ||
|
|
7a22ae6bf9 | ||
|
|
ebe23d6882 | ||
|
|
33c805aee0 | ||
|
|
244b6fcef6 | ||
|
|
616ff4ae25 | ||
|
|
e221eaa977 | ||
|
|
eed7abb839 | ||
|
|
5f6dcd36ed | ||
|
|
f395054536 | ||
|
|
afeafc8aa7 | ||
|
|
f1ece658f8 | ||
|
|
b3abb355eb | ||
|
|
5877b69d51 | ||
|
|
5ec2c1b712 | ||
|
|
0a73ed7d64 | ||
|
|
abf349fb0d | ||
|
|
3185fad918 | ||
|
|
0ab0f0ea44 | ||
|
|
ac467c7a2d | ||
|
|
c85b74497b | ||
|
|
3381a92d92 | ||
|
|
a2ee58d8a1 | ||
|
|
051f3720ce | ||
|
|
f017e1e9a1 | ||
|
|
33ba6896a8 | ||
|
|
f4d3ae6f70 | ||
|
|
860f3559a1 | ||
|
|
d8be8a7293 | ||
|
|
9750a361c9 | ||
|
|
ed3dd81d04 | ||
|
|
bef1aebf1c | ||
|
|
26688ba35d | ||
|
|
a1158feeb8 | ||
|
|
aef014a47d | ||
|
|
d6a0947e5a | ||
|
|
bc94318d83 | ||
|
|
d4c6e58b57 | ||
|
|
66832cf0a5 | ||
|
|
bcfe817212 | ||
|
|
07d72f950b | ||
|
|
dddfa3a075 | ||
|
|
74019877a4 | ||
|
|
465d82a92f | ||
|
|
49f889bf09 | ||
|
|
5e477e3b5b | ||
|
|
67cfad6a2c | ||
|
|
487e81fe3c | ||
|
|
18f525ac54 | ||
|
|
e0c184e097 | ||
|
|
78716ab8b9 | ||
|
|
8d082c13e0 | ||
|
|
196dc2a659 | ||
|
|
4fe797d704 | ||
|
|
3c188164ab | ||
|
|
5330370076 | ||
|
|
eecc73ea1a | ||
|
|
8c73c0795e | ||
|
|
7d68aa8f04 | ||
|
|
a0cd96e05e | ||
|
|
b19c90b9a6 | ||
|
|
e427712cb0 | ||
|
|
9864b191b1 | ||
|
|
e7574f119e | ||
|
|
51b6d16dc6 | ||
|
|
34d27ed45c | ||
|
|
094100bbf6 | ||
|
|
c8873d34af | ||
|
|
f0d640961a | ||
|
|
3746befd88 | ||
|
|
a8b037669a | ||
|
|
d819036daa | ||
|
|
6d41046b15 | ||
|
|
7b7203c149 | ||
|
|
95d4061b2a | ||
|
|
375b57a96a | ||
|
|
12ace4329d | ||
|
|
09e0be0e39 | ||
|
|
cd4bcea894 | ||
|
|
1bee151fe3 | ||
|
|
f5e52e748f | ||
|
|
b7f6c7c76a | ||
|
|
bc7f6209d8 | ||
|
|
372a548c28 | ||
|
|
5aad105c73 | ||
|
|
f40c83d025 | ||
|
|
83054af46f | ||
|
|
cb81f11422 | ||
|
|
a849f3c9ec | ||
|
|
25d854dc5c | ||
|
|
9963261d8d | ||
|
|
459ab3bbdc | ||
|
|
a21d4d3ac4 | ||
|
|
4da1f0da6f | ||
|
|
17bbe2637a | ||
|
|
6c6bbe5747 | ||
|
|
18b16e06ca | ||
|
|
e37cfc64d2 | ||
|
|
77510f4a3b | ||
|
|
d35e3c25b6 | ||
|
|
62eedbb8f6 | ||
|
|
5617bffe2f | ||
|
|
8adab2c6ca | ||
|
|
d0c44431d0 | ||
|
|
282a61ce51 | ||
|
|
7a1d22ff15 | ||
|
|
0dff71a410 | ||
|
|
26f30bff28 | ||
|
|
e6775e713c | ||
|
|
69f9122bef | ||
|
|
fc254fc744 | ||
|
|
845c43137a | ||
|
|
aaf2b6032e | ||
|
|
c4928c646d | ||
|
|
f12fe54d2b | ||
|
|
fc03c0266a | ||
|
|
7b042de300 | ||
|
|
681aad7e0d | ||
|
|
f22fa992f7 | ||
|
|
992e6f72cf | ||
|
|
e6ee3c772c | ||
|
|
9d716f0f7d | ||
|
|
95ed95c616 | ||
|
|
bf36f33e79 | ||
|
|
58ab8319b9 | ||
|
|
a87cb77ce8 | ||
|
|
2be45a35b4 | ||
|
|
9b636fdc10 | ||
|
|
b1903f0fbf | ||
|
|
00f5b78160 | ||
|
|
d58061473e | ||
|
|
33cb925f2e | ||
|
|
c70ca7f57b | ||
|
|
a6dab5e300 | ||
|
|
7cafec0750 | ||
|
|
4b12d52ef5 | ||
|
|
300612c5a8 | ||
|
|
856925d19b | ||
|
|
cbbcbb1fd7 | ||
|
|
bce93d60bd | ||
|
|
69e51aebab | ||
|
|
8ac133f2ee | ||
|
|
67996929e0 | ||
|
|
ccf119206d | ||
|
|
bc63f10057 | ||
|
|
6f15306766 | ||
|
|
161d83af5b | ||
|
|
3bf3b894ea | ||
|
|
536f08f33a | ||
|
|
3dd7410bb7 | ||
|
|
93d5be097a | ||
|
|
6eb9044353 | ||
|
|
612d34930b | ||
|
|
5be320368c | ||
|
|
7f2ad4ac7e | ||
|
|
0f00f4968c | ||
|
|
37b2c6a830 | ||
|
|
e86db3001f | ||
|
|
7b6ec4fc6c | ||
|
|
67dfa38e60 | ||
|
|
2eca9fc8af | ||
|
|
b5e5efc131 | ||
|
|
80ea13437d | ||
|
|
bf86b45178 | ||
|
|
4885fdf0f9 | ||
|
|
b7704833e4 | ||
|
|
ca7b46511d | ||
|
|
18864afa8a | ||
|
|
5ba75df507 | ||
|
|
9cf700e85d | ||
|
|
9172696324 | ||
|
|
49626ba709 | ||
|
|
baee6f3de0 | ||
|
|
28ab2f6048 | ||
|
|
90d4d339db | ||
|
|
6e0014e138 | ||
|
|
8080625747 | ||
|
|
21fb501699 | ||
|
|
0cd3a1b9bd | ||
|
|
8de483a45b | ||
|
|
3ea87169ac | ||
|
|
42d16d8296 | ||
|
|
adf3ae004f | ||
|
|
fced1172c4 | ||
|
|
299e98776e | ||
|
|
b803505402 | ||
|
|
8fb9795d04 | ||
|
|
d8623d6818 | ||
|
|
6c58a4c46c | ||
|
|
19f67e167c | ||
|
|
00d8df6fc3 | ||
|
|
02068aec7f | ||
|
|
3493d317e4 | ||
|
|
a2b486a5b0 | ||
|
|
3d0f8bdc39 | ||
|
|
04644102f2 | ||
|
|
f833cc80df | ||
|
|
df0142678a | ||
|
|
800240550b | ||
|
|
15cf7dd416 | ||
|
|
2c05fc858a | ||
|
|
a024c7665c | ||
|
|
cbb4749996 | ||
|
|
4b0d9f71e8 | ||
|
|
218c56f9a6 | ||
|
|
a35eda3d2a | ||
|
|
8a0e3e2f3d | ||
|
|
12a3d51bcc | ||
|
|
60367d95dd | ||
|
|
bd0e157b91 | ||
|
|
1821f68ca0 | ||
|
|
b5ac546275 | ||
|
|
46689df668 | ||
|
|
e828d0d3f7 | ||
|
|
cce0e5ea38 | ||
|
|
042e314589 | ||
|
|
61d813bfef | ||
|
|
ecee5cf801 | ||
|
|
9e4e913bf7 | ||
|
|
98fc528d8e | ||
|
|
d1cd2d1674 | ||
|
|
b593fe9c3e | ||
|
|
6ca6725f6e | ||
|
|
1d203fdb3c | ||
|
|
3f30699131 | ||
|
|
22bd9c4993 | ||
|
|
4654701c10 | ||
|
|
8a67ddcb2b | ||
|
|
ab71f17c47 | ||
|
|
f314abcfe1 | ||
|
|
2d1a22705f | ||
|
|
e74e577029 | ||
|
|
aa0ae610c6 | ||
|
|
dc6c4bf22e | ||
|
|
a7a5f0161f | ||
|
|
739fe1c2c4 | ||
|
|
3ba975466c | ||
|
|
d14a585cc9 | ||
|
|
7f7a7df3a2 | ||
|
|
5d5f40a82f | ||
|
|
ae6b029543 | ||
|
|
bb2bd76f91 | ||
|
|
4e1e166c6a | ||
|
|
5ff35d9984 | ||
|
|
c6a426a885 | ||
|
|
11103268e9 | ||
|
|
b332b1ae23 | ||
|
|
7e70e5f503 | ||
|
|
99fa23040a | ||
|
|
adeebec32a | ||
|
|
b93ef23d3f | ||
|
|
4002bee0c1 | ||
|
|
ed6fda6968 | ||
|
|
2ae13c5583 | ||
|
|
821dabb138 | ||
|
|
9d468f6da0 | ||
|
|
3a8ddf736e | ||
|
|
720c7b7519 | ||
|
|
0de83c4a51 | ||
|
|
8c073993ef | ||
|
|
a79ab41782 | ||
|
|
f509526e5c | ||
|
|
896199c9d4 | ||
|
|
08672cdf0a | ||
|
|
8163723e22 | ||
|
|
32a5f812a9 | ||
|
|
372874e89a | ||
|
|
8ebb8ee304 | ||
|
|
3d58254462 | ||
|
|
95de411a81 | ||
|
|
439d17569d | ||
|
|
8bcdba1a14 | ||
|
|
37e5f07d83 | ||
|
|
3c68b12176 | ||
|
|
63dc4b39bc | ||
|
|
0ea099bfd5 | ||
|
|
310776671b | ||
|
|
4b84de400b | ||
|
|
8677da2a72 | ||
|
|
de828b723e | ||
|
|
a515761193 | ||
|
|
784dad866f | ||
|
|
403e6f7e5c | ||
|
|
27f7c7fd88 | ||
|
|
4f59644cc2 | ||
|
|
c3f1d34b71 | ||
|
|
f8f20899a3 | ||
|
|
a319b0a0b4 | ||
|
|
604ddc0f9d | ||
|
|
126cabacb8 | ||
|
|
f78ae969e9 | ||
|
|
d1479072ae | ||
|
|
9a56e53d50 | ||
|
|
7899654675 | ||
|
|
a79c1bda9b | ||
|
|
665fae8343 | ||
|
|
6bee188f24 | ||
|
|
82dbcbb12a | ||
|
|
76c146f326 | ||
|
|
fd4ab3f262 | ||
|
|
cfbd3652ef | ||
|
|
e9c14979a4 | ||
|
|
e9f979b67b | ||
|
|
a323b8f63a | ||
|
|
9411c14fd2 | ||
|
|
8525e7542f | ||
|
|
7dabbc5462 | ||
|
|
de18cd1523 | ||
|
|
36a1560117 | ||
|
|
b5f311d6bc | ||
|
|
83dd4362aa | ||
|
|
a71cab639b | ||
|
|
5e0155ae29 | ||
|
|
afef83b1c6 | ||
|
|
9db13aac72 | ||
|
|
9a1f891998 | ||
|
|
7bb7ed468a | ||
|
|
4fc61d260f | ||
|
|
1ceb6926b7 | ||
|
|
d33c82cb66 | ||
|
|
4c66c35ed6 | ||
|
|
54db1d8915 | ||
|
|
a0ed80d821 | ||
|
|
e65913d376 | ||
|
|
2f266d946b | ||
|
|
b6ac4ad837 | ||
|
|
42f0282f14 | ||
|
|
af739d2f57 | ||
|
|
fa2aca1cbc | ||
|
|
943e5fe699 | ||
|
|
d09670d208 | ||
|
|
83b4b8d9c1 | ||
|
|
d32a7c1888 | ||
|
|
d0c1b73fb3 | ||
|
|
90ac15748e | ||
|
|
6be2077d92 | ||
|
|
456d439e97 | ||
|
|
2723553593 | ||
|
|
23de4c7aca | ||
|
|
ce14964943 | ||
|
|
e133476c35 | ||
|
|
524dc64ab7 | ||
|
|
17da5f45be | ||
|
|
42cd021d04 | ||
|
|
433d2f4c7d | ||
|
|
be8f5778a1 | ||
|
|
ef98a85b05 | ||
|
|
b4bd4ff67d | ||
|
|
930a5cd12a | ||
|
|
7e3701b64a | ||
|
|
165d17f7f7 | ||
|
|
3939cb614e | ||
|
|
377cf36be3 | ||
|
|
8b6652a40b | ||
|
|
479d726774 | ||
|
|
1fcc9717bb | ||
|
|
c35b3ea5c7 | ||
|
|
15beeef6ce | ||
|
|
92bc3cd0a7 | ||
|
|
0a9f971e44 | ||
|
|
4a3bbd0319 | ||
|
|
89e1446131 | ||
|
|
b694a97edf | ||
|
|
13ed184efd | ||
|
|
f03a05f6bb | ||
|
|
a6903651fc | ||
|
|
b8c544cc98 | ||
|
|
243725aae1 | ||
|
|
0bb59b2e22 | ||
|
|
837d44391c | ||
|
|
691ec08586 | ||
|
|
5425394654 | ||
|
|
1d82569f6d | ||
|
|
f74228830d | ||
|
|
a9e3329c39 | ||
|
|
a3e4e8e5cd | ||
|
|
898febcec5 | ||
|
|
855909b4e9 | ||
|
|
85d65a2fd2 | ||
|
|
cd9b0c9a20 | ||
|
|
0e11ca9b76 | ||
|
|
fd38dd02ce | ||
|
|
474418f03c | ||
|
|
6b9fea6f1a | ||
|
|
02894ca4a4 | ||
|
|
7d19209fa1 | ||
|
|
a6b4e8ff67 | ||
|
|
38c3ef3da0 | ||
|
|
610f2cc254 | ||
|
|
a79a3210e6 | ||
|
|
39ede26b5c | ||
|
|
c3f206733f | ||
|
|
69481d1590 | ||
|
|
6877668cab | ||
|
|
dc520bd156 | ||
|
|
bc4a343502 | ||
|
|
fbc8884693 | ||
|
|
c50c534d19 | ||
|
|
45627b485f | ||
|
|
b6fa121f53 | ||
|
|
9b31ffaa9f | ||
|
|
39e300640e | ||
|
|
2ffc1537e7 | ||
|
|
64abc90d30 | ||
|
|
788505095e | ||
|
|
98432395c3 | ||
|
|
6b89624f33 | ||
|
|
4b28b4fed4 | ||
|
|
fea4dbba50 | ||
|
|
83d2c440d5 | ||
|
|
e6d855b954 | ||
|
|
9f64c34f1a | ||
|
|
638ed15ada | ||
|
|
c0d8b95f67 | ||
|
|
c65938d53c | ||
|
|
2e3f3a55f1 | ||
|
|
cdd0f78bc6 | ||
|
|
9fac20ceef | ||
|
|
38bd08d25f | ||
|
|
b44493e7f2 | ||
|
|
f6ec8d2e33 | ||
|
|
c170d323d9 | ||
|
|
3ce123ab69 | ||
|
|
d8b7a51ab6 | ||
|
|
344a2bfc1a | ||
|
|
86588419fb | ||
|
|
d09db09849 | ||
|
|
1e5a8561c0 | ||
|
|
f3c9578bca | ||
|
|
3741afa6dc | ||
|
|
560a006892 | ||
|
|
4774e45218 | ||
|
|
206ee87188 | ||
|
|
a7e048484b | ||
|
|
d6b5f2f5da | ||
|
|
3df560ea38 | ||
|
|
adbaf700cd | ||
|
|
4a41bff3ab | ||
|
|
b453b0ea95 | ||
|
|
0192a7af96 | ||
|
|
630ad38a67 | ||
|
|
21156fc2a2 | ||
|
|
fa99f5bc03 | ||
|
|
09aa1e7af4 | ||
|
|
2034ed387b | ||
|
|
d6140d6d54 | ||
|
|
fb54bd3fcf | ||
|
|
a486ee347a | ||
|
|
5fb3582b31 | ||
|
|
8b0b9db31e | ||
|
|
f9889f81d6 | ||
|
|
efafa52719 | ||
|
|
8bda59fbe7 | ||
|
|
c3788d765e | ||
|
|
e407558f76 | ||
|
|
042df4198a | ||
|
|
ab6f35d83a | ||
|
|
f20d85738f | ||
|
|
f9b56a8581 | ||
|
|
fedc8ed474 | ||
|
|
79aeb31088 | ||
|
|
04857d32cd | ||
|
|
109cdce92c | ||
|
|
b7554d9ed8 | ||
|
|
6106f1a32e | ||
|
|
f2a8307bb6 | ||
|
|
470ee7aef9 | ||
|
|
aefca48e78 | ||
|
|
5e792078b3 | ||
|
|
7f7d2fd5b3 | ||
|
|
5e435b41ba | ||
|
|
44cfce1ca4 | ||
|
|
bb175cc958 | ||
|
|
5a9fb6eaf7 | ||
|
|
54d35ddfe9 | ||
|
|
7beccb7997 | ||
|
|
14a78f55cd | ||
|
|
7617a9316e | ||
|
|
a52ed366e4 | ||
|
|
7be164e2a5 | ||
|
|
a24f25c0d8 | ||
|
|
993b238a41 | ||
|
|
bbbfc8201c | ||
|
|
6f03a4d6ce | ||
|
|
c8958a22d2 | ||
|
|
37afa2180b | ||
|
|
b2df8e478a | ||
|
|
50fccb52be | ||
|
|
b90e719da5 | ||
|
|
97f1723181 | ||
|
|
80e0a3cce4 | ||
|
|
79effae933 | ||
|
|
810056349f | ||
|
|
b1d490ea53 | ||
|
|
345637290b |
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
github: lonvia
|
||||
custom: "https://nominatim.org/funding/"
|
||||
@@ -7,10 +7,13 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Note: if you are installing Nominatim through a docker image, you should report issues with the installation process with the docker repository first. -->
|
||||
<!-- Note: if you are installing Nominatim through a docker image, you should report issues with the installation process with the docker repository first.
|
||||
|
||||
Do not send screen shots! Copy any console output directly into the issue.
|
||||
-->
|
||||
|
||||
**Describe the bug**
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
<!-- A clear and concise description of what the bug is.-->
|
||||
|
||||
**To Reproduce**
|
||||
<!-- Please describe what you did to get to the issue. -->
|
||||
@@ -25,12 +28,15 @@ assignees: ''
|
||||
- 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. -->
|
||||
|
||||
**Nominatim Configuration:**
|
||||
|
||||
<!-- List the contents of your customized `.env` file. -->
|
||||
|
||||
**Additional context**
|
||||
|
||||
<!-- Add any other context about the problem here. -->
|
||||
|
||||
42
.github/actions/build-nominatim/action.yml
vendored
42
.github/actions/build-nominatim/action.yml
vendored
@@ -1,38 +1,48 @@
|
||||
name: 'Build Nominatim'
|
||||
|
||||
inputs:
|
||||
ubuntu:
|
||||
flavour:
|
||||
description: 'Version of Ubuntu to install on'
|
||||
required: false
|
||||
default: '20'
|
||||
default: 'ubuntu-20'
|
||||
cmake-args:
|
||||
description: 'Additional options to hand to cmake'
|
||||
required: false
|
||||
default: ''
|
||||
lua:
|
||||
description: 'Version of Lua to use'
|
||||
required: false
|
||||
default: '5.3'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
||||
steps:
|
||||
- name: Install prerequisites
|
||||
- name: Clean out the disk
|
||||
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
|
||||
if [ "x$UBUNTUVER" == "x18" ]; then
|
||||
pip3 install python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu osmium PyYAML==5.1 datrie
|
||||
sudo rm -rf /opt/hostedtoolcache/go /opt/hostedtoolcache/CodeQL /usr/lib/jvm /usr/local/share/chromium /usr/local/lib/android
|
||||
df -h
|
||||
shell: bash
|
||||
- name: Install${{ matrix.flavour }} 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 liblua${LUA_VERSION}-dev lua${LUA_VERSION} lua-dkjson nlohmann-json3-dev
|
||||
if [ "$FLAVOUR" == "oldstuff" ]; then
|
||||
pip3 install MarkupSafe==2.0.1 python-dotenv psycopg2==2.7.7 jinja2==2.8 psutil==5.4.2 pyicu==2.9 osmium PyYAML==5.1 sqlalchemy==1.4.31 datrie asyncpg
|
||||
else
|
||||
sudo apt-get install -y -qq python3-icu python3-datrie python3-pyosmium python3-jinja2 python3-psutil python3-psycopg2 python3-dotenv python3-yaml
|
||||
pip3 install sqlalchemy psycopg
|
||||
fi
|
||||
shell: bash
|
||||
env:
|
||||
UBUNTUVER: ${{ inputs.ubuntu }}
|
||||
|
||||
- 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
|
||||
FLAVOUR: ${{ inputs.flavour }}
|
||||
CMAKE_ARGS: ${{ inputs.cmake-args }}
|
||||
LUA_VERSION: ${{ inputs.lua }}
|
||||
|
||||
- name: Configure
|
||||
run: mkdir build && cd build && cmake ../Nominatim
|
||||
run: mkdir build && cd build && cmake $CMAKE_ARGS ../Nominatim
|
||||
shell: bash
|
||||
env:
|
||||
CMAKE_ARGS: ${{ inputs.cmake-args }}
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
||||
6
.github/actions/setup-postgresql/action.yml
vendored
6
.github/actions/setup-postgresql/action.yml
vendored
@@ -15,14 +15,16 @@ runs:
|
||||
- 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 install curl ca-certificates gnupg
|
||||
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
|
||||
sudo sh -c 'echo "deb https://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}
|
||||
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}
|
||||
shell: bash
|
||||
env:
|
||||
PGVER: ${{ inputs.postgresql-version }}
|
||||
|
||||
244
.github/workflows/ci-tests.yml
vendored
244
.github/workflows/ci-tests.yml
vendored
@@ -7,11 +7,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
data/country_osm_grid.sql.gz
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
mv nominatim-src.tar.bz2 Nominatim
|
||||
|
||||
- name: 'Upload Artifact'
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: full-source
|
||||
path: nominatim-src.tar.bz2
|
||||
@@ -37,23 +37,31 @@ jobs:
|
||||
needs: create-archive
|
||||
strategy:
|
||||
matrix:
|
||||
ubuntu: [18, 20]
|
||||
flavour: [oldstuff, "ubuntu-20", "ubuntu-22"]
|
||||
include:
|
||||
- ubuntu: 18
|
||||
postgresql: 9.5
|
||||
postgis: 2.5
|
||||
pytest: pytest
|
||||
php: 7.2
|
||||
- ubuntu: 20
|
||||
- flavour: oldstuff
|
||||
ubuntu: 20
|
||||
postgresql: '9.6'
|
||||
postgis: '2.5'
|
||||
php: '7.3'
|
||||
lua: '5.1'
|
||||
- flavour: ubuntu-20
|
||||
ubuntu: 20
|
||||
postgresql: 13
|
||||
postgis: 3
|
||||
pytest: py.test-3
|
||||
php: 7.4
|
||||
php: '7.4'
|
||||
lua: '5.3'
|
||||
- flavour: ubuntu-22
|
||||
ubuntu: 22
|
||||
postgresql: 15
|
||||
postgis: 3
|
||||
php: '8.1'
|
||||
lua: '5.3'
|
||||
|
||||
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
||||
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: full-source
|
||||
|
||||
@@ -64,13 +72,15 @@ jobs:
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: xdebug
|
||||
tools: phpunit, phpcs, composer
|
||||
tools: phpunit:9, phpcs, composer
|
||||
ini-values: opcache.jit=disable
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.6
|
||||
if: matrix.ubuntu == 18
|
||||
python-version: 3.7
|
||||
if: matrix.flavour == 'oldstuff'
|
||||
|
||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||
with:
|
||||
@@ -79,78 +89,71 @@ jobs:
|
||||
|
||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||
with:
|
||||
ubuntu: ${{ matrix.ubuntu }}
|
||||
flavour: ${{ matrix.flavour }}
|
||||
lua: ${{ matrix.lua }}
|
||||
|
||||
- name: Install test prerequsites
|
||||
run: sudo apt-get install -y -qq pylint python3-pytest python3-behave python3-pytest-cov php-codecoverage
|
||||
if: matrix.ubuntu == 20
|
||||
- name: Install test prerequsites (behave from apt)
|
||||
run: sudo apt-get install -y -qq python3-behave
|
||||
if: matrix.flavour == 'ubuntu-20'
|
||||
|
||||
- name: Install test prerequsites
|
||||
run: pip3 install pylint==2.6.0 pytest pytest-cov behave==1.2.6
|
||||
if: matrix.ubuntu == 18
|
||||
- name: Install test prerequsites (behave from pip)
|
||||
run: pip3 install behave==1.2.6
|
||||
if: (matrix.flavour == 'oldstuff') || (matrix.flavour == 'ubuntu-22')
|
||||
|
||||
- name: Install test prerequsites (from apt for Ununtu 2x)
|
||||
run: sudo apt-get install -y -qq python3-pytest python3-pytest-asyncio uvicorn
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
|
||||
- name: Install newer pytest-asyncio
|
||||
run: pip3 install -U pytest-asyncio
|
||||
if: matrix.flavour == 'ubuntu-20'
|
||||
|
||||
- name: Install test prerequsites (from pip for Ubuntu 18)
|
||||
run: pip3 install pytest pytest-asyncio uvicorn
|
||||
if: matrix.flavour == 'oldstuff'
|
||||
|
||||
- name: Install Python webservers
|
||||
run: pip3 install falcon starlette
|
||||
|
||||
- name: Install latest pylint
|
||||
run: pip3 install -U pylint asgi_lifespan
|
||||
|
||||
- name: PHP linting
|
||||
run: phpcs --report-width=120 .
|
||||
working-directory: Nominatim
|
||||
|
||||
- name: Python linting
|
||||
run: pylint nominatim
|
||||
run: python3 -m pylint nominatim
|
||||
working-directory: Nominatim
|
||||
|
||||
- name: PHP unit tests
|
||||
run: phpunit --coverage-clover ../../coverage-php.xml ./
|
||||
run: phpunit ./
|
||||
working-directory: Nominatim/test/php
|
||||
if: matrix.ubuntu == 20
|
||||
|
||||
- name: Python unit tests
|
||||
run: $PYTEST --cov=nominatim --cov-report=xml test/python
|
||||
run: python3 -m pytest test/python
|
||||
working-directory: Nominatim
|
||||
env:
|
||||
PYTEST: ${{ matrix.pytest }}
|
||||
|
||||
- name: BDD tests
|
||||
run: |
|
||||
mkdir cov
|
||||
behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3 -DPHPCOV=./cov
|
||||
composer require phpunit/phpcov:7.0.2
|
||||
vendor/bin/phpcov merge --clover ../../coverage-bdd.xml ./cov
|
||||
python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
|
||||
working-directory: Nominatim/test/bdd
|
||||
if: matrix.ubuntu == 20
|
||||
|
||||
- name: BDD tests
|
||||
run: |
|
||||
behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build --format=progress3
|
||||
working-directory: Nominatim/test/bdd
|
||||
if: matrix.ubuntu == 18
|
||||
- name: Install mypy and typechecking info
|
||||
run: pip3 install -U mypy osmium uvicorn types-PyYAML types-jinja2 types-psycopg2 types-psutil types-requests types-ujson types-Pygments typing-extensions
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
files: ./Nominatim/coverage*.xml
|
||||
directory: ./
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
||||
path_to_write_report: ./coverage/codecov_report.txt
|
||||
verbose: true
|
||||
if: matrix.ubuntu == 20
|
||||
- name: Python static typechecking
|
||||
run: python3 -m mypy --strict nominatim
|
||||
working-directory: Nominatim
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
|
||||
|
||||
icu-test:
|
||||
legacy-test:
|
||||
needs: create-archive
|
||||
strategy:
|
||||
matrix:
|
||||
ubuntu: [20]
|
||||
include:
|
||||
- ubuntu: 20
|
||||
postgresql: 13
|
||||
postgis: 3
|
||||
pytest: py.test-3
|
||||
php: 7.4
|
||||
|
||||
runs-on: ubuntu-${{ matrix.ubuntu }}.04
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: full-source
|
||||
|
||||
@@ -160,35 +163,59 @@ jobs:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: xdebug
|
||||
tools: phpunit, phpcs, composer
|
||||
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.6
|
||||
if: matrix.ubuntu == 18
|
||||
php-version: '7.4'
|
||||
|
||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||
with:
|
||||
postgresql-version: ${{ matrix.postgresql }}
|
||||
postgis-version: ${{ matrix.postgis }}
|
||||
postgresql-version: 13
|
||||
postgis-version: 3
|
||||
|
||||
- name: Install Postgresql server dev
|
||||
run: sudo apt-get install postgresql-server-dev-13
|
||||
|
||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||
with:
|
||||
ubuntu: ${{ matrix.ubuntu }}
|
||||
cmake-args: -DBUILD_MODULE=on
|
||||
|
||||
- name: Install test prerequsites
|
||||
run: sudo apt-get install -y -qq python3-behave
|
||||
if: matrix.ubuntu == 20
|
||||
|
||||
- name: BDD tests (legacy tokenizer)
|
||||
run: |
|
||||
python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=legacy --format=progress3
|
||||
working-directory: Nominatim/test/bdd
|
||||
|
||||
|
||||
python-api-test:
|
||||
needs: create-archive
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: full-source
|
||||
|
||||
- name: Unpack Nominatim
|
||||
run: tar xf nominatim-src.tar.bz2
|
||||
|
||||
- uses: ./Nominatim/.github/actions/setup-postgresql
|
||||
with:
|
||||
postgresql-version: 15
|
||||
postgis-version: 3
|
||||
|
||||
- uses: ./Nominatim/.github/actions/build-nominatim
|
||||
with:
|
||||
flavour: 'ubuntu-22'
|
||||
|
||||
- name: Install test prerequsites
|
||||
run: pip3 install behave==1.2.6
|
||||
if: matrix.ubuntu == 18
|
||||
run: sudo apt-get install -y -qq python3-behave
|
||||
|
||||
- name: BDD tests (icu tokenizer)
|
||||
- name: Install Python webservers
|
||||
run: pip3 install starlette asgi_lifespan httpx
|
||||
|
||||
- name: BDD tests (starlette)
|
||||
run: |
|
||||
behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DTOKENIZER=icu --format=progress3
|
||||
python3 -m behave -DREMOVE_TEMPLATE=1 -DBUILDDIR=$GITHUB_WORKSPACE/build -DAPI_ENGINE=starlette --format=progress3
|
||||
working-directory: Nominatim/test/bdd
|
||||
|
||||
|
||||
@@ -198,21 +225,16 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
name: [Ubuntu-18, Ubuntu-20, Centos-8]
|
||||
name: [Ubuntu-20, Ubuntu-22]
|
||||
include:
|
||||
- name: Ubuntu-18
|
||||
flavour: ubuntu
|
||||
image: "ubuntu:18.04"
|
||||
ubuntu: 18
|
||||
install_mode: install-nginx
|
||||
- name: Ubuntu-20
|
||||
flavour: ubuntu
|
||||
image: "ubuntu:20.04"
|
||||
ubuntu: 20
|
||||
install_mode: install-apache
|
||||
- name: Centos-8
|
||||
flavour: centos
|
||||
image: "centos:8"
|
||||
- name: Ubuntu-22
|
||||
image: "ubuntu:22.04"
|
||||
ubuntu: 22
|
||||
install_mode: install-apache
|
||||
|
||||
container:
|
||||
image: ${{ matrix.image }}
|
||||
@@ -232,14 +254,6 @@ jobs:
|
||||
apt-get install -y git sudo wget
|
||||
ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
|
||||
shell: bash
|
||||
if: matrix.flavour == 'ubuntu'
|
||||
|
||||
- name: Prepare container (CentOS)
|
||||
run: |
|
||||
dnf update -y
|
||||
dnf install -y sudo glibc-langpack-en
|
||||
shell: bash
|
||||
if: matrix.flavour == 'centos'
|
||||
|
||||
- name: Setup import user
|
||||
run: |
|
||||
@@ -251,7 +265,7 @@ jobs:
|
||||
OS: ${{ matrix.name }}
|
||||
INSTALL_MODE: ${{ matrix.install_mode }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: full-source
|
||||
path: /home/nominatim
|
||||
@@ -269,17 +283,24 @@ jobs:
|
||||
- name: Prepare import environment
|
||||
run: |
|
||||
mv Nominatim/test/testdb/apidb-test-data.pbf test.pbf
|
||||
mv Nominatim/settings/flex-base.lua flex-base.lua
|
||||
mv Nominatim/settings/import-extratags.lua import-extratags.lua
|
||||
mv Nominatim/settings/taginfo.lua taginfo.lua
|
||||
rm -rf Nominatim
|
||||
mkdir data-env-reverse
|
||||
working-directory: /home/nominatim
|
||||
|
||||
- name: Prepare import environment (CentOS)
|
||||
run: |
|
||||
sudo ln -s /usr/local/bin/nominatim /usr/bin/nominatim
|
||||
echo NOMINATIM_DATABASE_WEBUSER="apache" > nominatim-project/.env
|
||||
cp nominatim-project/.env data-env-reverse/.env
|
||||
- name: Print version
|
||||
run: nominatim --version
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
||||
- name: Print taginfo
|
||||
run: lua taginfo.lua
|
||||
working-directory: /home/nominatim
|
||||
if: matrix.flavour == 'centos'
|
||||
|
||||
- name: Collect host OS information
|
||||
run: nominatim admin --collect-os-info
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
||||
- name: Import
|
||||
run: nominatim import --osm-file ../test.pbf
|
||||
@@ -300,7 +321,6 @@ jobs:
|
||||
- name: Prepare update (Ubuntu)
|
||||
run: apt-get install -y python3-pip
|
||||
shell: bash
|
||||
if: matrix.flavour == 'ubuntu'
|
||||
|
||||
- name: Run update
|
||||
run: |
|
||||
@@ -309,12 +329,20 @@ jobs:
|
||||
NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
||||
- name: Clean up database
|
||||
run: nominatim refresh --postcodes --word-tokens
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
||||
- name: Run reverse-only import
|
||||
run : |
|
||||
echo 'NOMINATIM_DATABASE_DSN="pgsql:dbname=reverse"' >> .env
|
||||
nominatim import --osm-file ../test.pbf --reverse-only --no-updates
|
||||
working-directory: /home/nominatim/data-env-reverse
|
||||
|
||||
- name: Check reverse import
|
||||
- name: Check reverse-only import
|
||||
run: nominatim admin --check-database
|
||||
working-directory: /home/nominatim/data-env-reverse
|
||||
|
||||
- name: Clean up database (reverse-only import)
|
||||
run: nominatim refresh --postcodes --word-tokens
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
||||
23
.mypy.ini
Normal file
23
.mypy.ini
Normal file
@@ -0,0 +1,23 @@
|
||||
[mypy]
|
||||
plugins = sqlalchemy.ext.mypy.plugin
|
||||
|
||||
[mypy-sanic_cors.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-icu.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-asyncpg.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-datrie.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-dotenv.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-falcon.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-geoalchemy2.*]
|
||||
ignore_missing_imports = True
|
||||
@@ -1,6 +1,6 @@
|
||||
[MASTER]
|
||||
|
||||
extension-pkg-whitelist=osmium
|
||||
extension-pkg-whitelist=osmium,falcon
|
||||
ignored-modules=icu,datrie
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
@@ -10,6 +10,9 @@ ignored-modules=icu,datrie
|
||||
# closing added here because it sometimes triggers a false positive with
|
||||
# 'with' statements.
|
||||
ignored-classes=NominatimArgs,closing
|
||||
disable=too-few-public-methods,duplicate-code
|
||||
# 'too-many-ancestors' is triggered already by deriving from UserDict
|
||||
# 'not-context-manager' disabled because it causes false positives once
|
||||
# typed Python is enabled. See also https://github.com/PyCQA/pylint/issues/5273
|
||||
disable=too-few-public-methods,duplicate-code,too-many-ancestors,bad-option-value,no-self-use,not-context-manager,use-dict-literal,chained-comparison,attribute-defined-outside-init
|
||||
|
||||
good-names=i,x,y,fd,db
|
||||
good-names=i,j,x,y,m,t,fd,db,cc,x1,x2,y1,y2,pt,k,v,nr
|
||||
|
||||
16
AUTHORS
16
AUTHORS
@@ -1,15 +1,15 @@
|
||||
Nominatim was written by:
|
||||
|
||||
Brian Quinion
|
||||
Sarah Hoffmann
|
||||
Marc Tobias Metten
|
||||
* Brian Quinion
|
||||
* Sarah Hoffmann
|
||||
* Marc Tobias Metten
|
||||
|
||||
markigail
|
||||
gemo1011
|
||||
IrlJidel
|
||||
Frederik Ramm
|
||||
* markigail
|
||||
* AntoJvlt
|
||||
* gemo1011
|
||||
* darkshredder
|
||||
|
||||
and many more.
|
||||
|
||||
For a full list of contributors see
|
||||
For a full list of contributors see the Git logs or visit
|
||||
https://github.com/openstreetmap/Nominatim/graphs/contributors
|
||||
|
||||
@@ -19,13 +19,24 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
project(nominatim)
|
||||
|
||||
set(NOMINATIM_VERSION_MAJOR 4)
|
||||
set(NOMINATIM_VERSION_MINOR 0)
|
||||
set(NOMINATIM_VERSION_MINOR 3)
|
||||
set(NOMINATIM_VERSION_PATCH 2)
|
||||
|
||||
set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
|
||||
|
||||
add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
|
||||
|
||||
# Setting GIT_HASH
|
||||
find_package(Git)
|
||||
if (GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configuration
|
||||
@@ -33,7 +44,7 @@ add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
|
||||
|
||||
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_MODULE off CACHE BOOL "Build PostgreSQL module for legacy tokenizer")
|
||||
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")
|
||||
@@ -52,7 +63,6 @@ if (BUILD_IMPORTER AND BUILD_OSM2PGSQL)
|
||||
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()
|
||||
@@ -63,7 +73,7 @@ endif()
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (BUILD_IMPORTER)
|
||||
find_package(PythonInterp 3.6 REQUIRED)
|
||||
find_package(PythonInterp 3.7 REQUIRED)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -82,16 +92,6 @@ if (BUILD_API OR BUILD_IMPORTER)
|
||||
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()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -223,11 +223,17 @@ if (BUILD_IMPORTER)
|
||||
install(DIRECTORY nominatim
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
||||
FILES_MATCHING PATTERN "*.py"
|
||||
PATTERN "paths.py" EXCLUDE
|
||||
PATTERN __pycache__ EXCLUDE)
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python/nominatim
|
||||
RENAME paths.py)
|
||||
|
||||
install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
|
||||
|
||||
install(FILES data/country_name.sql
|
||||
${COUNTRY_GRID_FILE}
|
||||
install(FILES ${COUNTRY_GRID_FILE}
|
||||
data/words.sql
|
||||
DESTINATION ${NOMINATIM_DATADIR})
|
||||
endif()
|
||||
@@ -255,17 +261,20 @@ 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
|
||||
settings/import-admin.lua
|
||||
settings/import-street.lua
|
||||
settings/import-address.lua
|
||||
settings/import-full.lua
|
||||
settings/import-extratags.lua
|
||||
settings/flex-base.lua
|
||||
settings/icu_tokenizer.yaml
|
||||
settings/country_settings.yaml
|
||||
DESTINATION ${NOMINATIM_CONFIGDIR})
|
||||
|
||||
install(DIRECTORY settings/icu-rules
|
||||
DESTINATION ${NOMINATIM_CONFIGDIR})
|
||||
install(DIRECTORY settings/country-names
|
||||
DESTINATION ${NOMINATIM_CONFIGDIR})
|
||||
|
||||
if (INSTALL_MUNIN_PLUGINS)
|
||||
install(FILES munin/nominatim_importlag
|
||||
|
||||
@@ -36,7 +36,7 @@ Nominatim historically hasn't followed a particular coding style but we
|
||||
are in process of consolidating the style. The following rules apply:
|
||||
|
||||
* Python code uses the official Python style
|
||||
* indention
|
||||
* indentation
|
||||
* SQL use 2 spaces
|
||||
* all other file types use 4 spaces
|
||||
* [BSD style](https://en.wikipedia.org/wiki/Indent_style#Allman_style) for braces
|
||||
@@ -64,3 +64,39 @@ Before submitting a pull request make sure that the tests pass:
|
||||
cd build
|
||||
make test
|
||||
```
|
||||
|
||||
## Releases
|
||||
|
||||
Nominatim follows semantic versioning. Major releases are done for large changes
|
||||
that require (or at least strongly recommend) a reimport of the databases.
|
||||
Minor releases can usually be applied to exisiting databases. Patch releases
|
||||
contain bug fixes only and are released from a separate branch where the
|
||||
relevant changes are cherry-picked from the master branch.
|
||||
|
||||
Checklist for releases:
|
||||
|
||||
* [ ] increase version in `nominatim/version.py` and CMakeLists.txt
|
||||
* [ ] update `ChangeLog` (copy information from patch releases from release branch)
|
||||
* [ ] complete `docs/admin/Migration.md`
|
||||
* [ ] update EOL dates in `SECURITY.md`
|
||||
* [ ] commit and make sure CI tests pass
|
||||
* [ ] test migration
|
||||
* download, build and import previous version
|
||||
* migrate using master version
|
||||
* run updates using master version
|
||||
* [ ] prepare tarball:
|
||||
* `git clone --recursive https://github.com/osm-search/Nominatim` (switch to right branch!)
|
||||
* `rm -r .git* osm2pgsql/.git*`
|
||||
* copy country data into `data/`
|
||||
* add version to base directory and package
|
||||
* [ ] upload tarball to https://nominatim.org
|
||||
* [ ] prepare documentation
|
||||
* check out new docs branch
|
||||
* change git checkout instructions to tarball download instructions or adapt version on existing ones
|
||||
* build documentation and copy to https://github.com/osm-search/nominatim-org-site
|
||||
* add new version to history
|
||||
* [ ] check release tarball
|
||||
* download tarball as per new documentation instructions
|
||||
* compile and import Nominatim
|
||||
* run `nominatim --version` to confirm correct version
|
||||
* [ ] tag new release and add a release on github.com
|
||||
|
||||
133
ChangeLog
133
ChangeLog
@@ -1,3 +1,136 @@
|
||||
4.3.2
|
||||
* fix potential SQL injection issue for 'nominatim admin --collect-os-info'
|
||||
* PHP frontend: fix on-the-fly lookup of postcode areas near boundaries
|
||||
* Python frontend: improve handling of viewbox
|
||||
* Python frontend: correct deployment instructions
|
||||
|
||||
4.3.1
|
||||
* reintroduce result rematching
|
||||
* improve search of multi-part names
|
||||
* fix accidentally switched meaning of --reverse-only and --search-only in
|
||||
warm command
|
||||
|
||||
4.3.0
|
||||
* fix failing importance recalculation command
|
||||
* fix merging of linked names into unnamed boundaries
|
||||
* fix a number of corner cases with interpolation splitting resulting in
|
||||
invalid geometries
|
||||
* fix failure in website generation when password contains curly brackets
|
||||
* fix broken use of ST_Project in PostGIS 3.4
|
||||
* new NOMINATIM_SEARCH_WITHIN_COUNTRIES setting to restrict reverse lookups
|
||||
to known countries (thanks @alfmarcua)
|
||||
* allow negative OSM IDs (thanks @alfmarcua)
|
||||
* disallow import of Tiger data in a frozen DB
|
||||
* avoid UPDATE to change settings to be compatible with r/o DBs (thanks @t-tomek)
|
||||
* update bundled osm2pgsql to 1.9.2
|
||||
* reorganise osm2pgsql flex style and make it the default
|
||||
* exclude names ending in :wikipedia from indexing
|
||||
* no longer accept comma as a list separator in name tags
|
||||
* process forward dependencies on update to catch updates in geometries
|
||||
of ways and relations
|
||||
* fix handling of isolated silent letters during transliteration
|
||||
* no longer assign postcodes to large linear features like rivers
|
||||
* introduce nominatim.paths module for finding data and libraries
|
||||
* documentation layout changed to material theme
|
||||
* new documentation section for library
|
||||
* various smaller fixes to existing documentation
|
||||
(thanks @woodpeck, @bloom256, @biswajit-k)
|
||||
* updates to vagrant install scripts, drop support for Ubunut 18
|
||||
(thanks @n-timofeev)
|
||||
* removed obsolete configuration variables from env.defaults
|
||||
* add script for generating a taginfo description (thanks @biswajit-k)
|
||||
* modernize Python code around BDD test and add testing of Python frontend
|
||||
* lots of new BDD tests for API output
|
||||
|
||||
4.2.3
|
||||
|
||||
* fix deletion handling for 'nominatim add-data'
|
||||
* adapt place_force_delete() to new deletion handling
|
||||
* flex style: avoid dropping of postcode areas
|
||||
* fix update errors on address interpolation handling
|
||||
|
||||
4.2.2
|
||||
|
||||
* extend flex-style library to fully support all default styles
|
||||
* fix handling of Hebrew aleph
|
||||
* do not assign postcodes to rivers
|
||||
* fix string matching in PHP code
|
||||
* update osm2pgsql (various updates to flex)
|
||||
* fix slow query when deleting places on update
|
||||
* fix CLI details query
|
||||
* fix recalculation of importance values
|
||||
* fix polygon simplification in reverse results
|
||||
* add class/type information to reverse geocodejson result
|
||||
* minor improvements to default tokenizer configuration
|
||||
* various smaller fixes to documentation
|
||||
|
||||
4.2.1
|
||||
|
||||
* fix XSS vulnerability in debug view
|
||||
|
||||
4.2.0
|
||||
|
||||
* add experimental support for osm2pgsql flex style
|
||||
* introduce secondary importance value to be retrieved from a raster data file
|
||||
(currently still unused, to replace address importance, thanks to @tareqpi)
|
||||
* add new report tool `nominatim admin --collect-os-info`
|
||||
(thanks @micahcochran, @tareqpi)
|
||||
* reorganise index to improve lookup performance and size
|
||||
* run index creation after import in parallel
|
||||
* run ANALYZE more selectively to speed up continuation of indexing
|
||||
* fix crash on update when addr:interpolation receives an illegal value
|
||||
* fix minimum number of retrieved results to be at least 10
|
||||
* fix search for combinations of special term + name (e.g Hotel Bellevue)
|
||||
* do not return interpolations without a parent street on reverse search
|
||||
* improve invalidation of linked places on updates
|
||||
* fix address parsing for interpolation lines
|
||||
* make sure socket timeouts are respected during replication
|
||||
(working around a bug in some versions of pyosmium)
|
||||
* update bundled osm2pgsql to 1.7.1
|
||||
* add support for PostgreSQL 15
|
||||
* typing fixes to work with latest type annotations from typeshed
|
||||
* smaller improvements to documentation (thanks to @mausch)
|
||||
|
||||
4.1.1
|
||||
|
||||
* fix XSS vulnerability in debug view
|
||||
|
||||
4.1.0
|
||||
|
||||
* switch to ICU tokenizer as default
|
||||
* add housenumber normalization and support optional spaces during search
|
||||
* add postcode format checking and support optional spaces during search
|
||||
* add function for cleaning housenumbers in word table
|
||||
* add updates/deletion of country names imported from OSM
|
||||
* linked places no longer overwrite names from a place permanently
|
||||
* move default country name configuration into yaml file (thanks @tareqpi)
|
||||
* more compact layout for interpolation and TIGER tables
|
||||
* introduce mutations to ICU tokenizer (used for German umlauts)
|
||||
* support reinitializing a full project directory with refresh --website
|
||||
* fix various issues with linked places on updates
|
||||
* add support for external sanitizers and token analyzers
|
||||
* add CLI commands for forced indexing
|
||||
* add CLI command for version report
|
||||
* add offline import mode
|
||||
* change geocodejson to return a feature class in the 'type' field
|
||||
* add ISO3166-2 to address output (thanks @I70l0teN4ik)
|
||||
* improve parsing and matching of addr: tags
|
||||
* support relations as street members of associatedStreet
|
||||
* better ranking for address results from TIGER data
|
||||
* adapt rank classification to changed tag usage in OSM
|
||||
* update bundled osm2pgsql to 1.6.0
|
||||
* add typing information to Python code
|
||||
* improve unit test coverage
|
||||
* reorganise and speed up code for BDD tests, drop support for scenes
|
||||
* move PHP unit tests to PHP 9.5
|
||||
* extensive typo fixes in documentation (thanks @woodpeck,@StephanGeorg,
|
||||
@amandasaurus, @nslxndr, @stefkiourk, @Luflosi, @kianmeng)
|
||||
* drop official support for installation on CentOS
|
||||
* add installation instructions for Ubuntu 22.04
|
||||
* add support for PHP8
|
||||
* add setup instructions for updates and systemd
|
||||
* drop support for PostgreSQL 9.5
|
||||
|
||||
4.0.2
|
||||
|
||||
* fix XSS vulnerability in debug view
|
||||
|
||||
@@ -9,10 +9,10 @@ versions.
|
||||
|
||||
| Version | End of support for security updates |
|
||||
| ------- | ----------------------------------- |
|
||||
| 3.7.x | 2023-04-05 |
|
||||
| 3.6.x | 2022-12-12 |
|
||||
| 3.5.x | 2022-06-05 |
|
||||
| 3.4.x | 2021-10-24 |
|
||||
| 4.3.x | 2025-09-07 |
|
||||
| 4.2.x | 2024-11-24 |
|
||||
| 4.1.x | 2024-08-05 |
|
||||
| 4.0.x | 2023-11-02 |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
@@ -37,3 +37,4 @@ incident. Announcements will also be published at the
|
||||
## List of Previous Incidents
|
||||
|
||||
* 2020-05-04 - [SQL injection issue on /details endpoint](https://lists.openstreetmap.org/pipermail/geocoding/2020-May/002012.html)
|
||||
* 2023-02-21 - [cross-site scripting vulnerability](https://nominatim.org/2023/02/21/release-421.html)
|
||||
|
||||
40
VAGRANT.md
40
VAGRANT.md
@@ -1,6 +1,6 @@
|
||||
# Install Nominatim in a virtual machine for development and testing
|
||||
|
||||
This document describes how you can install Nominatim inside a Ubuntu 16
|
||||
This document describes how you can install Nominatim inside a Ubuntu 22
|
||||
virtual machine on your desktop/laptop (host machine). The goal is to give
|
||||
you a development environment to easily edit code and run the test suite
|
||||
without affecting the rest of your system.
|
||||
@@ -42,9 +42,9 @@ is.
|
||||
|
||||
```
|
||||
# inside the virtual machine:
|
||||
cd build
|
||||
wget --no-verbose --output-document=/tmp/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
||||
./utils/setup.php --osm-file /tmp/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | tee monaco.$$.log
|
||||
cd nominatim-project
|
||||
wget --no-verbose --output-document=monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
||||
nominatim import --osm-file monaco.osm.pbf 2>&1 | tee monaco.$$.log
|
||||
```
|
||||
|
||||
To repeat an import you'd need to delete the database first
|
||||
@@ -56,7 +56,7 @@ is.
|
||||
## Development
|
||||
|
||||
Vagrant maps the virtual machine's port 8089 to your host machine. Thus you can
|
||||
see Nominatim in action on [locahost:8089](http://localhost:8089/nominatim/).
|
||||
see Nominatim in action on [localhost:8089](http://localhost:8089/nominatim/).
|
||||
|
||||
You edit code on your host machine in any editor you like. There is no need to
|
||||
restart any software: just refresh your browser window.
|
||||
@@ -69,8 +69,7 @@ installation.
|
||||
PHP errors are written to `/var/log/apache2/error.log`.
|
||||
|
||||
With `echo` and `var_dump()` you write into the output (HTML/XML/JSON) when
|
||||
you either add `&debug=1` to the URL (preferred) or set
|
||||
`@define('CONST_Debug', true);` in `settings/local.php`.
|
||||
you either add `&debug=1` to the URL.
|
||||
|
||||
In the Python BDD test you can use `logger.info()` for temporary debug
|
||||
statements.
|
||||
@@ -130,6 +129,10 @@ and then
|
||||
Yes, Vagrant and Virtualbox can be installed on MS Windows just fine. You need a 64bit
|
||||
version of Windows.
|
||||
|
||||
##### Will it run on Apple Silicon?
|
||||
|
||||
You might need to replace Virtualbox with [Parallels](https://www.parallels.com/products/desktop/).
|
||||
There is no free/open source version of Parallels.
|
||||
|
||||
##### Why Monaco, can I use another country?
|
||||
|
||||
@@ -141,11 +144,12 @@ 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](https://nominatim.org/release-docs/latest/admin/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?
|
||||
|
||||
There is a Vagrant script for CentOS available, but the Nominatim directory
|
||||
There used to be a Vagrant script for CentOS available, but the Nominatim directory
|
||||
isn't symlinked/mounted to the host which makes development trickier. We used
|
||||
it mainly for debugging installation with SELinux.
|
||||
|
||||
@@ -154,14 +158,17 @@ are slightly different, e.g. the name of the package manager, Apache2 package
|
||||
name, location of files. We chose Ubuntu because that is closest to the
|
||||
nominatim.openstreetmap.org production environment.
|
||||
|
||||
You can configure/download other Vagrant boxes from [https://app.vagrantup.com/boxes/search](https://app.vagrantup.com/boxes/search).
|
||||
You can configure/download other Vagrant boxes from
|
||||
[https://app.vagrantup.com/boxes/search](https://app.vagrantup.com/boxes/search).
|
||||
|
||||
##### How can I connect to an existing database?
|
||||
|
||||
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.
|
||||
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 the `.env` in your
|
||||
project directory and point Nominatim to it.
|
||||
|
||||
NOMINATIM_DATABASE_DSN="pgsql:host=your-server.com;port=5432;user=postgres;dbname=nominatim_it
|
||||
|
||||
pgsql:host=your-server.com;port=5432;user=postgres;dbname=nominatim_it
|
||||
|
||||
No data import or restarting necessary.
|
||||
|
||||
If the Postgres installation is behind a firewall, you can try
|
||||
@@ -169,11 +176,12 @@ If the Postgres installation is behind a firewall, you can try
|
||||
ssh -L 9999:localhost:5432 your-username@your-server.com
|
||||
|
||||
inside the virtual machine. It will map the port to `localhost:9999` and then
|
||||
you edit `settings/local.php` with
|
||||
you edit `.env` file with
|
||||
|
||||
@define('CONST_Database_DSN', 'pgsql:host=localhost;port=9999;user=postgres;dbname=nominatim_it');
|
||||
NOMINATIM_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`
|
||||
To access postgres directly remember to specify the hostname,
|
||||
e.g. `psql --host localhost --port 9999 nominatim_it`
|
||||
|
||||
|
||||
##### My computer is slow and the import takes too long. Can I start the virtual machine "in the cloud"?
|
||||
|
||||
88
Vagrantfile
vendored
88
Vagrantfile
vendored
@@ -17,6 +17,14 @@ Vagrant.configure("2") do |config|
|
||||
checkout = "no"
|
||||
end
|
||||
|
||||
config.vm.provider "hyperv" do |hv, override|
|
||||
hv.memory = 2048
|
||||
hv.linked_clone = true
|
||||
if ENV['CHECKOUT'] != 'y' then
|
||||
override.vm.synced_folder ".", "/home/vagrant/Nominatim", type: "smb", smb_host: ENV['SMB_HOST'] || ENV['COMPUTERNAME']
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.provider "virtualbox" do |vb, override|
|
||||
vb.gui = false
|
||||
vb.memory = 2048
|
||||
@@ -34,7 +42,34 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu", primary: true do |sub|
|
||||
config.vm.define "ubuntu22", primary: true do |sub|
|
||||
sub.vm.box = "generic/ubuntu2204"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu22-apache" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2204"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-apache"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu22-nginx" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2204"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-22.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-nginx"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu20" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
@@ -43,7 +78,7 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu-apache" do |sub|
|
||||
config.vm.define "ubuntu20-apache" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
@@ -52,7 +87,7 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu-nginx" do |sub|
|
||||
config.vm.define "ubuntu20-nginx" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
@@ -60,51 +95,4 @@ Vagrant.configure("2") do |config|
|
||||
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
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu18-apache" do |sub|
|
||||
sub.vm.box = "generic/ubuntu1804"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-apache"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu18-nginx" do |sub|
|
||||
sub.vm.box = "generic/ubuntu1804"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-18.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-nginx"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "centos7" do |sub|
|
||||
sub.vm.box = "centos/7"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Centos-7.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "centos" do |sub|
|
||||
sub.vm.box = "generic/centos8"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Centos-8.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
15
cmake/paths-py.tmpl
Normal file
15
cmake/paths-py.tmpl
Normal file
@@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Path settings for extra data used by Nominatim (installed version).
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
PHPLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-php').resolve()
|
||||
SQLLIB_DIR = (Path('@NOMINATIM_LIBDIR@') / 'lib-sql').resolve()
|
||||
DATA_DIR = Path('@NOMINATIM_DATADIR@').resolve()
|
||||
CONFIG_DIR = Path('@NOMINATIM_CONFIGDIR@').resolve()
|
||||
@@ -4,14 +4,10 @@ import os
|
||||
|
||||
sys.path.insert(1, '@NOMINATIM_LIBDIR@/lib-python')
|
||||
|
||||
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||
|
||||
from nominatim import cli
|
||||
from nominatim import version
|
||||
|
||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||
|
||||
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@'))
|
||||
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql'))
|
||||
|
||||
@@ -4,14 +4,10 @@ import os
|
||||
|
||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
||||
|
||||
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
|
||||
|
||||
from nominatim import cli
|
||||
from nominatim import version
|
||||
|
||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||
|
||||
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@'))
|
||||
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql'))
|
||||
|
||||
14
codecov.yml
14
codecov.yml
@@ -1,14 +0,0 @@
|
||||
codecov:
|
||||
require_ci_to_pass: yes
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project: off
|
||||
patch: off
|
||||
|
||||
comment:
|
||||
require_changes: true
|
||||
after_n_builds: 2
|
||||
|
||||
fixes:
|
||||
- "Nominatim/::"
|
||||
File diff suppressed because one or more lines are too long
@@ -11,6 +11,7 @@ set (DOC_SOURCES
|
||||
develop
|
||||
api
|
||||
customize
|
||||
library
|
||||
index.md
|
||||
extra.css
|
||||
styles.css
|
||||
@@ -23,14 +24,12 @@ foreach (src ${DOC_SOURCES})
|
||||
endforeach()
|
||||
|
||||
ADD_CUSTOM_TARGET(doc
|
||||
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-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 PYTHONPATH=${PROJECT_SOURCE_DIR} mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-22.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-22.md
|
||||
COMMAND mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(serve-doc
|
||||
COMMAND PYTHONPATH=${PROJECT_SOURCE_DIR} mkdocs serve
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMAND mkdocs serve -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
@@ -36,16 +36,15 @@ which has the following structure:
|
||||
|
||||
```bash
|
||||
update
|
||||
├── europe
|
||||
│ ├── andorra
|
||||
│ │ └── sequence.state
|
||||
│ └── monaco
|
||||
│ └── sequence.state
|
||||
└── tmp
|
||||
└── europe
|
||||
├── andorra-latest.osm.pbf
|
||||
└── monaco-latest.osm.pbf
|
||||
|
||||
├── europe
|
||||
│ ├── andorra
|
||||
│ │ └── sequence.state
|
||||
│ └── monaco
|
||||
│ └── sequence.state
|
||||
└── tmp
|
||||
└── europe
|
||||
├── andorra-latest.osm.pbf
|
||||
└── monaco-latest.osm.pbf
|
||||
|
||||
```
|
||||
|
||||
@@ -99,7 +98,7 @@ Change into the project directory and run the following command:
|
||||
|
||||
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.
|
||||
script ([Geofabrik](https://download.geofabrik.de)) provides daily updates.
|
||||
|
||||
## Using an external PostgreSQL database
|
||||
|
||||
@@ -111,7 +110,7 @@ library.
|
||||
|
||||
!!! note
|
||||
The external module is only needed when using the legacy tokenizer.
|
||||
If you have choosen the ICU tokenizer, then you can ignore this section
|
||||
If you have chosen the ICU tokenizer, then you can ignore this section
|
||||
and follow the standard import documentation.
|
||||
|
||||
### Option 1: Compiling the library on the database server
|
||||
@@ -198,11 +197,10 @@ target machine.
|
||||
of a full database.
|
||||
|
||||
Next install Nominatim on the target machine by following the standard installation
|
||||
instructions. Again make sure to use the same version as the source machine.
|
||||
instructions. Again, make sure to use the same version as the source machine.
|
||||
|
||||
You can now copy the project directory from the source machine to the new machine.
|
||||
If necessary, edit the `.env` file to point it to the restored database.
|
||||
Finally run
|
||||
Create a project directory on your destination machine and set up the `.env`
|
||||
file to match the configuration on the source machine. Finally run
|
||||
|
||||
nominatim refresh --website
|
||||
|
||||
@@ -210,6 +208,8 @@ to make sure that the local installation of Nominatim will be used.
|
||||
|
||||
If you are using the legacy tokenizer you might also have to switch to the
|
||||
PostgreSQL module that was compiled on your target machine. If you get errors
|
||||
that PostgreSQL cannot find or access `nominatim.so` then copy the installed
|
||||
version into the `module` directory of your project directory. The installed
|
||||
copy can usually be found under `/usr/local/lib/nominatim/module/nominatim.so`.
|
||||
that PostgreSQL cannot find or access `nominatim.so` then rerun
|
||||
|
||||
nominatim refresh --functions
|
||||
|
||||
on the target machine to update the the location of the module.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Deploying Nominatim
|
||||
# Deploying Nominatim using the PHP frontend
|
||||
|
||||
The Nominatim API is implemented as a PHP application. The `website/` directory
|
||||
in the project directory contains the configured website. You can serve this
|
||||
@@ -8,13 +8,13 @@ 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
|
||||
[Apache](https://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
|
||||
Throughout this page, we assume your Nominatim project directory is
|
||||
located in `/srv/nominatim-project` and 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.
|
||||
@@ -82,7 +82,7 @@ The website should now be available on `http://localhost/nominatim`.
|
||||
|
||||
### Installing the required packages
|
||||
|
||||
Nginx has no built-in PHP interpreter. You need to use php-fpm as a deamon for
|
||||
Nginx has no built-in PHP interpreter. You need to use php-fpm as a daemon for
|
||||
serving PHP cgi.
|
||||
|
||||
On Ubuntu/Debian install nginx and php-fpm with:
|
||||
@@ -99,7 +99,7 @@ Unix socket instead, change the pool configuration
|
||||
|
||||
``` ini
|
||||
; Replace the tcp listener and add the unix socket
|
||||
listen = /var/run/php-fpm.sock
|
||||
listen = /var/run/php-fpm-nominatim.sock
|
||||
|
||||
; Ensure that the daemon runs as the correct user
|
||||
listen.owner = www-data
|
||||
@@ -121,7 +121,7 @@ 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_pass unix:/var/run/php-fpm-nominatim.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ location ~ [^/]\.php(/|$) {
|
||||
if (!-f $document_root$fastcgi_script_name) {
|
||||
return 404;
|
||||
}
|
||||
fastcgi_pass unix:/var/run/php-fpm.sock;
|
||||
fastcgi_pass unix:/var/run/php-fpm-nominatim.sock;
|
||||
fastcgi_index search.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
@@ -140,3 +140,9 @@ location ~ [^/]\.php(/|$) {
|
||||
Restart the nginx and php-fpm services and the website should now be available
|
||||
at `http://localhost/`.
|
||||
|
||||
## Nominatim with other webservers
|
||||
|
||||
Users have created instructions for other webservers:
|
||||
|
||||
* [Caddy](https://github.com/osm-search/Nominatim/discussions/2580)
|
||||
|
||||
140
docs/admin/Deployment-Python.md
Normal file
140
docs/admin/Deployment-Python.md
Normal file
@@ -0,0 +1,140 @@
|
||||
# Deploying the Nominatim Python frontend
|
||||
|
||||
The Nominatim can be run as a Python-based
|
||||
[ASGI web application](https://asgi.readthedocs.io/en/latest/). You have the
|
||||
choice between [Falcon](https://falcon.readthedocs.io/en/stable/)
|
||||
and [Starlette](https://www.starlette.io/) as the ASGI framework.
|
||||
|
||||
This section gives a quick overview on how to configure Nginx to serve
|
||||
Nominatim. Please refer to the documentation of
|
||||
[Nginx](https://nginx.org/en/docs/) for background information on how
|
||||
to configure it.
|
||||
|
||||
!!! Note
|
||||
Throughout this page, we assume your Nominatim project directory is
|
||||
located in `/srv/nominatim-project` and 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.
|
||||
|
||||
### Installing the required packages
|
||||
|
||||
The recommended way to deploy a Python ASGI application is to run
|
||||
the ASGI runner [uvicorn](https://uvicorn.org/)
|
||||
together with [gunicorn](https://gunicorn.org/) HTTP server. We use
|
||||
Falcon here as the web framework.
|
||||
|
||||
Create a virtual environment for the Python packages and install the necessary
|
||||
dependencies:
|
||||
|
||||
``` sh
|
||||
sudo apt install virtualenv
|
||||
virtualenv /srv/nominatim-venv
|
||||
/srv/nominatim-venv/bin/pip install SQLAlchemy PyICU psycopg[binary] \
|
||||
psycopg2-binary python-dotenv PyYAML falcon uvicorn gunicorn
|
||||
```
|
||||
|
||||
### Setting up Nominatim as a systemd job
|
||||
|
||||
Next you need to set up the service that runs the Nominatim frontend. This is
|
||||
easiest done with a systemd job.
|
||||
|
||||
First you need to tell systemd to create a socket file to be used by
|
||||
hunicorn. Crate the following file `/etc/systemd/system/nominatim.socket`:
|
||||
|
||||
``` systemd
|
||||
[Unit]
|
||||
Description=Gunicorn socket for Nominatim
|
||||
|
||||
[Socket]
|
||||
ListenStream=/run/nominatim.sock
|
||||
SocketUser=www-data
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Now you can add the systemd service for Nominatim itself.
|
||||
Create the following file `/etc/systemd/system/nominatim.service`:
|
||||
|
||||
``` systemd
|
||||
[Unit]
|
||||
Description=Nominatim running as a gunicorn application
|
||||
After=network.target
|
||||
Requires=nominatim.socket
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="PYTHONPATH=/usr/local/lib/nominatim/lib-python/"
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/srv/nominatim-project
|
||||
ExecStart=/srv/nominatim-venv/bin/gunicorn -b unix:/run/nominatim.sock -w 4 -k uvicorn.workers.UvicornWorker nominatim.server.falcon.server:run_wsgi
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
StandardOutput=append:/var/log/gunicorn-nominatim.log
|
||||
StandardError=inherit
|
||||
PrivateTmp=true
|
||||
TimeoutStopSec=5
|
||||
KillMode=mixed
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
This sets up gunicorn with 4 workers (`-w 4` in ExecStart). Each worker runs
|
||||
its own Python process using
|
||||
[`NOMINATIM_API_POOL_SIZE`](../customize/Settings.md#nominatim_api_pool_size)
|
||||
connections to the database to serve requests in parallel.
|
||||
|
||||
Make the new services known to systemd and start it:
|
||||
|
||||
``` sh
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable nominatim.socket
|
||||
sudo systemctl start nominatim.socket
|
||||
sudo systemctl enable nominatim.service
|
||||
sudo systemctl start nominatim.service
|
||||
```
|
||||
|
||||
This sets the service up, so that Nominatim is automatically started
|
||||
on reboot.
|
||||
|
||||
### Configuring nginx
|
||||
|
||||
To make the service available to the world, you need to proxy it through
|
||||
nginx. Add the following definition to the default configuration:
|
||||
|
||||
``` nginx
|
||||
upstream nominatim_service {
|
||||
server unix:/run/nominatim.sock fail_timeout=0;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
root /var/www/html;
|
||||
index /search;
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_redirect off;
|
||||
proxy_pass http://nominatim_service;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reload nginx with
|
||||
|
||||
```
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
and you should be able to see the status of your server under
|
||||
`http://localhost/status`.
|
||||
@@ -79,7 +79,7 @@ When running the import you may get a version mismatch:
|
||||
|
||||
pg_config seems to use bad includes sometimes when multiple versions
|
||||
of PostgreSQL are available in the system. Make sure you remove the
|
||||
server development libraries (`postgresql-server-dev-9.5` on Ubuntu)
|
||||
server development libraries (`postgresql-server-dev-13` on Ubuntu)
|
||||
and recompile (`cmake .. && make`).
|
||||
|
||||
|
||||
@@ -106,11 +106,6 @@ 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)
|
||||
@@ -126,22 +121,6 @@ The server cannot access your database. Add `&debug=1` to your URL
|
||||
to get the full error message.
|
||||
|
||||
|
||||
### On CentOS the website shows "Could not connect to server"
|
||||
|
||||
`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.md#adding-selinux-security-settings).
|
||||
|
||||
However, you can solve this the quick and dirty way by commenting out that line and then run
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart httpd
|
||||
|
||||
|
||||
### Website reports "DB Error: insufficient permissions"
|
||||
|
||||
The user the webserver, e.g. Apache, runs under needs to have access to the
|
||||
@@ -181,9 +160,6 @@ by everybody, e.g.
|
||||
|
||||
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.md#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
|
||||
|
||||
@@ -74,15 +74,15 @@ 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
|
||||
wget https://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.
|
||||
If you forgot to download the wikipedia rankings, then you can
|
||||
also add importances after the import. Download the SQL files, then
|
||||
run `nominatim refresh --wiki-data --importance`. Updating
|
||||
importances for a planet will take a couple of hours.
|
||||
|
||||
### External postcodes
|
||||
|
||||
@@ -92,8 +92,8 @@ and the UK (using the [CodePoint OpenData set](https://osdatahub.os.uk/downloads
|
||||
This data can be optionally downloaded into the project directory:
|
||||
|
||||
cd $PROJECT_DIR
|
||||
wget https://www.nominatim.org/data/gb_postcodes.csv.gz
|
||||
wget https://www.nominatim.org/data/us_postcodes.csv.gz
|
||||
wget https://nominatim.org/data/gb_postcodes.csv.gz
|
||||
wget https://nominatim.org/data/us_postcodes.csv.gz
|
||||
|
||||
You can also add your own custom postcode sources, see
|
||||
[Customization of postcodes](../customize/Postcodes.md).
|
||||
@@ -139,7 +139,7 @@ import. So this option is particularly interesting if you plan to transfer the
|
||||
database or reuse the space later.
|
||||
|
||||
!!! warning
|
||||
The datastructure for updates are also required when adding additional data
|
||||
The data structure for updates are also required when adding additional data
|
||||
after the import, for example [TIGER housenumber data](../customize/Tiger.md).
|
||||
If you plan to use those, you must not use the `--no-updates` parameter.
|
||||
Do a normal import, add the external data and once you are done with
|
||||
@@ -150,7 +150,7 @@ database or reuse the space later.
|
||||
|
||||
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
|
||||
[photon](https://photon.komoot.io/) 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.
|
||||
@@ -254,26 +254,70 @@ successfully.
|
||||
nominatim admin --check-database
|
||||
```
|
||||
|
||||
Now you can try out your installation by running:
|
||||
Now you can try out your installation by executing a simple query on the
|
||||
command line:
|
||||
|
||||
``` sh
|
||||
nominatim search --query Berlin
|
||||
```
|
||||
|
||||
or, when you have a reverse-only installation:
|
||||
|
||||
``` sh
|
||||
nominatim reverse --lat 51 --lon 45
|
||||
```
|
||||
|
||||
If you want to run Nominatim as a service, you need to make a choice between
|
||||
running the traditional PHP frontend or the new experimental Python frontend.
|
||||
Make sure you have installed the right packages as per
|
||||
[Installation](Installation.md#software).
|
||||
|
||||
#### Testing the PHP frontend
|
||||
|
||||
You can run a small test server with the PHP frontend like this:
|
||||
|
||||
```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`.
|
||||
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`
|
||||
or, for reverse-only installations a reverse query,
|
||||
e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
||||
|
||||
Note that search query is not supported for reverse-only imports. You can run a
|
||||
reverse query, e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
||||
Do not use this test server in production.
|
||||
To run Nominatim via webservers like Apache or nginx, please continue reading
|
||||
[Deploy the PHP frontend](Deployment-PHP.md).
|
||||
|
||||
To run Nominatim via webservers like Apache or nginx, please read the
|
||||
[Deployment chapter](Deployment.md).
|
||||
#### Testing the Python frontend
|
||||
|
||||
## Adding search through category phrases
|
||||
To run the test server against the Python frontend, you must choose a
|
||||
web framework to use, either starlette or falcon. Make sure the appropriate
|
||||
packages are installed. Then run
|
||||
|
||||
If you want to be able to search for places by their type through
|
||||
``` sh
|
||||
nominatim serve --engine falcon
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
``` sh
|
||||
nominatim serve --engine starlette
|
||||
```
|
||||
|
||||
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`
|
||||
or, for reverse-only installations a reverse query,
|
||||
e.g. `http://localhost:8088/reverse.php?lat=27.1750090510034&lon=78.04209025`.
|
||||
|
||||
Do not use this test server in production.
|
||||
To run Nominatim via webservers like Apache or nginx, please continue reading
|
||||
[Deploy the Python frontend](Deployment-Python.md).
|
||||
|
||||
|
||||
## Enabling search by category phrases
|
||||
|
||||
To be able to search for places by their type using
|
||||
[special phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases)
|
||||
you also need to import these key phrases like this:
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ 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 22.04](../appendix/Install-on-Ubuntu-22.md)
|
||||
* [Ubuntu 20.04](../appendix/Install-on-Ubuntu-20.md)
|
||||
* [Ubuntu 18.04](../appendix/Install-on-Ubuntu-18.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
|
||||
in the `vagrant/` directory.
|
||||
@@ -25,8 +23,9 @@ and can't offer support.
|
||||
### Software
|
||||
|
||||
!!! Warning
|
||||
For larger installations you **must have** PostgreSQL 11+ and Postgis 3+
|
||||
For larger installations you **must have** PostgreSQL 11+ and PostGIS 3+
|
||||
otherwise import and queries will be slow to the point of being unusable.
|
||||
Query performance has marked improvements with PostgreSQL 13+ and PostGIS 3.2+.
|
||||
|
||||
For compiling:
|
||||
|
||||
@@ -36,46 +35,58 @@ For compiling:
|
||||
* [bzip2](http://www.bzip.org/)
|
||||
* [zlib](https://www.zlib.net/)
|
||||
* [ICU](http://site.icu-project.org/)
|
||||
* [nlohmann/json](https://json.nlohmann.me/)
|
||||
* [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](https://www.postgresql.org) (9.5+ will work, 11+ strongly recommended)
|
||||
* [PostgreSQL](https://www.postgresql.org) (9.6+ will work, 11+ strongly recommended)
|
||||
* [PostGIS](https://postgis.net) (2.2+ will work, 3.0+ strongly recommended)
|
||||
* [Python 3](https://www.python.org/) (3.6+)
|
||||
* [Python 3](https://www.python.org/) (3.7+)
|
||||
* [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/)
|
||||
* [SQLAlchemy](https://www.sqlalchemy.org/) (1.4.31+ with greenlet support)
|
||||
* [asyncpg](https://magicstack.github.io/asyncpg) (0.8+)
|
||||
* [PyICU](https://pypi.org/project/PyICU/)
|
||||
* [PyYaml](https://pyyaml.org/) (5.1+)
|
||||
* [datrie](https://github.com/pytries/datrie)
|
||||
* [PHP](https://php.net) (7.0 or later)
|
||||
|
||||
When running the PHP frontend:
|
||||
|
||||
* [PHP](https://php.net) (7.3+)
|
||||
* PHP-pgsql
|
||||
* PHP-intl (bundled with PHP)
|
||||
* PHP-cgi (for running queries from the command line)
|
||||
|
||||
For running continuous updates:
|
||||
|
||||
* [pyosmium](https://osmcode.org/pyosmium/)
|
||||
|
||||
For running the experimental Python frontend:
|
||||
|
||||
* one of the following web frameworks:
|
||||
* [falcon](https://falconframework.org/) (3.0+)
|
||||
* [starlette](https://www.starlette.io/)
|
||||
* [uvicorn](https://www.uvicorn.org/)
|
||||
|
||||
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 64GB of RAM or more are strongly recommended. Do not report
|
||||
planet import 128GB 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 900GB of hard disk space.
|
||||
For a full planet install you will need at least 1TB of hard disk space.
|
||||
Take into account that the OSM database is growing fast.
|
||||
Fast disks are essential. Using NVME disks is recommended.
|
||||
|
||||
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.
|
||||
around 2 days. When using traditional SSDs, 4-5 days are more realistic.
|
||||
|
||||
## Tuning the PostgreSQL database
|
||||
|
||||
@@ -89,8 +100,7 @@ your `postgresql.conf` file.
|
||||
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
|
||||
max_wal_size = 1GB
|
||||
checkpoint_timeout = 10min
|
||||
checkpoint_completion_target = 0.9
|
||||
|
||||
@@ -108,15 +118,6 @@ you might consider setting:
|
||||
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:
|
||||
|
||||
fsync = off
|
||||
full_page_writes = off
|
||||
|
||||
Don't forget to reenable them after the initial import or you risk database
|
||||
corruption.
|
||||
|
||||
|
||||
## Downloading and building Nominatim
|
||||
|
||||
### Downloading the latest release
|
||||
@@ -130,13 +131,13 @@ 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
|
||||
git clone --recursive https://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
|
||||
wget -O Nominatim/data/country_osm_grid.sql.gz https://nominatim.org/data/country_grid.sql.gz
|
||||
```
|
||||
|
||||
### Building Nominatim
|
||||
@@ -158,6 +159,17 @@ make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
!!! warning
|
||||
The default installation no longer compiles the PostgreSQL module that
|
||||
is needed for the legacy tokenizer from older Nominatim versions. If you
|
||||
are upgrading an older database or want to run the
|
||||
[legacy tokenizer](../customize/Tokenizers.md#legacy-tokenizer) for
|
||||
some other reason, you need to enable the PostgreSQL module via
|
||||
cmake: `cmake -DBUILD_MODULE=on ../Nominatim`. To compile the module
|
||||
you need to have the server development headers for PostgreSQL installed.
|
||||
On Ubuntu/Debian run: `sudo apt install postgresql-server-dev-<postgresql version>`
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -34,6 +34,30 @@ to rerun the statistics computation when adding larger amounts of new data,
|
||||
for example, when adding an additional country via `nominatim add-data`.
|
||||
|
||||
|
||||
## Forcing recomputation of places and areas
|
||||
|
||||
Command: `nominatim refresh --data-object [NWR]<id> --data-area [NWR]<id>`
|
||||
|
||||
When running replication updates, Nominatim tries to recompute the search
|
||||
and address information for all places that are affected by a change. But it
|
||||
needs to restrict the total number of changes to make sure it can keep up
|
||||
with the minutely updates. Therefore it will refrain from propagating changes
|
||||
that affect a lot of objects.
|
||||
|
||||
The administrator may force an update of places in the database.
|
||||
`nominatim refresh --data-object` invalidates a single OSM object.
|
||||
`nominatim refresh --data-area` invalidates an OSM object and all dependent
|
||||
objects. That are usually the places that inside its area or around the
|
||||
center of the object. Both commands expect the OSM object as an argument
|
||||
of the form OSM type + OSM id. The type must be `N` (node), `W` (way) or
|
||||
`R` (relation).
|
||||
|
||||
After invalidating the object, indexing must be run again. If continuous
|
||||
update are running in the background, the objects will be recomputed together
|
||||
with the next round of updates. Otherwise you need to run `nominatim index`
|
||||
to finish the recomputation.
|
||||
|
||||
|
||||
## Removing large deleted objects
|
||||
|
||||
Nominatim refuses to delete very large areas because often these deletions are
|
||||
|
||||
@@ -15,6 +15,42 @@ breaking changes. **Please read them before running the migration.**
|
||||
If you are migrating from a version <3.6, then you still have to follow
|
||||
the manual migration steps up to 3.6.
|
||||
|
||||
## 4.2.0 -> 4.3.0
|
||||
|
||||
### New indexes for reverse lookup
|
||||
|
||||
The reverse lookup algorithm has changed slightly to improve performance.
|
||||
This change needs a different index in the database. The required index
|
||||
will be automatically build during migration. Until the new index is available
|
||||
performance of the /reverse endpoint is significantly reduced. You should
|
||||
therefore either remove traffic from the machine before attempting a
|
||||
version update or create the index manually **before** starting the update
|
||||
using the following SQL:
|
||||
|
||||
```sql
|
||||
CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPlaceNode
|
||||
ON placex USING gist (ST_Buffer(geometry, reverse_place_diameter(rank_search)))
|
||||
WHERE rank_address between 4 and 25 AND type != 'postcode'
|
||||
AND name is not null AND linked_place_id is null AND osm_type = 'N';
|
||||
```
|
||||
|
||||
## 4.0.0 -> 4.1.0
|
||||
|
||||
### ICU tokenizer is the new default
|
||||
|
||||
Nominatim now installs the [ICU tokenizer](../customize/Tokenizers.md#icu-tokenizer)
|
||||
by default. This only has an effect on newly installed databases. When
|
||||
updating older databases, it keeps its installed tokenizer. If you still
|
||||
run with the legacy tokenizer, make sure to compile Nominatim with the
|
||||
PostgreSQL module, see [Installation](Installation.md#building-nominatim).
|
||||
|
||||
### geocodejson output changed
|
||||
|
||||
The `type` field of the geocodejson output has changed. It now contains
|
||||
the address class of the object instead of the value of the OSM tag. If
|
||||
your client has used the `type` field, switch them to read `osm_value`
|
||||
instead.
|
||||
|
||||
## 3.7.0 -> 4.0.0
|
||||
|
||||
### NOMINATIM_PHRASE_CONFIG removed
|
||||
|
||||
@@ -16,12 +16,12 @@ and run it. Grab the latest release from
|
||||
[nominatim-ui's Github release page](https://github.com/osm-search/nominatim-ui/releases)
|
||||
and unpack it. You can use `nominatim-ui-x.x.x.tar.gz` or `nominatim-ui-x.x.x.zip`.
|
||||
|
||||
Next you need to adapt the UI yo your installation. Custom settings need to be
|
||||
Next you need to adapt the UI to your installation. Custom settings need to be
|
||||
put into `dist/theme/config.theme.js`. At a minimum you need to
|
||||
set `Nominatim_API_Endpoint` to point to your Nominatim installation:
|
||||
|
||||
cd nominatim-ui
|
||||
echo "Nominatim_Config.Nominatim_API_Endpoint='https:\\myserver.org\nominatim';" > dist/theme/config.theme.js
|
||||
echo "Nominatim_Config.Nominatim_API_Endpoint='https://myserver.org/nominatim/';" > dist/theme/config.theme.js
|
||||
|
||||
For the full set of available settings, have a look at `dist/config.defaults.js`.
|
||||
|
||||
@@ -161,24 +161,16 @@ directory like this:
|
||||
# If no endpoint is given, then use search.
|
||||
RewriteRule ^(/|$) "search.php"
|
||||
|
||||
# If format-html is explicity requested, forward to the UI.
|
||||
# If format-html is explicitly 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]
|
||||
RewriteRule ^([^/]+)(.php)? 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]
|
||||
RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END]
|
||||
</Directory>
|
||||
```
|
||||
|
||||
|
||||
@@ -59,8 +59,137 @@ 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.
|
||||
|
||||
#### One-time mode
|
||||
|
||||
When the `--once` parameter is given, then Nominatim will download exactly one
|
||||
batch of updates and then exit. This one-time mode still respects the
|
||||
`NOMINATIM_REPLICATION_UPDATE_INTERVAL` that you have set. If according to
|
||||
the update interval no new data has been published yet, it will go to sleep
|
||||
until the next expected update and only then attempt to download the next batch.
|
||||
|
||||
The one-time mode is particularly useful if you want to run updates continuously
|
||||
but need to schedule other work in between updates. For example, the main
|
||||
service at osm.org uses it, to regularly recompute postcodes -- a process that
|
||||
must not be run while updates are in progress. Its update script
|
||||
looks like this:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
# Switch to your project directory.
|
||||
cd /srv/nominatim
|
||||
|
||||
while true; do
|
||||
nominatim replication --once
|
||||
if [ -f "/srv/nominatim/schedule-maintenance" ]; then
|
||||
rm /srv/nominatim/schedule-maintenance
|
||||
nominatim refresh --postcodes
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
A cron job then creates the file `/srv/nominatim/schedule-maintenance` once per night.
|
||||
|
||||
##### One-time mode with systemd
|
||||
|
||||
You can run the one-time mode with a systemd timer & service.
|
||||
|
||||
Create a timer description like `/etc/systemd/system/nominatim-updates.timer`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=Timer to start updates of Nominatim
|
||||
|
||||
[Timer]
|
||||
OnActiveSec=2
|
||||
OnUnitActiveSec=1min
|
||||
Unit=nominatim-updates.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
And then a similar service definition: `/etc/systemd/system/nominatim-updates.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=Single updates of Nominatim
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/srv/nominatim
|
||||
ExecStart=nominatim replication --once
|
||||
StandardOutput=append:/var/log/nominatim-updates.log
|
||||
StandardError=append:/var/log/nominatim-updates.error.log
|
||||
User=nominatim
|
||||
Group=nominatim
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Replace the `WorkingDirectory` with your project directory. Also adapt user and
|
||||
group names as required. `OnUnitActiveSec` defines how often the individual
|
||||
update command is run.
|
||||
|
||||
Now activate the service and start the updates:
|
||||
|
||||
```
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable nominatim-updates.timer
|
||||
sudo systemctl start nominatim-updates.timer
|
||||
```
|
||||
|
||||
You can stop future data updates, while allowing any current, in-progress
|
||||
update steps to finish, by running `sudo systemctl stop
|
||||
nominatim-updates.timer` and waiting until `nominatim-updates.service` isn't
|
||||
running (`sudo systemctl is-active nominatim-updates.service`). Current output
|
||||
from the update can be seen like above (`systemctl status
|
||||
nominatim-updates.service`).
|
||||
|
||||
|
||||
#### Catch-up mode
|
||||
|
||||
With the `--catch-up` parameter, Nominatim will immediately try to download
|
||||
all changes from the server until the database is up-to-date. The catch-up mode
|
||||
still respects the parameter `NOMINATIM_REPLICATION_MAX_DIFF`. It downloads and
|
||||
applies the changes in appropriate batches until all is done.
|
||||
|
||||
The catch-up mode is foremost useful to bring the database up to speed after the
|
||||
initial import. Give that the service usually is not in production at this
|
||||
point, you can temporarily be a bit more generous with the batch size and
|
||||
number of threads you use for the updates by running catch-up like this:
|
||||
|
||||
```
|
||||
cd /srv/nominatim
|
||||
NOMINATIM_REPLICATION_MAX_DIFF=5000 nominatim replication --catch-up --threads 15
|
||||
```
|
||||
|
||||
The catch-up mode is also useful when you want to apply updates at a lower
|
||||
frequency than what the source publishes. You can set up a cron job to run
|
||||
replication catch-up at whatever interval you desire.
|
||||
|
||||
!!! hint
|
||||
When running scheduled updates with catch-up, it is a good idea to choose
|
||||
a replication source with an update frequency that is an order of magnitude
|
||||
lower. For example, if you want to update once a day, use an hourly updated
|
||||
source. This makes sure that you don't miss an entire day of updates when
|
||||
the source is unexpectedly late to publish its update.
|
||||
|
||||
If you want to use the source with the same update frequency (e.g. a daily
|
||||
updated source with daily updates), use the
|
||||
continuous update mode. It ensures to re-request the newest update until it
|
||||
is published.
|
||||
|
||||
|
||||
#### Continuous updates
|
||||
|
||||
!!! danger
|
||||
This mode is no longer recommended to use and will removed in future
|
||||
releases. systemd is much better
|
||||
suited for running regular updates. Please refer to the setup
|
||||
instructions for running one-time mode with systemd above.
|
||||
|
||||
This is the easiest mode. Simply run the replication command without any
|
||||
parameters:
|
||||
|
||||
@@ -70,7 +199,7 @@ The update application keeps running forever and retrieves and applies
|
||||
new updates from the server as they are published.
|
||||
|
||||
You can run this command as a simple systemd service. Create a service
|
||||
description like that in `/etc/systemd/system/nominatim-update.service`:
|
||||
description like that in `/etc/systemd/system/nominatim-updates.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
@@ -100,67 +229,4 @@ sudo systemctl enable nominatim-updates
|
||||
sudo systemctl start nominatim-updates
|
||||
```
|
||||
|
||||
#### One-time mode
|
||||
|
||||
When the `--once` parameter is given, then Nominatim will download exactly one
|
||||
batch of updates and then exit. This one-time mode still respects the
|
||||
`NOMINATIM_REPLICATION_UPDATE_INTERVAL` that you have set. If according to
|
||||
the update interval no new data has been published yet, it will go to sleep
|
||||
until the next expected update and only then attempt to download the next batch.
|
||||
|
||||
The one-time mode is particularly useful if you want to run updates continuously
|
||||
but need to schedule other work in between updates. For example, the main
|
||||
service at osm.org uses it, to regularly recompute postcodes -- a process that
|
||||
must not be run while updates are in progress. Its update script
|
||||
looks like this:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
# Switch to your project directory.
|
||||
cd /srv/nominatim
|
||||
|
||||
while true; do
|
||||
nominatim replication --once
|
||||
if [ -f "/srv/nominatim/schedule-mainenance" ]; then
|
||||
rm /srv/nominatim/schedule-mainenance
|
||||
nominatim refresh --postcodes
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
A cron job then creates the file `/srv/nominatim/need-mainenance` once per night.
|
||||
|
||||
|
||||
#### Catch-up mode
|
||||
|
||||
With the `--catch-up` parameter, Nominatim will immediately try to download
|
||||
all changes from the server until the database is up-to-date. The catch-up mode
|
||||
still respects the parameter `NOMINATIM_REPLICATION_MAX_DIFF`. It downloads and
|
||||
applies the changes in appropriate batches until all is done.
|
||||
|
||||
The catch-up mode is foremost useful to bring the database up to speed after the
|
||||
initial import. Give that the service usually is not in production at this
|
||||
point, you can temporarily be a bit more generous with the batch size and
|
||||
number of threads you use for the updates by running catch-up like this:
|
||||
|
||||
```
|
||||
cd /srv/nominatim
|
||||
NOMINATIM_REPLICATION_MAX_DIFF=5000 nominatim replication --catch-up --threads 15
|
||||
```
|
||||
|
||||
The catch-up mode is also useful when you want to apply updates at a lower
|
||||
frequency than what the source publishes. You can set up a cron job to run
|
||||
replication catch-up at whatever interval you desire.
|
||||
|
||||
!!! hint
|
||||
When running scheduled updates with catch-up, it is a good idea to choose
|
||||
a replication source with an update frequency that is an order of magnitude
|
||||
lower. For example, if you want to update once a day, use an hourly updated
|
||||
source. This makes sure that you don't miss an entire day of updates when
|
||||
the source is unexpectely late to publish its update.
|
||||
|
||||
If you want to use the source with the same update frequency (e.g. a daily
|
||||
updated source with daily updates), use the
|
||||
continuous update mode. It ensures to re-request the newest update until it
|
||||
is published.
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
|
||||
Show all details about a single place saved in the database.
|
||||
|
||||
This API endpoint is meant for visual inspection of the data in the database,
|
||||
mainly together with [Nominatim-UI](https://github.com/osm-search/nominatim-ui/).
|
||||
The parameters of the endpoint and the output may change occasionally between
|
||||
versions of Nominatim. Do not rely on the output in scripts or applications.
|
||||
|
||||
!!! warning
|
||||
The details page exists for debugging only. You may not use it in scripts
|
||||
or to automatically query details about a result.
|
||||
The details endpoint at https://nominatim.openstreetmap.org
|
||||
may not used in scripts or bots at all.
|
||||
See [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/).
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
The details API supports the following two request formats:
|
||||
|
||||
@@ -35,59 +39,90 @@ 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.
|
||||
|
||||
!!! danger "Deprecation warning"
|
||||
The API can also be used with the URL
|
||||
`https://nominatim.openstreetmap.org/details.php`. This is now deprecated
|
||||
and will be removed in future versions.
|
||||
|
||||
Additional optional parameters are explained below.
|
||||
|
||||
## Parameters
|
||||
|
||||
This section lists additional optional parameters.
|
||||
|
||||
### Output format
|
||||
|
||||
* `json_callback=<string>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| json_callback | function name | _unset_ |
|
||||
|
||||
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
When set, then JSON output will be wrapped in a callback function with
|
||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
||||
information.
|
||||
|
||||
* `pretty=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| pretty | 0 or 1 | 0 |
|
||||
|
||||
Add indentation to make it more human-readable. (Default: 0)
|
||||
`[PHP-only]` Add indentation to the output to make it more human-readable.
|
||||
|
||||
|
||||
### Output details
|
||||
|
||||
* `addressdetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| addressdetails | 0 or 1 | 0 |
|
||||
|
||||
Include a breakdown of the address into elements. (Default: 0)
|
||||
When set to 1, include a breakdown of the address into elements.
|
||||
|
||||
* `keywords=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| keywords | 0 or 1 | 0 |
|
||||
|
||||
Include a list of name keywords and address keywords (word ids). (Default: 0)
|
||||
When set to 1, include a list of name keywords and address keywords
|
||||
in the result.
|
||||
|
||||
* `linkedplaces=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| linkedplaces | 0 or 1 | 1 |
|
||||
|
||||
Include a details of places that are linked with this one. Places get linked
|
||||
Include 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]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| hierarchy | 0 or 1 | 0 |
|
||||
|
||||
Include details of places lower in the address hierarchy. (Default: 0)
|
||||
Include details of places lower in the address hierarchy.
|
||||
|
||||
* `group_hierarchy=[0|1]`
|
||||
`[Python-only]` will only return properly parented places. These are address
|
||||
or POI-like places that reuse the address of their parent street or place.
|
||||
|
||||
For JSON output will group the places by type. (Default: 0)
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| group_hierarchy | 0 or 1 | 0 |
|
||||
|
||||
* `polygon_geojson=[0|1]`
|
||||
When set to 1, the output of the address hierarchy will be
|
||||
grouped by type.
|
||||
|
||||
Include geometry of result. (Default: 0)
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_geojson | 0 or 1 | 0 |
|
||||
|
||||
|
||||
Include geometry of result.
|
||||
|
||||
### Language of results
|
||||
|
||||
* `accept-language=<browser language string>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
||||
|
||||
Preferred language order for showing result, overrides the value
|
||||
specified in the "Accept-Language" HTTP header.
|
||||
Either use a standard RFC2616 accept-language string or a simple
|
||||
comma-separated list of language codes.
|
||||
Preferred language order for showing search results. This may either be
|
||||
a simple comma-separated list of language codes or have the same format
|
||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -59,3 +59,27 @@ 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.
|
||||
|
||||
#### 7. My result has a wrong postcode. Where does it come from?
|
||||
|
||||
Most places in OSM don't have a postcode, so Nominatim tries to interpolate
|
||||
one. It first look at all the places that make up the address of the place.
|
||||
If one of them has a postcode defined, this is the one to be used. When
|
||||
none of the address parts has a postcode either, Nominatim interpolates one
|
||||
from the surrounding objects. If the postcode is for your result is one, then
|
||||
most of the time there is an OSM object with the wrong postcode nearby.
|
||||
|
||||
To find the bad postcode, go to
|
||||
[https://nominatim.openstreetmap.org](https://nominatim.openstreetmap.org)
|
||||
and search for your place. When you have found it, click on the 'details' link
|
||||
under the result to go to the details page. There is a field 'Computed Postcode'
|
||||
which should display the bad postcode. Click on the 'how?' link. A small
|
||||
explanation text appears. It contains a link to a query for Overpass Turbo.
|
||||
Click on that and you get a map with all places in the area that have the bad
|
||||
postcode. If none is displayed, zoom the map out a bit and then click on 'Run'.
|
||||
|
||||
Now go to [OpenStreetMap](https://openstreetmap.org) and fix the error you
|
||||
have just found. It will take at least a day for Nominatim to catch up with
|
||||
your data fix. Sometimes longer, depending on how much editing activity is in
|
||||
the area.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
The lookup API allows to query the address and other details of one or
|
||||
multiple OSM objects like node, way or relation.
|
||||
|
||||
## Parameters
|
||||
## Endpoint
|
||||
|
||||
The lookup API has the following format:
|
||||
|
||||
@@ -15,86 +15,140 @@ The lookup API has the following format:
|
||||
prefixed with its type, one of node(N), way(W) or relation(R). Up to 50 ids
|
||||
can be queried at the same time.
|
||||
|
||||
Additional optional parameters are explained below.
|
||||
!!! danger "Deprecation warning"
|
||||
The API can also be used with the URL
|
||||
`https://nominatim.openstreetmap.org/lookup.php`. This is now deprecated
|
||||
and will be removed in future versions.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
This section lists additional optional parameters.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `jsonv2` |
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||
See [Place Output Formats](Output.md) for details on each format.
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap JSON output in a callback function (JSONP) i.e. `<string>(<json>)`.
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| json_callback | function name | _unset_ |
|
||||
|
||||
When given, then JSON output will be wrapped in a callback function with
|
||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
||||
information.
|
||||
|
||||
Only has an effect for JSON output formats.
|
||||
|
||||
|
||||
### Output details
|
||||
|
||||
* `addressdetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| addressdetails | 0 or 1 | 0 |
|
||||
|
||||
Include a breakdown of the address into elements. (Default: 0)
|
||||
When set to 1, include a breakdown of the address into elements.
|
||||
The exact content of the address breakdown depends on the output format.
|
||||
|
||||
!!! tip
|
||||
If you are interested in a stable classification of address categories
|
||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
||||
All other formats return classifications according to OSM tagging.
|
||||
There is a much larger set of categories and they are not always consistent,
|
||||
which makes them very hard to work with.
|
||||
|
||||
|
||||
* `extratags=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| extratags | 0 or 1 | 0 |
|
||||
|
||||
Include additional information in the result if available,
|
||||
e.g. wikipedia link, opening hours. (Default: 0)
|
||||
When set to 1, the response include any additional information in the result
|
||||
that is available in the database, e.g. wikipedia link, opening hours.
|
||||
|
||||
|
||||
* `namedetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| namedetails | 0 or 1 | 0 |
|
||||
|
||||
Include a list of alternative names in the results. These may include
|
||||
language variants, references, operator and brand. (Default: 0)
|
||||
When set to 1, include a full list of names for the result. These may include
|
||||
language variants, older names, references and brand.
|
||||
|
||||
|
||||
### Language of results
|
||||
|
||||
* `accept-language=<browser language string>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
||||
|
||||
Preferred language order for showing search results. This may either be
|
||||
a simple comma-separated list of language codes or have the same format
|
||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||
|
||||
!!! tip
|
||||
First-time users of Nominatim tend to be confused that they get different
|
||||
results when using Nominatim in the browser versus in a command-line tool
|
||||
like wget or curl. The command-line tools
|
||||
usually don't send any Accept-Language header, prompting Nominatim
|
||||
to show results in the local language. Browsers on the contratry always
|
||||
send the currently chosen browser language.
|
||||
|
||||
Preferred language order for showing search results, overrides the value
|
||||
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`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_geojson | 0 or 1 | 0 |
|
||||
| polygon_kml | 0 or 1 | 0 |
|
||||
| polygon_svg | 0 or 1 | 0 |
|
||||
| polygon_text | 0 or 1 | 0 |
|
||||
|
||||
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||
options can be used at a time. (Default: 0)
|
||||
Add the full geometry of the place to the result output. Output formats
|
||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
||||
options can be used at a time.
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_threshold | floating-point number | 0.0 |
|
||||
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
When one of the polygon_* outputs is chosen, return a simplified version
|
||||
of the output geometry. The parameter describes the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
geometry. Topology is preserved in the geometry.
|
||||
|
||||
|
||||
### Other
|
||||
|
||||
* `email=<valid email address>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| email | valid email address | _unset_ |
|
||||
|
||||
If you are making large numbers of request please include an appropriate email
|
||||
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
address to identify your requests. See Nominatim's
|
||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
|
||||
* `debug=[0|1]`
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| debug | 0 or 1 | 0 |
|
||||
|
||||
Output assorted developer debug information. Data on internals of Nominatim's
|
||||
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||
This overrides the specified machine readable format. (Default: 0)
|
||||
"search loop" logic, and SQL queries. The output is HTML format.
|
||||
This overrides the specified machine readable format.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
##### XML
|
||||
|
||||
[https://nominatim.openstreetmap.org/lookup?osm_ids=R146656,W104393803,N240109189](https://nominatim.openstreetmap.org/lookup?osm_ids=R146656,W104393803,N240109189)
|
||||
[https://nominatim.openstreetmap.org/lookup?osm_ids=R146656,W104393803,N240109189](https://nominatim.openstreetmap.org/lookup?osm_ids=R146656,W50637691,N240109189)
|
||||
|
||||
```xml
|
||||
<lookupresults timestamp="Mon, 29 Jun 15 18:01:33 +0000" attribution="Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright" querystring="R146656,W104393803,N240109189" polygon="false">
|
||||
<place place_id="127761056" osm_type="relation" osm_id="146656" place_rank="16" lat="53.4791466" lon="-2.2447445" display_name="Manchester, Greater Manchester, North West England, England, United Kingdom" class="boundary" type="administrative" importance="0.704893333438333">
|
||||
<lookupresults timestamp="Mon, 28 Mar 22 14:38:54 +0000" attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" querystring="R146656,W50637691,N240109189" more_url="">
|
||||
<place place_id="282236157" osm_type="relation" osm_id="146656" place_rank="16" address_rank="16" boundingbox="53.3401044,53.5445923,-2.3199185,-2.1468288" lat="53.44246175" lon="-2.2324547359718547" display_name="Manchester, Greater Manchester, North West England, England, United Kingdom" class="boundary" type="administrative" importance="0.35">
|
||||
<city>Manchester</city>
|
||||
<county>Greater Manchester</county>
|
||||
<state_district>North West England</state_district>
|
||||
@@ -102,21 +156,20 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
<country>United Kingdom</country>
|
||||
<country_code>gb</country_code>
|
||||
</place>
|
||||
<place place_id="77769745" osm_type="way" osm_id="104393803" place_rank="30" lat="52.5162024" lon="13.3777343363579" display_name="Brandenburg Gate, 1, Pariser Platz, Mitte, Berlin, 10117, Germany" class="tourism" type="attraction" importance="0.443472858361592">
|
||||
<attraction>Brandenburg Gate</attraction>
|
||||
<house_number>1</house_number>
|
||||
<pedestrian>Pariser Platz</pedestrian>
|
||||
<suburb>Mitte</suburb>
|
||||
<city_district>Mitte</city_district>
|
||||
<city>Berlin</city>
|
||||
<state>Berlin</state>
|
||||
<postcode>10117</postcode>
|
||||
<place place_id="115462561" osm_type="way" osm_id="50637691" place_rank="30" address_rank="30" boundingbox="52.3994612,52.3996426,13.0479574,13.0481754" lat="52.399550700000006" lon="13.048066846939687" display_name="Brandenburger Tor, Brandenburger Straße, Historische Innenstadt, Innenstadt, Potsdam, Brandenburg, 14467, Germany" class="tourism" type="attraction" importance="0.29402874005524">
|
||||
<tourism>Brandenburger Tor</tourism>
|
||||
<road>Brandenburger Straße</road>
|
||||
<suburb>Historische Innenstadt</suburb>
|
||||
<city>Potsdam</city>
|
||||
<state>Brandenburg</state>
|
||||
<postcode>14467</postcode>
|
||||
<country>Germany</country>
|
||||
<country_code>de</country_code>
|
||||
</place>
|
||||
<place place_id="2570600569" osm_type="node" osm_id="240109189" place_rank="15" lat="52.5170365" lon="13.3888599" display_name="Berlin, Germany" class="place" type="city" importance="0.822149797630868">
|
||||
<place place_id="567505" osm_type="node" osm_id="240109189" place_rank="15" address_rank="16" boundingbox="52.3586925,52.6786925,13.2396024,13.5596024" lat="52.5186925" lon="13.3996024" display_name="Berlin, 10178, Germany" class="place" type="city" importance="0.78753902824914">
|
||||
<city>Berlin</city>
|
||||
<state>Berlin</state>
|
||||
<postcode>10178</postcode>
|
||||
<country>Germany</country>
|
||||
<country_code>de</country_code>
|
||||
</place>
|
||||
@@ -125,38 +178,50 @@ This overrides the specified machine readable format. (Default: 0)
|
||||
|
||||
##### JSON with extratags
|
||||
|
||||
[https://nominatim.openstreetmap.org/lookup?osm_ids=W50637691&format=json](https://nominatim.openstreetmap.org/lookup?osm_ids=W50637691&format=json)
|
||||
[https://nominatim.openstreetmap.org/lookup?osm_ids=W50637691&format=json&extratags=1](https://nominatim.openstreetmap.org/lookup?osm_ids=W50637691&format=json&extratags=1)
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"place_id": "84271358",
|
||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
||||
"osm_type": "way",
|
||||
"osm_id": "50637691",
|
||||
"lat": "52.39955055",
|
||||
"lon": "13.04806574678",
|
||||
"display_name": "Brandenburger Tor, Brandenburger Straße, Nördliche Innenstadt, Innenstadt, Potsdam, Brandenburg, 14467, Germany",
|
||||
"class": "historic",
|
||||
"type": "city_gate",
|
||||
"importance": "0.221233780277011",
|
||||
"address": {
|
||||
"address29": "Brandenburger Tor",
|
||||
"pedestrian": "Brandenburger Straße",
|
||||
"suburb": "Nördliche Innenstadt",
|
||||
"city": "Potsdam",
|
||||
"state": "Brandenburg",
|
||||
"postcode": "14467",
|
||||
"country": "Germany",
|
||||
"country_code": "de"
|
||||
},
|
||||
"extratags": {
|
||||
"image": "http://commons.wikimedia.org/wiki/File:Potsdam_brandenburger_tor.jpg",
|
||||
"wikidata": "Q695045",
|
||||
"wikipedia": "de:Brandenburger Tor (Potsdam)",
|
||||
"wheelchair": "yes",
|
||||
"description": "Kleines Brandenburger Tor in Potsdam"
|
||||
}
|
||||
}
|
||||
{
|
||||
"place_id": 115462561,
|
||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
||||
"osm_type": "way",
|
||||
"osm_id": 50637691,
|
||||
"boundingbox": [
|
||||
"52.3994612",
|
||||
"52.3996426",
|
||||
"13.0479574",
|
||||
"13.0481754"
|
||||
],
|
||||
"lat": "52.399550700000006",
|
||||
"lon": "13.048066846939687",
|
||||
"display_name": "Brandenburger Tor, Brandenburger Straße, Historische Innenstadt, Innenstadt, Potsdam, Brandenburg, 14467, Germany",
|
||||
"class": "tourism",
|
||||
"type": "attraction",
|
||||
"importance": 0.2940287400552381,
|
||||
"address": {
|
||||
"tourism": "Brandenburger Tor",
|
||||
"road": "Brandenburger Straße",
|
||||
"suburb": "Historische Innenstadt",
|
||||
"city": "Potsdam",
|
||||
"state": "Brandenburg",
|
||||
"postcode": "14467",
|
||||
"country": "Germany",
|
||||
"country_code": "de"
|
||||
},
|
||||
"extratags": {
|
||||
"image": "http://commons.wikimedia.org/wiki/File:Potsdam_brandenburger_tor.jpg",
|
||||
"heritage": "4",
|
||||
"wikidata": "Q695045",
|
||||
"architect": "Carl von Gontard;Georg Christian Unger",
|
||||
"wikipedia": "de:Brandenburger Tor (Potsdam)",
|
||||
"wheelchair": "yes",
|
||||
"description": "Kleines Brandenburger Tor in Potsdam",
|
||||
"heritage:website": "http://www.bldam-brandenburg.de/images/stories/PDF/DML%202012/04-p-internet-13.pdf",
|
||||
"heritage:operator": "bldam",
|
||||
"architect:wikidata": "Q68768;Q95223",
|
||||
"year_of_construction": "1771"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
@@ -28,6 +28,7 @@ a single place (for reverse) of the following format:
|
||||
"city": "London",
|
||||
"state_district": "Greater London",
|
||||
"state": "England",
|
||||
"ISO3166-2-lvl4": "GB-ENG",
|
||||
"postcode": "SW1A 2DU",
|
||||
"country": "United Kingdom",
|
||||
"country_code": "gb"
|
||||
@@ -97,7 +98,10 @@ The GeocodeJSON format follows the
|
||||
The following feature attributes are implemented:
|
||||
|
||||
* `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, ...)
|
||||
* `type` - the 'address level' of the object ('house', 'street', `district`, `city`,
|
||||
`county`, `state`, `country`, `locality`)
|
||||
* `osm_key`- key of the main tag of the OSM object (e.g. boundary, highway, amenity)
|
||||
* `osm_value` - value of the main tag of the OSM object (e.g. residential, restaurant)
|
||||
* `label` - full comma-separated address
|
||||
* `name` - localised name of the place
|
||||
* `housenumber`, `street`, `locality`, `district`, `postcode`, `city`,
|
||||
@@ -126,6 +130,7 @@ formats depending on the API call.
|
||||
</result>
|
||||
<addressparts>
|
||||
<state>Bavaria</state>
|
||||
<ISO3166-2-lvl4>DE-BY</ISO3166-2-lvl4>
|
||||
<country>Germany</country>
|
||||
<country_code>de</country_code>
|
||||
</addressparts>
|
||||
@@ -179,6 +184,7 @@ Additional information requested with `addressdetails=1`, `extratags=1` and
|
||||
<city>London</city>
|
||||
<state_district>Greater London</state_district>
|
||||
<state>England</state>
|
||||
<ISO3166-2-lvl4>GB-ENG</ISO3166-2-lvl4>
|
||||
<postcode>SW1A 2DU</postcode>
|
||||
<country>United Kingdom</country>
|
||||
<country_code>gb</country_code>
|
||||
@@ -205,8 +211,8 @@ be more than one. The attributes of that element contain:
|
||||
* `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 ([see notes](#boundingbox))
|
||||
* `place_rank` - class [search rank](../develop/Ranking#search-rank)
|
||||
* `address_rank` - place [address rank](../develop/Ranking#address-rank)
|
||||
* `place_rank` - class [search rank](../customize/Ranking.md#search-rank)
|
||||
* `address_rank` - place [address rank](../customize/Ranking.md#address-rank)
|
||||
* `display_name` - full comma-separated address
|
||||
* `class`, `type` - key and value of the main OSM tag
|
||||
* `importance` - computed importance rank
|
||||
@@ -230,7 +236,7 @@ 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
|
||||
The combination `osm_type`+`osm_id` is slightly 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`,
|
||||
@@ -279,12 +285,12 @@ with a designation label. Per default the following labels may appear:
|
||||
|
||||
* continent
|
||||
* country, country_code
|
||||
* region, state, state_district, county
|
||||
* region, state, state_district, county, ISO3166-2-lvl<admin_level>
|
||||
* 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
|
||||
* city_block, residential, farm, farmyard, industrial, commercial, retail
|
||||
* road
|
||||
* house_number, house_name
|
||||
* emergency, historic, military, natural, landuse, place, railway,
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
### Nominatim API
|
||||
|
||||
Nominatim indexes named (or numbered) features within the OpenStreetMap (OSM) dataset and a subset of other unnamed features (pubs, hotels, churches, etc).
|
||||
!!! Attention
|
||||
The current version of Nominatim implements two different search frontends:
|
||||
the old PHP frontend and the new Python frontend. They have a very similar
|
||||
API but differ in some implementation details. These are marked in the
|
||||
documentation as `[Python-only]` or `[PHP-only]`.
|
||||
|
||||
Its API has the following endpoints for querying the data:
|
||||
`https://nominatim.openstreetmap.org` implements the **Python frontend**.
|
||||
So users should refer to the **`[Python-only]`** comments.
|
||||
|
||||
This section describes the API V1 of the Nominatim web service. The
|
||||
service offers the following endpoints:
|
||||
|
||||
* __[/search](Search.md)__ - search OSM objects by name or type
|
||||
* __[/reverse](Reverse.md)__ - search OSM object by their location
|
||||
@@ -12,3 +20,6 @@ Its API has the following endpoints for querying the data:
|
||||
back in Nominatim in case the deletion was accidental
|
||||
* __/polygons__ - list of broken polygons detected by Nominatim
|
||||
* __[/details](Details.md)__ - show internal details for an object (for debugging only)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Reverse Geocoding
|
||||
|
||||
Reverse geocoding generates an address from a latitude and longitude.
|
||||
Reverse geocoding generates an address from a coordinate given as
|
||||
latitude and longitude.
|
||||
|
||||
## How it works
|
||||
|
||||
@@ -18,8 +19,7 @@ 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
|
||||
## Endpoint
|
||||
|
||||
The main format of the reverse API is
|
||||
|
||||
@@ -27,61 +27,105 @@ The main format of the reverse API is
|
||||
https://nominatim.openstreetmap.org/reverse?lat=<value>&lon=<value>&<params>
|
||||
```
|
||||
|
||||
where `lat` and `lon` are latitude and longitutde of a coordinate in WGS84
|
||||
where `lat` and `lon` are latitude and longitude 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.
|
||||
|
||||
Additional paramters are accepted as listed below.
|
||||
|
||||
!!! warning "Deprecation warning"
|
||||
!!! danger "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.
|
||||
its OSM id for `[PHP-only]`. The use is considered deprecated.
|
||||
Use the [Address Lookup API](Lookup.md) instead.
|
||||
|
||||
!!! danger "Deprecation warning"
|
||||
The API can also be used with the URL
|
||||
`https://nominatim.openstreetmap.org/reverse.php`. This is now deprecated
|
||||
and will be removed in future versions.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
This section lists additional parameters to further influence the output.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `xml` |
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: xml)
|
||||
See [Place Output Formats](Output.md) for details on each format.
|
||||
|
||||
* `json_callback=<string>`
|
||||
|
||||
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| json_callback | function name | _unset_ |
|
||||
|
||||
When given, then JSON output will be wrapped in a callback function with
|
||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
||||
information.
|
||||
|
||||
Only has an effect for JSON output formats.
|
||||
|
||||
|
||||
### Output details
|
||||
|
||||
* `addressdetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| addressdetails | 0 or 1 | 1 |
|
||||
|
||||
Include a breakdown of the address into elements. (Default: 1)
|
||||
When set to 1, include a breakdown of the address into elements.
|
||||
The exact content of the address breakdown depends on the output format.
|
||||
|
||||
!!! tip
|
||||
If you are interested in a stable classification of address categories
|
||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
||||
All other formats return classifications according to OSM tagging.
|
||||
There is a much larger set of categories and they are not always consistent,
|
||||
which makes them very hard to work with.
|
||||
|
||||
|
||||
* `extratags=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| extratags | 0 or 1 | 0 |
|
||||
|
||||
Include additional information in the result if available,
|
||||
e.g. wikipedia link, opening hours. (Default: 0)
|
||||
When set to 1, the response include any additional information in the result
|
||||
that is available in the database, e.g. wikipedia link, opening hours.
|
||||
|
||||
|
||||
* `namedetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| namedetails | 0 or 1 | 0 |
|
||||
|
||||
Include a list of alternative names in the results. These may include
|
||||
language variants, references, operator and brand. (Default: 0)
|
||||
When set to 1, include a full list of names for the result. These may include
|
||||
language variants, older names, references and brand.
|
||||
|
||||
|
||||
### Language of results
|
||||
|
||||
* `accept-language=<browser language string>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
||||
|
||||
Preferred language order for showing search results, overrides the value
|
||||
specified in the "Accept-Language" HTTP header.
|
||||
Either use a standard RFC2616 accept-language string or a simple
|
||||
comma-separated list of language codes.
|
||||
Preferred language order for showing search results. This may either be
|
||||
a simple comma-separated list of language codes or have the same format
|
||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||
|
||||
### Result limitation
|
||||
!!! tip
|
||||
First-time users of Nominatim tend to be confused that they get different
|
||||
results when using Nominatim in the browser versus in a command-line tool
|
||||
like wget or curl. The command-line tools
|
||||
usually don't send any Accept-Language header, prompting Nominatim
|
||||
to show results in the local language. Browsers on the contratry always
|
||||
send the currently chosen browser language.
|
||||
|
||||
* `zoom=[0-18]`
|
||||
|
||||
Level of detail required for the address. Default: 18. This is a number that
|
||||
### Result restriction
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| zoom | 0-18 | 18 |
|
||||
|
||||
Level of detail required for the address. 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:
|
||||
@@ -92,41 +136,79 @@ In terms of address details the zoom levels are as follows:
|
||||
5 | state
|
||||
8 | county
|
||||
10 | city
|
||||
14 | suburb
|
||||
12 | town / borough
|
||||
13 | village / suburb
|
||||
14 | neighbourhood
|
||||
15 | any settlement
|
||||
16 | major streets
|
||||
17 | major and minor streets
|
||||
18 | building
|
||||
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| layer | comma-separated list of: `address`, `poi`, `railway`, `natural`, `manmade` | _unset_ (no restriction) |
|
||||
|
||||
The layer filter allows to select places by themes.
|
||||
|
||||
The `address` layer contains all places that make up an address:
|
||||
address points with house numbers, streets, inhabited places (suburbs, villages,
|
||||
cities, states etc.) and administrative boundaries.
|
||||
|
||||
The `poi` layer selects all point of interest. This includes classic points
|
||||
of interest like restaurants, shops, hotels but also less obvious features
|
||||
like recycling bins, guideposts or benches.
|
||||
|
||||
The `railway` layer includes railway infrastructure like tracks.
|
||||
Note that in Nominatim's standard configuration, only very few railway
|
||||
features are imported into the database.
|
||||
|
||||
The `natural` layer collects feautures like rivers, lakes and mountains while
|
||||
the `manmade` layer functions as a catch-all for features not covered by the
|
||||
other layers.
|
||||
|
||||
|
||||
### Polygon output
|
||||
|
||||
* `polygon_geojson=1`
|
||||
* `polygon_kml=1`
|
||||
* `polygon_svg=1`
|
||||
* `polygon_text=1`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_geojson | 0 or 1 | 0 |
|
||||
| polygon_kml | 0 or 1 | 0 |
|
||||
| polygon_svg | 0 or 1 | 0 |
|
||||
| polygon_text | 0 or 1 | 0 |
|
||||
|
||||
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||
options can be used at a time. (Default: 0)
|
||||
Add the full geometry of the place to the result output. Output formats
|
||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
||||
options can be used at a time.
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_threshold | floating-point number | 0.0 |
|
||||
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
When one of the polygon_* outputs is chosen, return a simplified version
|
||||
of the output geometry. The parameter describes the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
geometry. Topology is preserved in the geometry.
|
||||
|
||||
|
||||
### Other
|
||||
|
||||
* `email=<valid email address>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| email | valid email address | _unset_ |
|
||||
|
||||
If you are making large numbers of request please include an appropriate email
|
||||
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
address to identify your requests. See Nominatim's
|
||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
|
||||
|
||||
* `debug=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| debug | 0 or 1 | 0 |
|
||||
|
||||
Output assorted developer debug information. Data on internals of Nominatim's
|
||||
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||
This overrides the specified machine readable format. (Default: 0)
|
||||
"search loop" logic, and SQL queries. The output is HTML format.
|
||||
This overrides the specified machine readable format.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -8,12 +8,12 @@ The search query may also contain
|
||||
which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`).
|
||||
This can be used to narrow down the kind of objects to be returned.
|
||||
|
||||
!!! warning
|
||||
!!! note
|
||||
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
|
||||
## Endpoint
|
||||
|
||||
The search API has the following format:
|
||||
|
||||
@@ -21,82 +21,211 @@ The search API has the following format:
|
||||
https://nominatim.openstreetmap.org/search?<params>
|
||||
```
|
||||
|
||||
The search term may be specified with two different sets of parameters:
|
||||
!!! danger "Deprecation warning"
|
||||
The API can also be used with the URL
|
||||
`https://nominatim.openstreetmap.org/search.php`. This is now deprecated
|
||||
and will be removed in future versions.
|
||||
|
||||
* `q=<query>`
|
||||
The query term can be given in two different forms: free-form or structured.
|
||||
|
||||
Free-form query string to search for.
|
||||
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for
|
||||
[pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for
|
||||
[birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue).
|
||||
Commas are optional, but improve performance by reducing the complexity of the search.
|
||||
### Free-form query
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------| ----- |
|
||||
| q | Free-form query string to search for |
|
||||
|
||||
* `street=<housenumber> <streetname>`
|
||||
* `city=<city>`
|
||||
* `county=<county>`
|
||||
* `state=<state>`
|
||||
* `country=<country>`
|
||||
* `postalcode=<postalcode>`
|
||||
In this form, the query can be unstructured.
|
||||
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for
|
||||
[pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for
|
||||
[birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue).
|
||||
Commas are optional, but improve performance by reducing the complexity of the search.
|
||||
|
||||
Alternative query string format split into several parameters for structured requests.
|
||||
Structured requests are faster but are less robust against alternative
|
||||
OSM tagging schemas. **Do not combine with** `q=<query>` **parameter**.
|
||||
The free-form may also contain special phrases to describe the type of
|
||||
place to be returned or a coordinate to search close to a position.
|
||||
|
||||
Both query forms accept the additional parameters listed below.
|
||||
### Structured query
|
||||
|
||||
| Parameter | Value |
|
||||
|----------- | ----- |
|
||||
| amenity | name and/or type of POI |
|
||||
| street | housenumber and streetname |
|
||||
| city | city |
|
||||
| county | county |
|
||||
| state | state |
|
||||
| country | country |
|
||||
| postalcode | postal code |
|
||||
|
||||
The structured form of the search query allows to lookup up an address
|
||||
that is already split into its components. Each parameter represents a field
|
||||
of the address. All parameters are optional. You should only use the ones
|
||||
that are relevant for the address you want to geocode.
|
||||
|
||||
!!! Attention
|
||||
Cannot be combined with the `q=<query>` parameter. Newer versions of
|
||||
the API will return an error if you do so. Older versions simply return
|
||||
unexpected results.
|
||||
|
||||
## Parameters
|
||||
|
||||
The following parameters can be used to further restrict the search and
|
||||
change the output. They are usable for both forms of the search query.
|
||||
|
||||
### Output format
|
||||
|
||||
* `format=[xml|json|jsonv2|geojson|geocodejson]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `jsonv2` |
|
||||
|
||||
See [Place Output Formats](Output.md) for details on each format. (Default: jsonv2)
|
||||
See [Place Output Formats](Output.md) for details on each format.
|
||||
|
||||
* `json_callback=<string>`
|
||||
!!! note
|
||||
The Nominatim service at
|
||||
[https://nominatim.openstreetmap.org](https://nominatim.openstreetmap.org)
|
||||
has a different default behaviour for historical reasons. When the
|
||||
`format` parameter is omitted, the request will be forwarded to the Web UI.
|
||||
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| json_callback | function name | _unset_ |
|
||||
|
||||
When given, then JSON output will be wrapped in a callback function with
|
||||
the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more
|
||||
information.
|
||||
|
||||
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.
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| limit | number | 10 |
|
||||
|
||||
Limit the maximum number of returned results. Cannot be more than 40.
|
||||
Nominatim may decide to return less results than given, if additional
|
||||
results do not sufficiently match the query.
|
||||
|
||||
|
||||
### Output details
|
||||
|
||||
* `addressdetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| addressdetails | 0 or 1 | 0 |
|
||||
|
||||
Include a breakdown of the address into elements. (Default: 0)
|
||||
When set to 1, include a breakdown of the address into elements.
|
||||
The exact content of the address breakdown depends on the output format.
|
||||
|
||||
!!! tip
|
||||
If you are interested in a stable classification of address categories
|
||||
(suburb, city, state, etc), have a look at the `geocodejson` format.
|
||||
All other formats return classifications according to OSM tagging.
|
||||
There is a much larger set of categories and they are not always consistent,
|
||||
which makes them very hard to work with.
|
||||
|
||||
|
||||
* `extratags=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| extratags | 0 or 1 | 0 |
|
||||
|
||||
Include additional information in the result if available,
|
||||
e.g. wikipedia link, opening hours. (Default: 0)
|
||||
When set to 1, the response include any additional information in the result
|
||||
that is available in the database, e.g. wikipedia link, opening hours.
|
||||
|
||||
|
||||
* `namedetails=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| namedetails | 0 or 1 | 0 |
|
||||
|
||||
Include a list of alternative names in the results. These may include
|
||||
language variants, references, operator and brand. (Default: 0)
|
||||
When set to 1, include a full list of names for the result. These may include
|
||||
language variants, older names, references and brand.
|
||||
|
||||
|
||||
### Language of results
|
||||
|
||||
* `accept-language=<browser language string>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| accept-language | browser language string | content of "Accept-Language" HTTP header |
|
||||
|
||||
Preferred language order for showing search results, overrides the value
|
||||
specified in the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||
Either use a standard RFC2616 accept-language string or a simple
|
||||
comma-separated list of language codes.
|
||||
Preferred language order for showing search results. This may either be
|
||||
a simple comma-separated list of language codes or have the same format
|
||||
as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language).
|
||||
|
||||
### Result limitation
|
||||
!!! tip
|
||||
First-time users of Nominatim tend to be confused that they get different
|
||||
results when using Nominatim in the browser versus in a command-line tool
|
||||
like wget or curl. The command-line tools
|
||||
usually don't send any Accept-Language header, prompting Nominatim
|
||||
to show results in the local language. Browsers on the contratry always
|
||||
send the currently chosen browser language.
|
||||
|
||||
* `countrycodes=<countrycode>[,<countrycode>][,<countrycode>]...`
|
||||
### Result restriction
|
||||
|
||||
Limit search results to one or more countries. `<countrycode>` must be the
|
||||
[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code,
|
||||
e.g. `gb` for the United Kingdom, `de` for Germany.
|
||||
There are two ways to influence the results. *Filters* exclude certain
|
||||
kinds of results completely. *Boost parameters* only change the order of the
|
||||
results and thus give a preference to some results over others.
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| countrycodes | comma-separated list of country codes | _unset_ |
|
||||
|
||||
Filer that limits the search results to one or more countries.
|
||||
The country code must be the
|
||||
[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code
|
||||
of the country, 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.
|
||||
at all, for example, when it is in international waters. These places are
|
||||
also excluded when the filter is set.
|
||||
|
||||
* `exclude_place_ids=<place_id,[place_id],[place_id]`
|
||||
!!! Note
|
||||
This parameter should not be confused with the 'country' parameter of
|
||||
the structured query. The 'country' parameter contains a search term
|
||||
and will be handled with some fuzziness. The `countrycodes` parameter
|
||||
is a hard filter and as such should be prefered. Having both parameters
|
||||
in the same query will work. If the parameters contradict each other,
|
||||
the search will come up empty.
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| layer | comma-separated list of: `address`, `poi`, `railway`, `natural`, `manmade` | _unset_ (no restriction) |
|
||||
|
||||
The layer filter allows to select places by themes.
|
||||
|
||||
The `address` layer contains all places that make up an address:
|
||||
address points with house numbers, streets, inhabited places (suburbs, villages,
|
||||
cities, states tec.) and administrative boundaries.
|
||||
|
||||
The `poi` layer selects all point of interest. This includes classic POIs like
|
||||
restaurants, shops, hotels but also less obvious features like recycling bins,
|
||||
guideposts or benches.
|
||||
|
||||
The `railway` layer includes railway infrastructure like tracks.
|
||||
Note that in Nominatim's standard configuration, only very few railway
|
||||
features are imported into the database.
|
||||
|
||||
The `natural` layer collects feautures like rivers, lakes and mountains while
|
||||
the `manmade` layer functions as a catch-all for features not covered by the
|
||||
other layers.
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| featureType | one of: `country`, `state`, `city`, `settlement` | _unset_ |
|
||||
|
||||
The featureType allows to have a more fine-grained selection for places
|
||||
from the address layer. Results can be restricted to places that make up
|
||||
the 'state', 'country' or 'city' part of an address. A featureType of
|
||||
settlement selects any human inhabited feature from 'state' down to
|
||||
'neighbourhood'.
|
||||
|
||||
When featureType ist set, then results are automatically restricted
|
||||
to the address layer (see above).
|
||||
|
||||
!!! tip
|
||||
Instead of using the featureType filters `country`, `state` or `city`,
|
||||
you can also use a structured query without the finer-grained parameters
|
||||
amenity or street.
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| exclude_place_ids | comma-separeted list of place ids |
|
||||
|
||||
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.
|
||||
@@ -104,180 +233,212 @@ 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).
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| viewbox | `<x1>,<y1>,<x2>,<y2>` | _unset_ |
|
||||
|
||||
* `limit=<integer>`
|
||||
Boost parameter which focuses the search on the given area.
|
||||
Any two corner points of the box are accepted as long as they make a proper
|
||||
box. `x` is longitude, `y` is latitude.
|
||||
|
||||
Limit the number of returned results. (Default: 10, Maximum: 50)
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| bounded | 0 or 1 | 0 |
|
||||
|
||||
When set to 1, then it turns the 'viewbox' parameter (see above) into
|
||||
a filter paramter, excluding any results outside the viewbox.
|
||||
|
||||
* `viewbox=<x1>,<y1>,<x2>,<y2>`
|
||||
|
||||
The preferred area to find search results. Any two corner points of the 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 within that
|
||||
viewbox (see above). When `viewbox` and `bounded=1` are given, an amenity
|
||||
only search is allowed. Give the special keyword for the amenity in square
|
||||
When `bounded=1` is given and the viewbox is small enough, then an amenity-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)
|
||||
There is no guarantee that the result returns all objects in the area.
|
||||
|
||||
|
||||
### Polygon output
|
||||
|
||||
* `polygon_geojson=1`
|
||||
* `polygon_kml=1`
|
||||
* `polygon_svg=1`
|
||||
* `polygon_text=1`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_geojson | 0 or 1 | 0 |
|
||||
| polygon_kml | 0 or 1 | 0 |
|
||||
| polygon_svg | 0 or 1 | 0 |
|
||||
| polygon_text | 0 or 1 | 0 |
|
||||
|
||||
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
|
||||
options can be used at a time. (Default: 0)
|
||||
Add the full geometry of the place to the result output. Output formats
|
||||
in GeoJSON, KML, SVG or WKT are supported. Only one of these
|
||||
options can be used at a time.
|
||||
|
||||
* `polygon_threshold=0.0`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| polygon_threshold | floating-point number | 0.0 |
|
||||
|
||||
Return a simplified version of the output geometry. The parameter is the
|
||||
When one of the polygon_* outputs is chosen, return a simplified version
|
||||
of the output geometry. The parameter describes the
|
||||
tolerance in degrees with which the geometry may differ from the original
|
||||
geometry. Topology is preserved in the result. (Default: 0.0)
|
||||
geometry. Topology is preserved in the geometry.
|
||||
|
||||
### Other
|
||||
|
||||
* `email=<valid email address>`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| email | valid email address | _unset_ |
|
||||
|
||||
If you are making large numbers of request please include an appropriate email
|
||||
address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
address to identify your requests. See Nominatim's
|
||||
[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
|
||||
|
||||
* `dedupe=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| dedupe | 0 or 1 | 1 |
|
||||
|
||||
Sometimes you have several objects in OSM identifying the same place or
|
||||
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)
|
||||
attempt to detect such duplicates and only return one match. Setting
|
||||
this parameter to 0 disables this deduplication mechanism and
|
||||
ensures that all results are returned.
|
||||
|
||||
* `debug=[0|1]`
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| debug | 0 or 1 | 0 |
|
||||
|
||||
Output assorted developer debug information. Data on internals of Nominatim's
|
||||
"Search Loop" logic, and SQL queries. The output is (rough) HTML format.
|
||||
This overrides the specified machine readable format. (Default: 0)
|
||||
|
||||
"search loop" logic, and SQL queries. The output is HTML format.
|
||||
This overrides the specified machine readable format.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
##### XML with kml polygon
|
||||
##### XML with KML polygon
|
||||
|
||||
* [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)
|
||||
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_kml=1&addressdetails=1](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_kml=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"
|
||||
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>
|
||||
<town>Sutton Coldfield</town>
|
||||
<city>City of Birmingham</city>
|
||||
<county>West Midlands (county)</county>
|
||||
<postcode>B72</postcode>
|
||||
<country>United Kingdom</country>
|
||||
<country_code>gb</country_code>
|
||||
</place>
|
||||
</searchresults>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<searchresults timestamp="Tue, 08 Aug 2023 15:45:41 +00:00"
|
||||
attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright"
|
||||
querystring="135 pilkington avenue, birmingham"
|
||||
more_url="https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue%2C+birmingham&polygon_kml=1&addressdetails=1&limit=20&exclude_place_ids=125279639&format=xml"
|
||||
exclude_place_ids="125279639">
|
||||
<place place_id="125279639"
|
||||
osm_type="way"
|
||||
osm_id="90394480"
|
||||
lat="52.5487921"
|
||||
lon="-1.8164308"
|
||||
boundingbox="52.5487473,52.5488481,-1.8165130,-1.8163464"
|
||||
place_rank="30"
|
||||
address_rank="30"
|
||||
display_name="135, Pilkington Avenue, Maney, Sutton Coldfield, Wylde Green, Birmingham, West Midlands Combined Authority, England, B72 1LH, United Kingdom"
|
||||
class="building"
|
||||
type="residential"
|
||||
importance="9.999999994736442e-08">
|
||||
<geokml>
|
||||
<Polygon>
|
||||
<outerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>-1.816513,52.5487566 -1.816434,52.5487473 -1.816429,52.5487629 -1.8163717,52.5487561 -1.8163464,52.5488346 -1.8164599,52.5488481 -1.8164685,52.5488213 -1.8164913,52.548824 -1.816513,52.5487566</coordinates>
|
||||
</LinearRing>
|
||||
</outerBoundaryIs>
|
||||
</Polygon>
|
||||
</geokml>
|
||||
<house_number>135</house_number>
|
||||
<road>Pilkington Avenue</road>
|
||||
<hamlet>Maney</hamlet>
|
||||
<town>Sutton Coldfield</town>
|
||||
<village>Wylde Green</village>
|
||||
<city>Birmingham</city>
|
||||
<ISO3166-2-lvl8>GB-BIR</ISO3166-2-lvl8>
|
||||
<state_district>West Midlands Combined Authority</state_district>
|
||||
<state>England</state>
|
||||
<ISO3166-2-lvl4>GB-ENG</ISO3166-2-lvl4>
|
||||
<postcode>B72 1LH</postcode>
|
||||
<country>United Kingdom</country>
|
||||
<country_code>gb</country_code>
|
||||
</place>
|
||||
</searchresults>
|
||||
```
|
||||
|
||||
##### JSON with SVG polygon
|
||||
|
||||
[https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1](https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1)
|
||||
[https://nominatim.openstreetmap.org/search?q=Unter%20den%20Linden%201%20Berlin&format=json&addressdetails=1&limit=1&polygon_svg=1](https://nominatim.openstreetmap.org/search?q=Unter%20den%20Linden%201%20Berlin&format=json&addressdetails=1&limit=1&polygon_svg=1)
|
||||
|
||||
```json
|
||||
{
|
||||
"address": {
|
||||
"city": "Berlin",
|
||||
"city_district": "Mitte",
|
||||
"construction": "Unter den Linden",
|
||||
"continent": "European Union",
|
||||
"country": "Deutschland",
|
||||
"country_code": "de",
|
||||
"house_number": "1",
|
||||
"neighbourhood": "Scheunenviertel",
|
||||
"postcode": "10117",
|
||||
"public_building": "Kommandantenhaus",
|
||||
"state": "Berlin",
|
||||
"suburb": "Mitte"
|
||||
},
|
||||
"boundingbox": [
|
||||
"52.5170783996582",
|
||||
"52.5173187255859",
|
||||
"13.3975105285645",
|
||||
"13.3981599807739"
|
||||
],
|
||||
"class": "amenity",
|
||||
"display_name": "Kommandantenhaus, 1, Unter den Linden, Scheunenviertel, Mitte, Berlin, 10117, Deutschland, European Union",
|
||||
"importance": 0.73606775332943,
|
||||
"lat": "52.51719785",
|
||||
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
|
||||
"lon": "13.3978352028938",
|
||||
"osm_id": "15976890",
|
||||
"osm_type": "way",
|
||||
"place_id": "30848715",
|
||||
"svg": "M 13.397511 -52.517283599999999 L 13.397829400000001 -52.517299800000004 13.398131599999999 -52.517315099999998 13.398159400000001 -52.517112099999999 13.3975388 -52.517080700000001 Z",
|
||||
"type": "public_building"
|
||||
}
|
||||
[
|
||||
{
|
||||
"address": {
|
||||
"ISO3166-2-lvl4": "DE-BE",
|
||||
"borough": "Mitte",
|
||||
"city": "Berlin",
|
||||
"country": "Deutschland",
|
||||
"country_code": "de",
|
||||
"historic": "Kommandantenhaus",
|
||||
"house_number": "1",
|
||||
"neighbourhood": "Friedrichswerder",
|
||||
"postcode": "10117",
|
||||
"road": "Unter den Linden",
|
||||
"suburb": "Mitte"
|
||||
},
|
||||
"boundingbox": [
|
||||
"52.5170798",
|
||||
"52.5173311",
|
||||
"13.3975116",
|
||||
"13.3981577"
|
||||
],
|
||||
"class": "historic",
|
||||
"display_name": "Kommandantenhaus, 1, Unter den Linden, Friedrichswerder, Mitte, Berlin, 10117, Deutschland",
|
||||
"importance": 0.8135042058306902,
|
||||
"lat": "52.51720765",
|
||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
|
||||
"lon": "13.397834399325466",
|
||||
"osm_id": 15976890,
|
||||
"osm_type": "way",
|
||||
"place_id": 108681845,
|
||||
"svg": "M 13.3975116 -52.5172905 L 13.397549 -52.5170798 13.397715 -52.5170906 13.3977122 -52.5171064 13.3977392 -52.5171086 13.3977417 -52.5170924 13.3979655 -52.5171069 13.3979623 -52.5171233 13.3979893 -52.5171248 13.3979922 -52.5171093 13.3981577 -52.5171203 13.398121 -52.5173311 13.3978115 -52.5173103 Z",
|
||||
"type": "house"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
##### JSON with address details
|
||||
|
||||
[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)
|
||||
[https://nominatim.openstreetmap.org/search?addressdetails=1&q=bakery+in+berlin+wedding&format=jsonv2&limit=1](https://nominatim.openstreetmap.org/search?addressdetails=1&q=bakery+in+berlin+wedding&format=jsonv2&limit=1)
|
||||
|
||||
```json
|
||||
{
|
||||
"address": {
|
||||
"bakery": "B\u00e4cker Kamps",
|
||||
"city_district": "Mitte",
|
||||
"continent": "European Union",
|
||||
"country": "Deutschland",
|
||||
"country_code": "de",
|
||||
"footway": "Bahnsteig U6",
|
||||
"neighbourhood": "Sprengelkiez",
|
||||
"postcode": "13353",
|
||||
"state": "Berlin",
|
||||
"suburb": "Wedding"
|
||||
},
|
||||
"boundingbox": [
|
||||
"52.5460929870605",
|
||||
"52.5460968017578",
|
||||
"13.3591794967651",
|
||||
"13.3591804504395"
|
||||
],
|
||||
"class": "shop",
|
||||
"display_name": "B\u00e4cker Kamps, Bahnsteig U6, Sprengelkiez, Wedding, Mitte, Berlin, 13353, Deutschland, European Union",
|
||||
"icon": "https://nominatim.openstreetmap.org/images/mapicons/shopping_bakery.p.20.png",
|
||||
"importance": 0.201,
|
||||
"lat": "52.5460941",
|
||||
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
|
||||
"lon": "13.35918",
|
||||
"osm_id": "317179427",
|
||||
"osm_type": "node",
|
||||
"place_id": "1453068",
|
||||
"type": "bakery"
|
||||
}
|
||||
[
|
||||
{
|
||||
"address": {
|
||||
"ISO3166-2-lvl4": "DE-BE",
|
||||
"borough": "Mitte",
|
||||
"city": "Berlin",
|
||||
"country": "Deutschland",
|
||||
"country_code": "de",
|
||||
"neighbourhood": "Sprengelkiez",
|
||||
"postcode": "13347",
|
||||
"road": "Lindower Straße",
|
||||
"shop": "Ditsch",
|
||||
"suburb": "Wedding"
|
||||
},
|
||||
"addresstype": "shop",
|
||||
"boundingbox": [
|
||||
"52.5427201",
|
||||
"52.5427654",
|
||||
"13.3668619",
|
||||
"13.3669442"
|
||||
],
|
||||
"category": "shop",
|
||||
"display_name": "Ditsch, Lindower Straße, Sprengelkiez, Wedding, Mitte, Berlin, 13347, Deutschland",
|
||||
"importance": 9.99999999995449e-06,
|
||||
"lat": "52.54274275",
|
||||
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
|
||||
"lon": "13.36690305710228",
|
||||
"name": "Ditsch",
|
||||
"osm_id": 437595031,
|
||||
"osm_type": "way",
|
||||
"place_id": 204751033,
|
||||
"place_rank": 30,
|
||||
"type": "bakery"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
##### GeoJSON
|
||||
|
||||
@@ -1,35 +1,50 @@
|
||||
# Status
|
||||
|
||||
Useful for checking if the service and database is running. The JSON output also shows
|
||||
Report on the state of the service and database. Useful for checking if the
|
||||
service is up and running. The JSON output also reports
|
||||
when the database was last updated.
|
||||
|
||||
## Endpoint
|
||||
|
||||
The status API has the following format:
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/status
|
||||
```
|
||||
|
||||
!!! danger "Deprecation warning"
|
||||
The API can also be used with the URL
|
||||
`https://nominatim.openstreetmap.org/status.php`. This is now deprecated
|
||||
and will be removed in future versions.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
* `format=[text|json]` (defaults to 'text')
|
||||
The status endpoint takes a single optional parameter:
|
||||
|
||||
| Parameter | Value | Default |
|
||||
|-----------| ----- | ------- |
|
||||
| format | one of: `text`, `json` | 'text' |
|
||||
|
||||
Selects the output format. See below.
|
||||
|
||||
|
||||
## Output
|
||||
|
||||
#### Text format
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/status.php
|
||||
```
|
||||
When everything is okay, a status code 200 is returned and a simple message: `OK`
|
||||
|
||||
will return HTTP status code 200 and print `OK`.
|
||||
|
||||
On error it will return HTTP status code 500 and print a message, e.g.
|
||||
On error it will return HTTP status code 500 and print a detailed error message, e.g.
|
||||
`ERROR: Database connection failed`.
|
||||
|
||||
|
||||
|
||||
#### JSON format
|
||||
|
||||
```
|
||||
https://nominatim.openstreetmap.org/status.php?format=json
|
||||
```
|
||||
Always returns a HTTP code 200, when the status call could be executed.
|
||||
|
||||
will return HTTP code 200 and a structure
|
||||
On success a JSON dictionary with the following structure is returned:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -45,8 +60,8 @@ 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.
|
||||
On error will return a shorter JSON dictionary with the error message
|
||||
and status only, e.g.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -54,13 +69,3 @@ code and message, e.g.
|
||||
"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 |
|
||||
|
||||
149
docs/customize/Country-Settings.md
Normal file
149
docs/customize/Country-Settings.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# Customizing Per-Country Data
|
||||
|
||||
Whenever an OSM is imported into Nominatim, the object is first assigned
|
||||
a country. Nominatim can use this information to adapt various aspects of
|
||||
the address computation to the local customs of the country. This section
|
||||
explains how country assignment works and the principal per-country
|
||||
localizations.
|
||||
|
||||
## Country assignment
|
||||
|
||||
Countries are assigned on the basis of country data from the OpenStreetMap
|
||||
input data itself. Countries are expected to be tagged according to the
|
||||
[administrative boundary schema](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative):
|
||||
a OSM relation with `boundary=administrative` and `admin_level=2`. Nominatim
|
||||
uses the country code to distinguish the countries.
|
||||
|
||||
If there is no country data available for a point, then Nominatim uses the
|
||||
fallback data imported from `data/country_osm_grid.sql.gz`. This was computed
|
||||
from OSM data as well but is guaranteed to cover all countries.
|
||||
|
||||
Some OSM objects may also be located outside any country, for example a buoy
|
||||
in the middle of the ocean. These object do not get any country assigned and
|
||||
get a default treatment when it comes to localized handling of data.
|
||||
|
||||
## Per-country settings
|
||||
|
||||
### Global country settings
|
||||
|
||||
The main place to configure settings per country is the file
|
||||
`settings/country_settings.yaml`. This file has one section per country that
|
||||
is recognised by Nominatim. Each section is tagged with the country code
|
||||
(in lower case) and contains the different localization information. Only
|
||||
countries which are listed in this file are taken into account for computations.
|
||||
|
||||
For example, the section for Andorra looks like this:
|
||||
|
||||
```
|
||||
partition: 35
|
||||
languages: ca
|
||||
names: !include country-names/ad.yaml
|
||||
postcode:
|
||||
pattern: "(ddd)"
|
||||
output: AD\1
|
||||
```
|
||||
|
||||
The individual settings are described below.
|
||||
|
||||
#### `partition`
|
||||
|
||||
Nominatim internally splits the data into multiple tables to improve
|
||||
performance. The partition number tells Nominatim into which table to put
|
||||
the country. This is purely internal management and has no effect on the
|
||||
output data.
|
||||
|
||||
The default is to have one partition per country.
|
||||
|
||||
#### `languages`
|
||||
|
||||
A comma-separated list of ISO-639 language codes of default languages in the
|
||||
country. These are the languages used in name tags without a language suffix.
|
||||
Note that this is not necessarily the same as the list of official languages
|
||||
in the country. There may be officially recognised languages in a country
|
||||
which are only ever used in name tags with the appropriate language suffixes.
|
||||
Conversely, a non-official language may appear a lot in the name tags, for
|
||||
example when used as an unofficial Lingua Franca.
|
||||
|
||||
List the languages in order of frequency of appearance with the most frequently
|
||||
used language first. It is not recommended to add languages when there are only
|
||||
very few occurrences.
|
||||
|
||||
If only one language is listed, then Nominatim will 'auto-complete' the
|
||||
language of names without an explicit language-suffix.
|
||||
|
||||
#### `names`
|
||||
|
||||
List of names of the country and its translations. These names are used as
|
||||
a baseline. It is always possible to search countries by the given names, no
|
||||
matter what other names are in the OSM data. They are also used as a fallback
|
||||
when a needed translation is not available.
|
||||
|
||||
!!! Note
|
||||
The list of names per country is currently fairly large because Nominatim
|
||||
supports translations in many languages per default. That is why the
|
||||
name lists have been separated out into extra files. You can find the
|
||||
name lists in the file `settings/country-names/<country code>.yaml`.
|
||||
The names section in the main country settings file only refers to these
|
||||
files via the special `!include` directive.
|
||||
|
||||
#### `postcode`
|
||||
|
||||
Describes the format of the postcode that is in use in the country.
|
||||
|
||||
When a country has no official postcodes, set this to no. Example:
|
||||
|
||||
```
|
||||
ae:
|
||||
postcode: no
|
||||
```
|
||||
|
||||
When a country has a postcode, you need to state the postcode pattern and
|
||||
the default output format. Example:
|
||||
|
||||
```
|
||||
bm:
|
||||
postcode:
|
||||
pattern: "(ll)[ -]?(dd)"
|
||||
output: \1 \2
|
||||
```
|
||||
|
||||
The **pattern** is a regular expression that describes the possible formats
|
||||
accepted as a postcode. The pattern follows the standard syntax for
|
||||
[regular expressions in Python](https://docs.python.org/3/library/re.html#regular-expression-syntax)
|
||||
with two extra shortcuts: `d` is a shortcut for a single digit([0-9])
|
||||
and `l` for a single ASCII letter ([A-Z]).
|
||||
|
||||
Use match groups to indicate groups in the postcode that may optionally be
|
||||
separated with a space or a hyphen.
|
||||
|
||||
For example, the postcode for Bermuda above always consists of two letters
|
||||
and two digits. They may optionally be separated by a space or hyphen. That
|
||||
means that Nominatim will consider `AB56`, `AB 56` and `AB-56` spelling variants
|
||||
for one and the same postcode.
|
||||
|
||||
Never add the country code in front of the postcode pattern. Nominatim will
|
||||
automatically accept variants with a country code prefix for all postcodes.
|
||||
|
||||
The **output** field is an optional field that describes what the canonical
|
||||
spelling of the postcode should be. The format is the
|
||||
[regular expression expand syntax](https://docs.python.org/3/library/re.html#re.Match.expand) referring back to the bracket groups in the pattern.
|
||||
|
||||
Most simple postcodes only have one spelling variant. In that case, the
|
||||
**output** can be omitted. The postcode will simply be used as is.
|
||||
|
||||
In the Bermuda example above, the canonical spelling would be to have a space
|
||||
between letters and digits.
|
||||
|
||||
!!! Warning
|
||||
When your postcode pattern covers multiple variants of the postcode, then
|
||||
you must explicitly state the canonical output or Nominatim will not
|
||||
handle the variations correctly.
|
||||
|
||||
### Other country-specific configuration
|
||||
|
||||
There are some other configuration files where you can set localized settings
|
||||
according to the assigned country. These are:
|
||||
|
||||
* [Place ranking configuration](Ranking.md)
|
||||
|
||||
Please see the linked documentation sections for more information.
|
||||
@@ -1,149 +1,439 @@
|
||||
## Configuring the Import
|
||||
|
||||
Which OSM objects are added to the database and which of the tags are used
|
||||
can be configured via the import style configuration file. 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.
|
||||
In the very first step of a Nominatim import, OSM data is loaded into the
|
||||
database. Nominatim uses [osm2pgsql](https://osm2pgsql.org) for this task.
|
||||
It comes with a [flex style](https://osm2pgsql.org/doc/manual.html#the-flex-output)
|
||||
specifically tailored to filter and convert OSM data into Nominatim's
|
||||
internal data representation.
|
||||
|
||||
The style to use is given by the `NOMINATIM_IMPORT_STYLE` configuration
|
||||
option. There are a number of default styles, which are explained in detail
|
||||
in the [Import section](../admin/Import.md#filtering-imported-data). These
|
||||
standard styles may be referenced by their name.
|
||||
There are a number of default configurations for the flex style which
|
||||
result in geocoding databases of different detail. The
|
||||
[Import section](../admin/Import.md#filtering-imported-data) explains
|
||||
these default configurations in detail.
|
||||
|
||||
You can also create your own custom syle. Put the style file into your
|
||||
You can also create your own custom style. Put the style file into your
|
||||
project directory and then set `NOMINATIM_IMPORT_STYLE` to the name of the file.
|
||||
It is always recommended to start with one of the standard styles and customize
|
||||
those. You find the standard styles under the name `import-<stylename>.style`
|
||||
those. You find the standard styles under the name `import-<stylename>.lua`
|
||||
in the standard Nominatim configuration path (usually `/etc/nominatim` or
|
||||
`/usr/local/etc/nominatim`).
|
||||
|
||||
The remainder of the page describes the format of the file.
|
||||
The remainder of the page describes how the flex style works and how to
|
||||
customize it.
|
||||
|
||||
### Configuration Rules
|
||||
### The `flex-base.lua` module
|
||||
|
||||
A single rule looks like this:
|
||||
The core of Nominatim's flex import configuration is the `flex-base` module.
|
||||
It defines the table layout used by Nominatim and provides standard
|
||||
implementations for the import callbacks that make it easy to customize
|
||||
how OSM tags are used by Nominatim.
|
||||
|
||||
Every custom style should include this module to make sure that the correct
|
||||
tables are created. Thus start your custom style as follows:
|
||||
|
||||
``` lua
|
||||
local flex = require('flex-base')
|
||||
|
||||
```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 following sections explain how the module can be customized.
|
||||
|
||||
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.
|
||||
### Changing the recognized tags
|
||||
|
||||
The rules in a configuration file are processed sequentially and the first
|
||||
match for each tag wins.
|
||||
If you just want to change which OSM tags are recognized during import,
|
||||
then there are a number of convenience functions to set the tag lists used
|
||||
during the processing.
|
||||
|
||||
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.
|
||||
!!! warning
|
||||
There are no built-in defaults for the tag lists, so all the functions
|
||||
need to be called from your style script to fully process the data.
|
||||
Make sure you start from one of the default style and only modify
|
||||
the data you are interested in. You can also derive your style from an
|
||||
existing style by importing the appropriate module, e.g.
|
||||
`local flex = require('import-street')`.
|
||||
|
||||
### Tag Properties
|
||||
Many of the following functions take _key match lists_. These lists can
|
||||
contain three kinds of strings to match against tag keys:
|
||||
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 is matched exactly against tag keys.
|
||||
|
||||
One or more of the following properties may be given for each tag:
|
||||
|
||||
* `main`
|
||||
#### `set_main_tags()` - principal tags
|
||||
|
||||
A principal tag. A new row will be added for the object with key and value
|
||||
as `class` and `type`.
|
||||
If a principal or main tag is found on an OSM object, then the object
|
||||
is included in Nominatim's search index. A single object may also have
|
||||
multiple main tags. In that case, the object will be included multiple
|
||||
times in the index, once for each main tag.
|
||||
|
||||
* `with_name`
|
||||
The flex script distinguishes between four types of main tags:
|
||||
|
||||
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).
|
||||
* __always__: a main tag that is used unconditionally
|
||||
* __named__: consider this main tag only, if the object has a proper name
|
||||
(a reference is not enough, see below).
|
||||
* __named_with_key__: consider this main tag only, when the object has
|
||||
a proper name with a domain prefix. 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__: use this main tag only, if there is no other main tag.
|
||||
Fallback always implied `named`, i.e. fallbacks are only tried for
|
||||
named objects.
|
||||
|
||||
* `with_name_key`
|
||||
The `set_main_tags()` function takes exactly one table parameter which
|
||||
defines the keys and key/value combinations to include and the kind of
|
||||
main tag. Each lua table key defines an OSM tag key. The value may
|
||||
be a string defining the kind of main key as described above. Then the tag will
|
||||
be considered a main tag for any possible value. To further restrict
|
||||
which values are acceptable, give a table with the permitted values
|
||||
and their kind of main tag. If the table contains a simple value without
|
||||
key, then this is used as default for values that are not listed.
|
||||
|
||||
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.
|
||||
!!! example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
* `fallback`
|
||||
flex.set_main_tags{
|
||||
boundary = {administrative = 'named'},
|
||||
highway = {'always', street_lamp = 'named'},
|
||||
landuse = '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.
|
||||
In this example an object with a `boundary` tag will only be included
|
||||
when it has a value of `administrative`. Objects with `highway` tags are
|
||||
always included. However when the value is `street_lamp` then the object
|
||||
must have a name, too. With any other value, the object is included
|
||||
independently of the name. Finally, if a `landuse` tag is present then
|
||||
it will be used independely of the concrete value if neither boundary
|
||||
nor highway tags were found and the object is named.
|
||||
|
||||
* `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.
|
||||
#### `set_prefilters()` - ignoring tags
|
||||
|
||||
* `name`
|
||||
Pre-filtering of tags allows to ignore them for any further processing.
|
||||
Thus pre-filtering takes precedence over any other tag processing. This is
|
||||
useful when some specific key/value combinations need to be excluded from
|
||||
processing. When tags are filtered, they may either be deleted completely
|
||||
or moved to `extratags`. Extra tags are saved with the object and returned
|
||||
to the user when requested, but are not used otherwise.
|
||||
|
||||
Add tag to the list of names.
|
||||
`set_prefilters()` takes a table with four optional fields:
|
||||
|
||||
* `ref`
|
||||
* __delete_keys__ is a _key match list_ for tags that should be deleted
|
||||
* __delete_tags__ contains a table of tag keys pointing to a list of tag
|
||||
values. Tags with matching key/value pairs are deleted.
|
||||
* __extra_keys__ is a _key match list_ for tags which should be saved into
|
||||
extratags
|
||||
* __extra_tags__ contains a table of tag keys pointing to a list of tag
|
||||
values. Tags with matching key/value pairs are moved to extratags.
|
||||
|
||||
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`.
|
||||
Key list may contain three kinds of strings:
|
||||
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 is matched exactly against tag keys.
|
||||
|
||||
* `address`
|
||||
!!! example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
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.
|
||||
flex.set_prefilters{
|
||||
delete_keys = {'source', 'source:*'},
|
||||
extra_tags = {amenity = {'yes', 'no'}}
|
||||
}
|
||||
flex.set_main_tags{
|
||||
amenity = 'always'
|
||||
}
|
||||
```
|
||||
|
||||
* `postcode`
|
||||
In this example any tags `source` and tags that begin with `source:` are
|
||||
deleted before any other processing is done. Getting rid of frequent tags
|
||||
this way can speed up the import.
|
||||
|
||||
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.
|
||||
Tags with `amenity=yes` or `amenity=no` are moved to extratags. Later
|
||||
all tags with an `amenity` key are made a main tag. This effectively means
|
||||
that Nominatim will use all amenity tags except for those with value
|
||||
yes and no.
|
||||
|
||||
* `country`
|
||||
#### `set_name_tags()` - defining names
|
||||
|
||||
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.
|
||||
The flex script distinguishes between two kinds of names:
|
||||
|
||||
* `house`
|
||||
* __main__: the primary names make an object fully searchable.
|
||||
Main tags of type _named_ will only cause the object to be included when
|
||||
such a primary name is present. Primary names are usually those found
|
||||
in the `name` tag and its variants.
|
||||
* __extra__: extra names are still added to the search index but they are
|
||||
alone not sufficient to make an object named.
|
||||
|
||||
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.
|
||||
`set_name_tags()` takes a table with two optional fields `main` and `extra`.
|
||||
They take _key match lists_ for main and extra names respectively.
|
||||
|
||||
* `interpolation`
|
||||
!!! example
|
||||
``` lua
|
||||
local flex = require('flex-base')
|
||||
|
||||
Add this object as an address interpolation (appears as `class`=`place` and
|
||||
`type`=`houses` in the database).
|
||||
flex.set_main_tags{highway = {traffic_light = 'named'}}
|
||||
flex.set_name_tags{main = {'name', 'name:*'},
|
||||
extra = {'ref'}
|
||||
}
|
||||
```
|
||||
|
||||
* `extra`
|
||||
This example creates a search index over traffic lights but will
|
||||
only include those that have a common name and not those which just
|
||||
have some reference ID from the city.
|
||||
|
||||
Add tag to the list of extra tags.
|
||||
#### `set_address_tags()` - defining address parts
|
||||
|
||||
* `skip`
|
||||
Address tags will be used to build up the address of an object.
|
||||
|
||||
Skip the tag completely. Useful when a custom default fallback is defined
|
||||
or to define exceptions to rules.
|
||||
`set_address_tags()` takes a table with arbitrary fields pointing to
|
||||
_key match lists_. To fields have a special meaning:
|
||||
|
||||
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.
|
||||
* __main__: defines
|
||||
the tags that make a full address object out of the OSM object. This
|
||||
is usually the housenumber or variants thereof. If a main address tag
|
||||
appears, then the object will always be included, if necessary with a
|
||||
fallback of `place=house`. If the key has a prefix of `addr:` or `is_in:`
|
||||
this will be stripped.
|
||||
|
||||
* __extra__: defines all supplementary tags for addresses, tags like `addr:street`, `addr:city` etc. If the key has a prefix of `addr:` or `is_in:` this will be stripped.
|
||||
|
||||
All other fields will be handled as summary fields. If a key matches the
|
||||
key match list, then its value will be added to the address tags with the
|
||||
name of the field as key. If multiple tags match, then an arbitrary one
|
||||
wins.
|
||||
|
||||
Country tags are handled slightly special. Only tags with a two-letter code
|
||||
are accepted, all other values are discarded.
|
||||
|
||||
!!! example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
flex.set_address_tags{
|
||||
main = {'addr:housenumber'},
|
||||
extra = {'addr:*'},
|
||||
postcode = {'postal_code', 'postcode', 'addr:postcode'},
|
||||
country = {'country-code', 'ISO3166-1'}
|
||||
}
|
||||
```
|
||||
|
||||
In this example all tags which begin with `addr:` will be saved in
|
||||
the address tag list. If one of the tags is `addr:housenumber`, the
|
||||
object will fall back to be entered as a `place=house` in the database
|
||||
unless there is another interested main tag to be found.
|
||||
|
||||
Tags with keys `country-code` and `ISO3166-1` are saved with their
|
||||
value under `country` in the address tag list. The same thing happens
|
||||
to postcodes, they will always be saved under the key `postcode` thus
|
||||
normalizing the multitude of keys that are used in the OSM database.
|
||||
|
||||
|
||||
#### `set_unused_handling()` - processing remaining tags
|
||||
|
||||
This function defines what to do with tags that remain after all tags
|
||||
have been classified using the functions above. There are two ways in
|
||||
which the function can be used:
|
||||
|
||||
`set_unused_handling(delete_keys = ..., delete_tags = ...)` deletes all
|
||||
keys that match the descriptions in the parameters and moves all remaining
|
||||
tags into the extratags list.
|
||||
`set_unused_handling(extra_keys = ..., extra_tags = ...)` moves all tags
|
||||
matching the parameters into the extratags list and then deletes the remaining
|
||||
tags. For the format of the parameters see the description in `set_prefilters()`
|
||||
above.
|
||||
|
||||
!!! example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
flex.set_address_tags{
|
||||
main = {'addr:housenumber'},
|
||||
extra = {'addr:*', 'tiger:county'}
|
||||
}
|
||||
flex.set_unused_handling{delete_keys = {'tiger:*'}}
|
||||
```
|
||||
|
||||
In this example all remaining tags except those beginning with `tiger:`
|
||||
are moved to the extratags list. Note that it is not possible to
|
||||
already delete the tiger tags with `set_prefilters()` because that
|
||||
would remove tiger:county before the address tags are processed.
|
||||
|
||||
### Customizing osm2pgsql callbacks
|
||||
|
||||
osm2pgsql expects the flex style to implement three callbacks, one process
|
||||
function per OSM type. If you want to implement special handling for
|
||||
certain OSM types, you can override the default implementations provided
|
||||
by the flex-base module.
|
||||
|
||||
#### Changing the relation types to be handled
|
||||
|
||||
The default scripts only allows relations of type `multipolygon`, `boundary`
|
||||
and `waterway`. To add other types relations, set `RELATION_TYPES` for
|
||||
the type to the kind of geometry that should be created. The following
|
||||
kinds of geometries can be used:
|
||||
|
||||
* __relation_as_multipolygon__ creates a (Multi)Polygon from the ways in
|
||||
the relation. If the ways do not form a valid area, then the object is
|
||||
silently discarded.
|
||||
* __relation_as_multiline__ creates a (Mutli)LineString from the ways in
|
||||
the relations. Ways are combined as much as possible without any regards
|
||||
to their order in the relation.
|
||||
|
||||
!!! Example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
flex.RELATION_TYPES['site'] = flex.relation_as_multipolygon
|
||||
```
|
||||
|
||||
With this line relations of `type=site` will be included in the index
|
||||
according to main tags found. This only works when the site relation
|
||||
resolves to a valid area. Nodes in the site relation are not part of the
|
||||
geometry.
|
||||
|
||||
|
||||
#### Adding additional logic to processing functions
|
||||
|
||||
The default processing functions are also exported by the flex-base module
|
||||
as `process_node`, `process_way` and `process_relation`. These can be used
|
||||
to implement your own processing functions with some additional processing
|
||||
logic.
|
||||
|
||||
!!! Example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
function osm2pgsql.process_relation(object)
|
||||
if object.tags.boundary ~= 'administrative' or object.tags.admin_level ~= '2' then
|
||||
flex.process_relation(object)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
This example discards all country-level boundaries and uses standard
|
||||
handling for everything else. This can be useful if you want to use
|
||||
your own custom country boundaries.
|
||||
|
||||
|
||||
### Customizing the main processing function
|
||||
|
||||
The main processing function of the flex style can be found in the function
|
||||
`process_tags`. This function is called for all OSM object kinds and is
|
||||
responsible for filtering the tags and writing out the rows into Postgresql.
|
||||
|
||||
!!! Example
|
||||
``` lua
|
||||
local flex = require('import-full')
|
||||
|
||||
local original_process_tags = flex.process_tags
|
||||
|
||||
function flex.process_tags(o)
|
||||
if o.object.tags.highway ~= nil and o.object.tags.access == 'no' then
|
||||
return
|
||||
end
|
||||
|
||||
original_process_tags(o)
|
||||
end
|
||||
```
|
||||
|
||||
This example shows the most simple customization of the process_tags function.
|
||||
It simply adds some additional processing before running the original code.
|
||||
To do that, first save the original function and then overwrite process_tags
|
||||
from the module. In this example all highways which are not accessible
|
||||
by anyone will be ignored.
|
||||
|
||||
|
||||
#### The `Place` class
|
||||
|
||||
The `process_tags` function receives a Lua object of `Place` type which comes
|
||||
with some handy functions to collect the data necessary for geocoding and
|
||||
writing it into the place table. Always use this object to fill the table.
|
||||
|
||||
The Place class has some attributes which you may access read-only:
|
||||
|
||||
* __object__ is the original OSM object data handed in by osm2pgsql
|
||||
* __admin_level__ is the content of the admin_level tag, parsed into an
|
||||
integer and normalized to a value between 0 and 15
|
||||
* __has_name__ is a boolean indicating if the object has a full name
|
||||
* __names__ is a table with the collected list of name tags
|
||||
* __address__ is a table with the collected list of address tags
|
||||
* __extratags__ is a table with the collected list of additional tags to save
|
||||
|
||||
There are a number of functions to fill these fields. All functions expect
|
||||
a table parameter with fields as indicated in the description.
|
||||
Many of these functions expect match functions which are described in detail
|
||||
further below.
|
||||
|
||||
* __delete{match=...}__ removes all tags that match the match function given
|
||||
in _match_.
|
||||
* __grab_extratags{match=...}__ moves all tags that match the match function
|
||||
given in _match_ into extratags. Returns the number of tags moved.
|
||||
* __clean{delete=..., extra=...}__ deletes all tags that match _delete_ and
|
||||
moves the ones that match _extra_ into extratags
|
||||
* __grab_address_parts{groups=...}__ moves matching tags into the address table.
|
||||
_groups_ must be a group match function. Tags of the group `main` and
|
||||
`extra` are added to the address table as is but with `addr:` and `is_in:`
|
||||
prefixes removed from the tag key. All other groups are added with the
|
||||
group name as key and the value from the tag. Multiple values of the same
|
||||
group overwrite each other. The function returns the number of tags saved
|
||||
from the main group.
|
||||
* __grab_main_parts{groups=...}__ moves matching tags into the name table.
|
||||
_groups_ must be a group match function. If a tags of the group `main` is
|
||||
present, the object will be marked as having a name. Tags of group `house`
|
||||
produce a fallback to `place=house`. This fallback is return by the function
|
||||
if present.
|
||||
|
||||
There are two functions to write a row into the place table. Both functions
|
||||
expect the main tag (key and value) for the row and then use the collected
|
||||
information from the name, address, extratags etc. fields to complete the row.
|
||||
They also have a boolean parameter `save_extra_mains` which defines how any
|
||||
unprocessed tags are handled: when True, the tags will be saved as extratags,
|
||||
when False, they will be simply discarded.
|
||||
|
||||
* __write_row(key, value, save_extra_mains)__ creates a new table row from
|
||||
the current state of the Place object.
|
||||
* __write_place(key, value, mtype, save_extra_mains)__ creates a new row
|
||||
conditionally. When value is nil, the function will attempt to look up the
|
||||
value in the object tags. If value is still nil or mtype is nil, the row
|
||||
is ignored. An mtype of `always` will then always write out the row,
|
||||
a mtype of `named` only, when the object has a full name. When mtype
|
||||
is `named_with_key`, the function checks for a domain name, i.e. a name
|
||||
tag prefixed with the name of the main key. Only if at least one is found,
|
||||
the row will be written. The names are replaced with the domain names found.
|
||||
|
||||
#### Match functions
|
||||
|
||||
The Place functions usually expect either a _match function_ or a
|
||||
_group match function_ to find the tags to apply their function to.
|
||||
|
||||
The __match function__ is a Lua function which takes two parameters,
|
||||
key and value, and returns a boolean to indicate that a tag matches. The
|
||||
flex-base module has a convenience function `tag_match()` to create such a
|
||||
function. It takes a table with two optional fields: `keys` takes a key match
|
||||
list (see above), `tags` takes a table with keys that point to a list of
|
||||
possible values, thus defining key/value matches.
|
||||
|
||||
The __group match function__ is a Lua function which also takes two parameters,
|
||||
key and value, and returns a string indicating to which group or type they
|
||||
belong to. The `tag_group()` can be used to create such a function. It expects
|
||||
a table where the group names are the keys and the values are a key match list.
|
||||
|
||||
|
||||
|
||||
### Using the gazetteer output of osm2pgsql
|
||||
|
||||
Nominatim still allows you to configure the gazetteer output to remain
|
||||
backwards compatible with older imports. It will be automatically used
|
||||
when the style file name ends in `.style`. For documentation of the
|
||||
old import style, please refer to the documentation of older releases
|
||||
of Nominatim. Do not use the gazetteer output for new imports. There is no
|
||||
guarantee that new versions of Nominatim are fully compatible with the
|
||||
gazetteer output.
|
||||
|
||||
### Changing the Style of Existing Databases
|
||||
|
||||
|
||||
49
docs/customize/Importance.md
Normal file
49
docs/customize/Importance.md
Normal file
@@ -0,0 +1,49 @@
|
||||
## Importance
|
||||
|
||||
Search requests can yield multiple results which match equally well with
|
||||
the original query. In such case Nominatim needs to order the results
|
||||
according to a different criterion: importance. This is a measure for how
|
||||
likely it is that a user will search for a given place. This section explains
|
||||
the sources Nominatim uses for computing importance of a place and how to
|
||||
customize them.
|
||||
|
||||
### How importance is computed
|
||||
|
||||
The main value for importance is derived from page ranking values for Wikipedia
|
||||
pages for a place. For places that do not have their own
|
||||
Wikipedia page, a formula is used that derives a static importance from the
|
||||
places [search rank](../customize/Ranking.md#search-rank).
|
||||
|
||||
In a second step, a secondary importance value is added which is meant to
|
||||
represent how well-known the general area is where the place is located. It
|
||||
functions as a tie-breaker between places with very similar primary
|
||||
importance values.
|
||||
|
||||
nominatim.org has preprocessed importance tables for the
|
||||
[primary Wikipedia rankings](https://nominatim.org/data/wikimedia-importance.sql.gz)
|
||||
and for a secondary importance based on the number of tile views on openstreetmap.org.
|
||||
|
||||
### Customizing secondary importance
|
||||
|
||||
The secondary importance is implemented as a simple
|
||||
[Postgis raster](https://postgis.net/docs/raster.html) table, where Nominatim
|
||||
looks up the value for the coordinates of the centroid of a place. You can
|
||||
provide your own secondary importance raster in form of an SQL file named
|
||||
`secondary_importance.sql.gz` in your project directory.
|
||||
|
||||
The SQL file needs to drop and (re)create a table `secondary_importance` which
|
||||
must as a minimum contain a column `rast` of type `raster`. The raster must
|
||||
be in EPSG:4326 and contain 16bit unsigned ints
|
||||
(`raster_constraint_pixel_types(rast) = '{16BUI}'). Any other columns in the
|
||||
table will be ignored. You must furthermore create an index as follows:
|
||||
|
||||
```
|
||||
CREATE INDEX ON secondary_importance USING gist(ST_ConvexHull(gist))
|
||||
```
|
||||
|
||||
The following raster2pgsql command will create a table that conforms to
|
||||
the requirements:
|
||||
|
||||
```
|
||||
raster2pgsql -I -C -Y -d -t 128x128 input.tiff public.secondary_importance
|
||||
```
|
||||
@@ -91,7 +91,7 @@ The option is only used by the Legacy tokenizer and ignored otherwise.
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Tokenizer used for normalizing and parsing queries and names |
|
||||
| **Format:** | string |
|
||||
| **Default:** | legacy |
|
||||
| **Default:** | icu |
|
||||
| **After Changes:** | cannot be changed after import |
|
||||
|
||||
Sets the tokenizer type to use for the import. For more information on
|
||||
@@ -189,7 +189,7 @@ will be used.
|
||||
| **Description:** | Enable searching for Tiger house number data |
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | no |
|
||||
| **After Changes:** | run `nominatim --refresh --functions` |
|
||||
| **After Changes:** | run `nominatim refresh --functions` |
|
||||
|
||||
When this setting is enabled, search and reverse queries also take data
|
||||
from [Tiger house number data](Tiger.md) into account.
|
||||
@@ -202,7 +202,7 @@ from [Tiger house number data](Tiger.md) into account.
|
||||
| **Description:** | Enable searching in external house number tables |
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | no |
|
||||
| **After Changes:** | run `nominatim --refresh --functions` |
|
||||
| **After Changes:** | run `nominatim refresh --functions` |
|
||||
| **Comment:** | Do not use. |
|
||||
|
||||
When this setting is enabled, search queries also take data from external
|
||||
@@ -552,6 +552,8 @@ used.
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | no |
|
||||
| **After Changes:** | run `nominatim refresh --website` |
|
||||
| **Comment:** | PHP frontend only |
|
||||
|
||||
|
||||
This feature is currently undocumented and potentially broken.
|
||||
|
||||
@@ -564,6 +566,7 @@ This feature is currently undocumented and potentially broken.
|
||||
| **Format:** | integer |
|
||||
| **Default:** | 500 |
|
||||
| **After Changes:** | run `nominatim refresh --website` |
|
||||
| **Comment:** | PHP frontend only |
|
||||
|
||||
This setting defines the threshold over which a name is no longer considered
|
||||
as rare. When searching for places with rare names, only the name is used
|
||||
@@ -604,6 +607,88 @@ with a single query.
|
||||
|
||||
Setting this parameter to 0 disables polygon output completely.
|
||||
|
||||
|
||||
#### NOMINATIM_SEARCH_WITHIN_COUNTRIES
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Disable search for elements that are not in the country grid |
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | no |
|
||||
| **After Changes:** | run `nominatim refresh --website` |
|
||||
| **Comment:** | PHP frontend only |
|
||||
|
||||
Enable to search elements just within countries.
|
||||
|
||||
When enabled, if, despite not finding a point within the static grid of countries, it
|
||||
finds a geometry of a region, do not return the geometry.
|
||||
Return "Unable to geocode" instead.
|
||||
|
||||
|
||||
#### NOMINATIM_SERVE_LEGACY_URLS
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Enable serving via URLs with a .php suffix |
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | yes |
|
||||
| **Comment:** | Python frontend only |
|
||||
|
||||
When enabled, then endpoints are reachable as `/<name>` as well as `/<name>.php`.
|
||||
This can be useful when you want to be backwards-compatible with previous
|
||||
versions of Nominatim.
|
||||
|
||||
|
||||
#### NOMINATIM_API_POOL_SIZE
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Number of parallel database connections per worker |
|
||||
| **Format:** | number |
|
||||
| **Default:** | 10 |
|
||||
| **Comment:** | Python frontend only |
|
||||
|
||||
Sets the maximum number of database connections available for a single instance
|
||||
of Nominatim. When configuring the maximum number of connections that your
|
||||
PostgreSQL database can handle, you need at least
|
||||
`NOMINATIM_API_POOL_SIZE` * `<number of configured workers>` connections.
|
||||
For configuring the number of workers, refer to the section about
|
||||
[Deploying the Python frontend](../admin/Deployment-Python.md).
|
||||
|
||||
#### NOMINATIM_QUERY_TIMEOUT
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Timeout for SQL queries to the database |
|
||||
| **Format:** | number (seconds) |
|
||||
| **Default:** | 10 |
|
||||
| **Comment:** | Python frontend only |
|
||||
|
||||
When this timeout is set, then all SQL queries that run longer than the
|
||||
specified numbers of seconds will be cancelled and the user receives a
|
||||
timeout exceptions. Users of the API see a 503 HTTP error.
|
||||
|
||||
The timeout does ont apply when using the
|
||||
[low-level DB access](../library/Low-Level-DB-Access.md)
|
||||
of the library. A timeout can be manually set, if required.
|
||||
|
||||
|
||||
#### NOMINATIM_REQUEST_TIMEOUT
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Timeout for search queries |
|
||||
| **Format:** | number (seconds) |
|
||||
| **Default:** | 60 |
|
||||
| **Comment:** | Python frontend only |
|
||||
|
||||
When this timeout is set, a search query will finish sending queries
|
||||
to the database after the timeout has passed and immediately return the
|
||||
results gathered so far.
|
||||
|
||||
Note that under high load you may observe that users receive different results
|
||||
than usual without seeing an error. This may cause some confusion.
|
||||
|
||||
### Logging Settings
|
||||
|
||||
#### NOMINATIM_LOG_DB
|
||||
@@ -643,7 +728,24 @@ The entries in the log file have the following format:
|
||||
<request time> <execution time in s> <number of results> <type> "<query string>"
|
||||
|
||||
Request time is the time when the request was started. The execution time is
|
||||
given in ms and corresponds to the time the query took executing in PHP.
|
||||
given in seconds and corresponds to the time the query took executing in PHP.
|
||||
type contains the name of the endpoint used.
|
||||
|
||||
Can be used as the same time as NOMINATIM_LOG_DB.
|
||||
|
||||
#### NOMINATIM_DEBUG_SQL
|
||||
|
||||
| Summary | |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| **Description:** | Enable printing of raw SQL by SQLAlchemy |
|
||||
| **Format:** | boolean |
|
||||
| **Default:** | no |
|
||||
| **Comment:** | **For developers only.** |
|
||||
|
||||
This settings enables
|
||||
[SQL debugging](https://docs.sqlalchemy.org/en/20/core/engines.html#dbengine-logging)
|
||||
by SQLAlchemy. This can be helpful when debugging some bugs with internal
|
||||
query handling. It should only be used together with the CLI query functions.
|
||||
Enabling it for server mode may have unintended consequences. Use the `debug`
|
||||
parameter instead, which prints information on how the search is executed
|
||||
including SQL statements.
|
||||
|
||||
@@ -5,22 +5,22 @@ 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 2021 data:
|
||||
1. Get preprocessed TIGER data:
|
||||
|
||||
cd $PROJECT_DIR
|
||||
wget https://nominatim.org/data/tiger2021-nominatim-preprocessed.csv.tar.gz
|
||||
wget https://nominatim.org/data/tiger-nominatim-preprocessed-latest.csv.tar.gz
|
||||
|
||||
2. Import the data into your Nominatim database:
|
||||
|
||||
nominatim add-data --tiger-data tiger2021-nominatim-preprocessed.csv.tar.gz
|
||||
nominatim add-data --tiger-data tiger-nominatim-preprocessed-latest.csv.tar.gz
|
||||
|
||||
3. Enable use of the Tiger data in your `.env` by adding:
|
||||
3. Enable use of the Tiger data in your existing `.env` file by adding:
|
||||
|
||||
echo NOMINATIM_USE_US_TIGER_DATA=yes >> .env
|
||||
|
||||
4. Apply the new settings:
|
||||
|
||||
nominatim refresh --functions
|
||||
nominatim refresh --functions --website
|
||||
|
||||
|
||||
See the [TIGER-data project](https://github.com/osm-search/TIGER-data) for more
|
||||
|
||||
@@ -19,7 +19,22 @@ they can be configured.
|
||||
|
||||
The legacy tokenizer implements the analysis algorithms of older Nominatim
|
||||
versions. It uses a special Postgresql module to normalize names and queries.
|
||||
This tokenizer is currently the default.
|
||||
This tokenizer is automatically installed and used when upgrading an older
|
||||
database. It should not be used for new installations anymore.
|
||||
|
||||
### Compiling the PostgreSQL module
|
||||
|
||||
The tokeinzer needs a special C module for PostgreSQL which is not compiled
|
||||
by default. If you need the legacy tokenizer, compile Nominatim as follows:
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_MODULE=on
|
||||
make
|
||||
```
|
||||
|
||||
### Enabling the tokenizer
|
||||
|
||||
To enable the tokenizer add the following line to your project configuration:
|
||||
|
||||
@@ -47,6 +62,7 @@ normalization functions are hard-coded.
|
||||
The ICU tokenizer uses the [ICU library](http://site.icu-project.org/) to
|
||||
normalize names and queries. It also offers configurable decomposition and
|
||||
abbreviation handling.
|
||||
This tokenizer is currently the default.
|
||||
|
||||
To enable the tokenizer add the following line to your project configuration:
|
||||
|
||||
@@ -86,7 +102,7 @@ Here is an example configuration file:
|
||||
``` yaml
|
||||
normalization:
|
||||
- ":: lower ()"
|
||||
- "ß > 'ss'" # German szet is unimbigiously equal to double ss
|
||||
- "ß > 'ss'" # German szet is unambiguously equal to double ss
|
||||
transliteration:
|
||||
- !include /etc/nominatim/icu-rules/extended-unicode-to-asccii.yaml
|
||||
- ":: Ascii ()"
|
||||
@@ -99,6 +115,9 @@ token-analysis:
|
||||
- words:
|
||||
- road -> rd
|
||||
- bridge -> bdge,br,brdg,bri,brg
|
||||
mutations:
|
||||
- pattern: 'ä'
|
||||
replacements: ['ä', 'ae']
|
||||
```
|
||||
|
||||
The configuration file contains four sections:
|
||||
@@ -109,7 +128,7 @@ The configuration file contains four sections:
|
||||
The normalization and transliteration sections each define a set of
|
||||
ICU rules that are applied to the names.
|
||||
|
||||
The **normalisation** rules are applied after sanitation. They should remove
|
||||
The **normalization** rules are applied after sanitation. They should remove
|
||||
any information that is not relevant for search at all. Usual rules to be
|
||||
applied here are: lower-casing, removing of special characters, cleanup of
|
||||
spaces.
|
||||
@@ -157,28 +176,66 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
##### split-name-list
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.split_name_list
|
||||
selection:
|
||||
options:
|
||||
members: False
|
||||
rendering:
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
##### strip-brace-terms
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.strip_brace_terms
|
||||
selection:
|
||||
options:
|
||||
members: False
|
||||
rendering:
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
##### tag-analyzer-by-language
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.tag_analyzer_by_language
|
||||
selection:
|
||||
options:
|
||||
members: False
|
||||
rendering:
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
##### clean-housenumbers
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_housenumbers
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
##### clean-postcodes
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_postcodes
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
##### clean-tiger-tags
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_tiger_tags
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
#### delete-tags
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.delete_tags
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
#### tag-japanese
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.tag_japanese
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
docstring_section_style: spacy
|
||||
|
||||
#### Token Analysis
|
||||
|
||||
@@ -196,21 +253,25 @@ by a sanitizer (see for example the
|
||||
The token-analysis section contains the list of configured analyzers. Each
|
||||
analyzer must have an `id` parameter that uniquely identifies the analyzer.
|
||||
The only exception is the default analyzer that is used when no special
|
||||
analyzer was selected.
|
||||
analyzer was selected. There are analysers with special ids:
|
||||
|
||||
* '@housenumber'. If an analyzer with that name is present, it is used
|
||||
for normalization of house numbers.
|
||||
* '@potcode'. If an analyzer with that name is present, it is used
|
||||
for normalization of postcodes.
|
||||
|
||||
Different analyzer implementations may exist. To select the implementation,
|
||||
the `analyzer` parameter must be set. Currently there is only one implementation
|
||||
`generic` which is described in the following.
|
||||
the `analyzer` parameter must be set. The different implementations are
|
||||
described in the following.
|
||||
|
||||
##### Generic token analyzer
|
||||
|
||||
The generic analyzer is able to create variants from a list of given
|
||||
abbreviation and decomposition replacements. It takes one optional parameter
|
||||
`variants` which lists the replacements to apply. If the section is
|
||||
omitted, then the generic analyzer becomes a simple analyzer that only
|
||||
applies the transliteration.
|
||||
The generic analyzer `generic` is able to create variants from a list of given
|
||||
abbreviation and decomposition replacements and introduce spelling variations.
|
||||
|
||||
The variants section defines lists of replacements which create alternative
|
||||
###### Variants
|
||||
|
||||
The optional 'variants' section defines lists of replacements which create alternative
|
||||
spellings of a name. To create the variants, a name is scanned from left to
|
||||
right and the longest matching replacement is applied until the end of the
|
||||
string is reached.
|
||||
@@ -296,6 +357,48 @@ decomposition has an effect here on the source as well. So a rule
|
||||
means that for a word like `hauptstrasse` four variants are created:
|
||||
`hauptstrasse`, `haupt strasse`, `hauptstr` and `haupt str`.
|
||||
|
||||
###### Mutations
|
||||
|
||||
The 'mutation' section in the configuration describes an additional set of
|
||||
replacements to be applied after the variants have been computed.
|
||||
|
||||
Each mutation is described by two parameters: `pattern` and `replacements`.
|
||||
The pattern must contain a single regular expression to search for in the
|
||||
variant name. The regular expressions need to follow the syntax for
|
||||
[Python regular expressions](file:///usr/share/doc/python3-doc/html/library/re.html#regular-expression-syntax).
|
||||
Capturing groups are not permitted.
|
||||
`replacements` must contain a list of strings that the pattern
|
||||
should be replaced with. Each occurrence of the pattern is replaced with
|
||||
all given replacements. Be mindful of combinatorial explosion of variants.
|
||||
|
||||
###### Modes
|
||||
|
||||
The generic analyser supports a special mode `variant-only`. When configured
|
||||
then it consumes the input token and emits only variants (if any exist). Enable
|
||||
the mode by adding:
|
||||
|
||||
```
|
||||
mode: variant-only
|
||||
```
|
||||
|
||||
to the analyser configuration.
|
||||
|
||||
##### Housenumber token analyzer
|
||||
|
||||
The analyzer `housenumbers` is purpose-made to analyze house numbers. It
|
||||
creates variants with optional spaces between numbers and letters. Thus,
|
||||
house numbers of the form '3 a', '3A', '3-A' etc. are all considered equivalent.
|
||||
|
||||
The analyzer cannot be customized.
|
||||
|
||||
##### Postcode token analyzer
|
||||
|
||||
The analyzer `postcodes` is pupose-made to analyze postcodes. It supports
|
||||
a 'lookup' varaint of the token, which produces variants with optional
|
||||
spaces. Use together with the clean-postcodes sanitizer.
|
||||
|
||||
The analyzer cannot be customized.
|
||||
|
||||
### Reconfiguration
|
||||
|
||||
Changing the configuration after the import is currently not possible, although
|
||||
|
||||
@@ -119,7 +119,7 @@ to compute the address relations between places. These tables are partitioned.
|
||||
Each country is assigned a partition number in the country_name table (see
|
||||
below) and the data is then split between a set of tables, one for each
|
||||
partition. Note that Nominatim still manually manages partitioned tables.
|
||||
Native support for partitions in PostgreSQL only became useable with version 13.
|
||||
Native support for partitions in PostgreSQL only became usable with version 13.
|
||||
It will be a little while before Nominatim drops support for older versions.
|
||||
|
||||

|
||||
@@ -155,9 +155,9 @@ Nominatim also creates a number of static tables at import:
|
||||
default languages and saves the assignment of countries to partitions.
|
||||
* `country_osm_grid` provides a fallback for country geometries
|
||||
|
||||
## Auxilary data tables
|
||||
## Auxiliary data tables
|
||||
|
||||
Finally there are some table for auxillary data:
|
||||
Finally there are some table for auxiliary data:
|
||||
|
||||
* `location_property_tiger` - saves housenumber from the Tiger import. Its
|
||||
layout is similar to that of `location_propoerty_osmline`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Setting up Nominatim for Development
|
||||
|
||||
This chapter gives an overview how to set up Nominatim for developement
|
||||
This chapter gives an overview how to set up Nominatim for development
|
||||
and how to run tests.
|
||||
|
||||
!!! Important
|
||||
@@ -30,15 +30,25 @@ 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.6
|
||||
* [phpunit](https://phpunit.de) >= 7.3
|
||||
* [phpunit](https://phpunit.de) (9.5 is known to work)
|
||||
* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||
* [Pylint](https://pylint.org/) (2.6.0 is used for the CI)
|
||||
* [Pylint](https://pylint.org/) (CI always runs the latest version from pip)
|
||||
* [mypy](http://mypy-lang.org/) (plus typing information for external libs)
|
||||
* [Python Typing Extensions](https://github.com/python/typing_extensions) (for Python < 3.9)
|
||||
* [pytest](https://pytest.org)
|
||||
* [pytest-asyncio](https://pytest-asyncio.readthedocs.io)
|
||||
|
||||
For testing the Python search frontend, you need to install extra dependencies
|
||||
depending on your choice of webserver framework:
|
||||
|
||||
* [httpx](https://www.python-httpx.org/) (starlette only)
|
||||
* [asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan) (starlette only)
|
||||
|
||||
The documentation is built with mkdocs:
|
||||
|
||||
* [mkdocs](https://www.mkdocs.org/) >= 1.1.2
|
||||
* [mkdocstrings](https://mkdocstrings.github.io/)
|
||||
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.18
|
||||
* [mkdocstrings-python](https://mkdocstrings.github.io/python/)
|
||||
|
||||
### Installing prerequisites on Ubuntu/Debian
|
||||
|
||||
@@ -50,9 +60,12 @@ To install all necessary packages run:
|
||||
|
||||
```sh
|
||||
sudo apt install php-cgi phpunit php-codesniffer \
|
||||
python3-pip python3-setuptools python3-dev pylint
|
||||
python3-pip python3-setuptools python3-dev
|
||||
|
||||
pip3 install --user behave mkdocs mkdocstrings pytest
|
||||
pip3 install --user behave mkdocs mkdocstrings pytest pytest-asyncio pylint \
|
||||
mypy types-PyYAML types-jinja2 types-psycopg2 types-psutil \
|
||||
types-ujson types-requests types-Pygments typing-extensions\
|
||||
httpx asgi-lifespan
|
||||
```
|
||||
|
||||
The `mkdocs` executable will be located in `.local/bin`. You may have to add
|
||||
|
||||
220
docs/develop/ICU-Tokenizer-Modules.md
Normal file
220
docs/develop/ICU-Tokenizer-Modules.md
Normal file
@@ -0,0 +1,220 @@
|
||||
# Writing custom sanitizer and token analysis modules for the ICU tokenizer
|
||||
|
||||
The [ICU tokenizer](../customize/Tokenizers.md#icu-tokenizer) provides a
|
||||
highly customizable method to pre-process and normalize the name information
|
||||
of the input data before it is added to the search index. It comes with a
|
||||
selection of sanitizers and token analyzers which you can use to adapt your
|
||||
installation to your needs. If the provided modules are not enough, you can
|
||||
also provide your own implementations. This section describes the API
|
||||
of sanitizers and token analysis.
|
||||
|
||||
!!! warning
|
||||
This API is currently in early alpha status. While this API is meant to
|
||||
be a public API on which other sanitizers and token analyzers may be
|
||||
implemented, it is not guaranteed to be stable at the moment.
|
||||
|
||||
|
||||
## Using non-standard sanitizers and token analyzers
|
||||
|
||||
Sanitizer names (in the `step` property) and token analysis names (in the
|
||||
`analyzer`) may refer to externally supplied modules. There are two ways
|
||||
to include external modules: through a library or from the project directory.
|
||||
|
||||
To include a module from a library, use the absolute import path as name and
|
||||
make sure the library can be found in your PYTHONPATH.
|
||||
|
||||
To use a custom module without creating a library, you can put the module
|
||||
somewhere in your project directory and then use the relative path to the
|
||||
file. Include the whole name of the file including the `.py` ending.
|
||||
|
||||
## Custom sanitizer modules
|
||||
|
||||
A sanitizer module must export a single factory function `create` with the
|
||||
following signature:
|
||||
|
||||
``` python
|
||||
def create(config: SanitizerConfig) -> Callable[[ProcessInfo], None]
|
||||
```
|
||||
|
||||
The function receives the custom configuration for the sanitizer and must
|
||||
return a callable (function or class) that transforms the name and address
|
||||
terms of a place. When a place is processed, then a `ProcessInfo` object
|
||||
is created from the information that was queried from the database. This
|
||||
object is sequentially handed to each configured sanitizer, so that each
|
||||
sanitizer receives the result of processing from the previous sanitizer.
|
||||
After the last sanitizer is finished, the resulting name and address lists
|
||||
are forwarded to the token analysis module.
|
||||
|
||||
Sanitizer functions are instantiated once and then called for each place
|
||||
that is imported or updated. They don't need to be thread-safe.
|
||||
If multi-threading is used, each thread creates their own instance of
|
||||
the function.
|
||||
|
||||
### Sanitizer configuration
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.config.SanitizerConfig
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### The main filter function of the sanitizer
|
||||
|
||||
The filter function receives a single object of type `ProcessInfo`
|
||||
which has with three members:
|
||||
|
||||
* `place: PlaceInfo`: read-only information about the place being processed.
|
||||
See PlaceInfo below.
|
||||
* `names: List[PlaceName]`: The current list of names for the place.
|
||||
* `address: List[PlaceName]`: The current list of address names for the place.
|
||||
|
||||
While the `place` member is provided for information only, the `names` and
|
||||
`address` lists are meant to be manipulated by the sanitizer. It may add and
|
||||
remove entries, change information within a single entry (for example by
|
||||
adding extra attributes) or completely replace the list with a different one.
|
||||
|
||||
#### PlaceInfo - information about the place
|
||||
|
||||
::: nominatim.data.place_info.PlaceInfo
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
||||
#### PlaceName - extended naming information
|
||||
|
||||
::: nominatim.data.place_name.PlaceName
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
||||
### Example: Filter for US street prefixes
|
||||
|
||||
The following sanitizer removes the directional prefixes from street names
|
||||
in the US:
|
||||
|
||||
``` python
|
||||
import re
|
||||
|
||||
def _filter_function(obj):
|
||||
if obj.place.country_code == 'us' \
|
||||
and obj.place.rank_address >= 26 and obj.place.rank_address <= 27:
|
||||
for name in obj.names:
|
||||
name.name = re.sub(r'^(north|south|west|east) ',
|
||||
'',
|
||||
name.name,
|
||||
flags=re.IGNORECASE)
|
||||
|
||||
def create(config):
|
||||
return _filter_function
|
||||
```
|
||||
|
||||
This is the most simple form of a sanitizer module. If defines a single
|
||||
filter function and implements the required `create()` function by returning
|
||||
the filter.
|
||||
|
||||
The filter function first checks if the object is interesting for the
|
||||
sanitizer. Namely it checks if the place is in the US (through `country_code`)
|
||||
and it the place is a street (a `rank_address` of 26 or 27). If the
|
||||
conditions are met, then it goes through all available names and
|
||||
removes any leading directional prefix using a simple regular expression.
|
||||
|
||||
Save the source code in a file in your project directory, for example as
|
||||
`us_streets.py`. Then you can use the sanitizer in your `icu_tokenizer.yaml`:
|
||||
|
||||
``` yaml
|
||||
...
|
||||
sanitizers:
|
||||
- step: us_streets.py
|
||||
...
|
||||
```
|
||||
|
||||
!!! warning
|
||||
This example is just a simplified show case on how to create a sanitizer.
|
||||
It is not really read for real-world use: while the sanitizer would
|
||||
correcly transform `West 5th Street` into `5th Street`. it would also
|
||||
shorten a simple `North Street` to `Street`.
|
||||
|
||||
For more sanitizer examples, have a look at the sanitizers provided by Nominatim.
|
||||
They can be found in the directory
|
||||
[`nominatim/tokenizer/sanitizers`](https://github.com/osm-search/Nominatim/tree/master/nominatim/tokenizer/sanitizers).
|
||||
|
||||
|
||||
## Custom token analysis module
|
||||
|
||||
::: nominatim.tokenizer.token_analysis.base.AnalysisModule
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
||||
::: nominatim.tokenizer.token_analysis.base.Analyzer
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### Example: Creating acronym variants for long names
|
||||
|
||||
The following example of a token analysis module creates acronyms from
|
||||
very long names and adds them as a variant:
|
||||
|
||||
``` python
|
||||
class AcronymMaker:
|
||||
""" This class is the actual analyzer.
|
||||
"""
|
||||
def __init__(self, norm, trans):
|
||||
self.norm = norm
|
||||
self.trans = trans
|
||||
|
||||
|
||||
def get_canonical_id(self, name):
|
||||
# In simple cases, the normalized name can be used as a canonical id.
|
||||
return self.norm.transliterate(name.name).strip()
|
||||
|
||||
|
||||
def compute_variants(self, name):
|
||||
# The transliterated form of the name always makes up a variant.
|
||||
variants = [self.trans.transliterate(name)]
|
||||
|
||||
# Only create acronyms from very long words.
|
||||
if len(name) > 20:
|
||||
# Take the first letter from each word to form the acronym.
|
||||
acronym = ''.join(w[0] for w in name.split())
|
||||
# If that leds to an acronym with at least three letters,
|
||||
# add the resulting acronym as a variant.
|
||||
if len(acronym) > 2:
|
||||
# Never forget to transliterate the variants before returning them.
|
||||
variants.append(self.trans.transliterate(acronym))
|
||||
|
||||
return variants
|
||||
|
||||
# The following two functions are the module interface.
|
||||
|
||||
def configure(rules, normalizer, transliterator):
|
||||
# There is no configuration to parse and no data to set up.
|
||||
# Just return an empty configuration.
|
||||
return None
|
||||
|
||||
|
||||
def create(normalizer, transliterator, config):
|
||||
# Return a new instance of our token analysis class above.
|
||||
return AcronymMaker(normalizer, transliterator)
|
||||
```
|
||||
|
||||
Given the name `Trans-Siberian Railway`, the code above would return the full
|
||||
name `Trans-Siberian Railway` and the acronym `TSR` as variant, so that
|
||||
searching would work for both.
|
||||
|
||||
## Sanitizers vs. Token analysis - what to use for variants?
|
||||
|
||||
It is not always clear when to implement variations in the sanitizer and
|
||||
when to write a token analysis module. Just take the acronym example
|
||||
above: it would also have been possible to write a sanitizer which adds the
|
||||
acronym as an additional name to the name list. The result would have been
|
||||
similar. So which should be used when?
|
||||
|
||||
The most important thing to keep in mind is that variants created by the
|
||||
token analysis are only saved in the word lookup table. They do not need
|
||||
extra space in the search index. If there are many spelling variations, this
|
||||
can mean quite a significant amount of space is saved.
|
||||
|
||||
When creating additional names with a sanitizer, these names are completely
|
||||
independent. In particular, they can be fed into different token analysis
|
||||
modules. This gives a much greater flexibility but at the price that the
|
||||
additional names increase the size of the search index.
|
||||
|
||||
@@ -78,7 +78,7 @@ The inheritance is computed in the data preparation step.
|
||||
The prepared place information is handed to the tokenizer next. This is a
|
||||
Python module responsible for processing the names from both name and address
|
||||
terms and building up the word index from them. The process is explained in
|
||||
more detail in the [Tokenizer chapter](Tokenizer.md).
|
||||
more detail in the [Tokenizer chapter](Tokenizers.md).
|
||||
|
||||
### Address processing
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ This test directory is sturctured as follows:
|
||||
|
|
||||
+- php PHP unit tests
|
||||
+- python Python unit tests
|
||||
+- scenes Geometry test data
|
||||
+- testdb Base data for generating API test database
|
||||
+- testdata Additional test data used by unit tests
|
||||
```
|
||||
|
||||
## PHP Unit Tests (`test/php`)
|
||||
@@ -84,6 +84,8 @@ The tests can be configured with a set of environment variables (`behave -D key=
|
||||
* `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)
|
||||
* `API_ENGINE` - webframe to use for running search queries, same values as
|
||||
`nominatim serve --engine` parameter
|
||||
* `DB_HOST` - (optional) hostname of database host
|
||||
* `DB_PORT` - (optional) port of database on host
|
||||
* `DB_USER` - (optional) username of database login
|
||||
@@ -120,7 +122,7 @@ and compromises the following data:
|
||||
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
|
||||
#### Code Coverage (PHP engine only)
|
||||
|
||||
The API tests also support code coverage tests. You need to install
|
||||
[PHP_CodeCoverage](https://github.com/sebastianbergmann/php-code-coverage).
|
||||
@@ -153,7 +155,3 @@ needs superuser rights for postgres.
|
||||
|
||||
These tests check that data is imported correctly into the place table. They
|
||||
use the same template database as the 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.
|
||||
|
||||
@@ -93,7 +93,7 @@ for a custom tokenizer implementation.
|
||||
|
||||
Nominatim expects two files for a tokenizer:
|
||||
|
||||
* `nominiatim/tokenizer/<NAME>_tokenizer.py` containing the Python part of the
|
||||
* `nominatim/tokenizer/<NAME>_tokenizer.py` containing the Python part of the
|
||||
implementation
|
||||
* `lib-php/tokenizer/<NAME>_tokenizer.php` with the PHP part of the
|
||||
implementation
|
||||
@@ -105,7 +105,7 @@ functions. By convention, these should be placed in `lib-sql/tokenizer`.
|
||||
If the tokenizer has a default configuration file, this should be saved in
|
||||
the `settings/<NAME>_tokenizer.<SUFFIX>`.
|
||||
|
||||
### Configuration and Persistance
|
||||
### Configuration and Persistence
|
||||
|
||||
Tokenizers may define custom settings for their configuration. All settings
|
||||
must be prefixed with `NOMINATIM_TOKENIZER_`. Settings may be transient or
|
||||
@@ -134,14 +134,14 @@ All tokenizers must inherit from `nominatim.tokenizer.base.AbstractTokenizer`
|
||||
and implement the abstract functions defined there.
|
||||
|
||||
::: nominatim.tokenizer.base.AbstractTokenizer
|
||||
rendering:
|
||||
heading_level: 4
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### Python Analyzer Class
|
||||
|
||||
::: nominatim.tokenizer.base.AbstractAnalyzer
|
||||
rendering:
|
||||
heading_level: 4
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### PL/pgSQL Functions
|
||||
|
||||
@@ -189,6 +189,28 @@ a house number token text. If a place has multiple house numbers they must
|
||||
be listed with a semicolon as delimiter. Must be NULL when the place has no
|
||||
house numbers.
|
||||
|
||||
```sql
|
||||
FUNCTION token_is_street_address(info JSONB) RETURNS BOOLEAN
|
||||
```
|
||||
|
||||
Return true if this is an object that should be parented against a street.
|
||||
Only relevant for objects with address rank 30.
|
||||
|
||||
```sql
|
||||
FUNCTION token_has_addr_street(info JSONB) RETURNS BOOLEAN
|
||||
```
|
||||
|
||||
Return true if there are street names to match against for finding the
|
||||
parent of the object.
|
||||
|
||||
|
||||
```sql
|
||||
FUNCTION token_has_addr_place(info JSONB) RETURNS BOOLEAN
|
||||
```
|
||||
|
||||
Return true if there are place names to match against for finding the
|
||||
parent of the object.
|
||||
|
||||
```sql
|
||||
FUNCTION token_matches_street(info JSONB, street_tokens INTEGER[]) RETURNS BOOLEAN
|
||||
```
|
||||
@@ -245,11 +267,11 @@ Currently, tokenizers are encouraged to make sure that matching works against
|
||||
both the search token list and the match token list.
|
||||
|
||||
```sql
|
||||
FUNCTION token_normalized_postcode(postcode TEXT) RETURNS TEXT
|
||||
FUNCTION token_get_postcode(info JSONB) RETURNS TEXT
|
||||
```
|
||||
|
||||
Return the normalized version of the given postcode. This function must return
|
||||
the same value as the Python function `AbstractAnalyzer->normalize_postcode()`.
|
||||
Return the postcode for the object, if any exists. The postcode must be in
|
||||
the form that should also be presented to the end-user.
|
||||
|
||||
```sql
|
||||
FUNCTION token_strip_info(info JSONB) RETURNS JSONB
|
||||
|
||||
@@ -13,7 +13,7 @@ More details in [osm-search/country-grid-data](https://github.com/osm-search/cou
|
||||
|
||||
## US Census TIGER
|
||||
|
||||
For the United States you can choose to import additonal street-level data.
|
||||
For the United States you can choose to import additional street-level data.
|
||||
The data isn't mixed into OSM data but queried as fallback when no OSM
|
||||
result can be found.
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
display: none!important
|
||||
}
|
||||
|
||||
.wy-nav-content {
|
||||
max-width: 900px!important
|
||||
}
|
||||
|
||||
table {
|
||||
margin-bottom: 12pt
|
||||
}
|
||||
@@ -14,10 +18,19 @@ th {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
/* Indentation for mkdocstrings.
|
||||
div.doc-contents:not(.first) {
|
||||
padding-left: 25px;
|
||||
border-left: 4px solid rgba(230, 230, 230);
|
||||
margin-bottom: 60px;
|
||||
}*/
|
||||
.doc-object h6 {
|
||||
margin-bottom: 0.8em;
|
||||
font-size: 130%;
|
||||
}
|
||||
|
||||
.doc-object {
|
||||
margin-bottom: 1.3em;
|
||||
}
|
||||
|
||||
.doc-children .doc-contents {
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
||||
.md-footer__inner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
Nominatim (from the Latin, 'by name') is a tool to search OSM data by name and address and to generate synthetic addresses of OSM points (reverse geocoding).
|
||||
Nominatim (from the Latin, 'by name') is a tool to search OSM data by name and
|
||||
address and to generate synthetic addresses of OSM points (reverse geocoding).
|
||||
It has also limited capability to search features by their type
|
||||
(pubs, hotels, churches, etc).
|
||||
|
||||
This guide comes in four parts:
|
||||
This guide comes in five parts:
|
||||
|
||||
* __[API reference](api/Overview.md)__ for users of Nominatim
|
||||
* __[Administration Guide](admin/Installation.md)__ for those who want
|
||||
to install their own Nominatim server
|
||||
* __[Customization Guide](customize/Overview.md)__ for those who want to
|
||||
adapt their own installation to their special requirements
|
||||
* __[Library Guide](library/Getting-Started.md)__ for Python developers who
|
||||
want to use Nominatim as a library in their project
|
||||
* __[Developer's Guide](develop/overview.md)__ for developers of the software
|
||||
|
||||
31
docs/library/Configuration.md
Normal file
31
docs/library/Configuration.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Configuration
|
||||
|
||||
When using Nominatim through the library, it can be configured in exactly
|
||||
the same way as when running as a service. This means that you should have
|
||||
created a [project directory](../admin/Import.md#creating-the-project-directory)
|
||||
which contains all files belonging to the Nominatim instance. It can also contain
|
||||
an `.env` file with configuration options. Setting configuration parameters
|
||||
via environment variables works as well.
|
||||
|
||||
Configuration options are resolved in the following order:
|
||||
|
||||
* from the OS environment (or the dictionary given in `environ`,
|
||||
(see NominatimAPI.md#nominatim.api.core.NominatimAPI.__init__)
|
||||
* from the .env file in the project directory of the installation
|
||||
* from the default installation in the configuration directory
|
||||
|
||||
For more information on configuration via dotenv and a list of possible
|
||||
configuration parameters, see the [Configuration page](../customize/Settings.md).
|
||||
|
||||
|
||||
## `Configuration` class
|
||||
|
||||
::: nominatim.config.Configuration
|
||||
options:
|
||||
members:
|
||||
- get_bool
|
||||
- get_int
|
||||
- get_str_list
|
||||
- get_path
|
||||
heading_level: 6
|
||||
show_signature_annotations: True
|
||||
248
docs/library/Getting-Started.md
Normal file
248
docs/library/Getting-Started.md
Normal file
@@ -0,0 +1,248 @@
|
||||
# Getting Started
|
||||
|
||||
The Nominatim search frontend can directly be used as a Python library in
|
||||
scripts and applications. When you have imported your own Nominatim database,
|
||||
then it is no longer necessary to run a full web service for it and access
|
||||
the database through http requests. There are
|
||||
also less constraints on the kinds of data that can be accessed. The library
|
||||
allows to get access to more detailed information about the objects saved
|
||||
in the database.
|
||||
|
||||
!!! danger
|
||||
The library interface is currently in an experimental stage. There might
|
||||
be some smaller adjustments to the public interface until the next version.
|
||||
|
||||
The library also misses a proper installation routine, so some manipulation
|
||||
of the PYTHONPATH is required. At the moment, use is only recommended for
|
||||
developers wit some experience in Python.
|
||||
|
||||
## Installation
|
||||
|
||||
To use the Nominatim library, you need access to a local Nominatim database.
|
||||
Follow the [installation](../admin/Installation.md) and
|
||||
[import](../admin/Import.md) instructions to set up your database.
|
||||
|
||||
It is not yet possible to install it in the usual way via pip or inside a
|
||||
virtualenv. To get access to the library you need to set an appropriate
|
||||
`PYTHONPATH`. With the default installation, the python library can be found
|
||||
under `/usr/local/share/nominatim/lib-python`. If you have installed
|
||||
Nominatim under a different prefix, adapt the `/usr/local/` part accordingly.
|
||||
You can also point the `PYTHONPATH` to the Nominatim source code.
|
||||
|
||||
### A simple search example
|
||||
|
||||
To query the Nominatim database you need to first set up a connection. This
|
||||
is done by creating an Nominatim API object. This object exposes all the
|
||||
search functions of Nominatim that are also known from its web API.
|
||||
|
||||
This code snippet implements a simple search for the town of 'Brugge':
|
||||
|
||||
!!! example
|
||||
=== "NominatimAPIAsync"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
async def search(query):
|
||||
api = napi.NominatimAPIAsync(Path('.'))
|
||||
|
||||
return await api.search(query)
|
||||
|
||||
results = asyncio.run(search('Brugge'))
|
||||
if not results:
|
||||
print('Cannot find Brugge')
|
||||
else:
|
||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
||||
```
|
||||
|
||||
=== "NominatimAPI"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
api = napi.NominatimAPI(Path('.'))
|
||||
|
||||
results = api.search('Brugge')
|
||||
|
||||
if not results:
|
||||
print('Cannot find Brugge')
|
||||
else:
|
||||
print(f'Found a place at {results[0].centroid.x},{results[0].centroid.y}')
|
||||
```
|
||||
|
||||
The Nominatim library is designed around
|
||||
[asyncio](https://docs.python.org/3/library/asyncio.html). `NominatimAPIAsync`
|
||||
provides you with an interface of coroutines.
|
||||
If you have many requests to make, coroutines can speed up your applications
|
||||
significantly.
|
||||
|
||||
For smaller scripts there is also a synchronous wrapper around the API. By
|
||||
using `NominatimAPI`, you get exactly the same interface using classic functions.
|
||||
|
||||
The examples in this chapter will always show-case both
|
||||
implementations. The documentation itself will usually refer only to
|
||||
'Nominatim API class' when both flavours are meant. If a functionality is
|
||||
available only for the synchronous or asynchronous version, this will be
|
||||
explicitly mentioned.
|
||||
|
||||
### Defining which database to use
|
||||
|
||||
The [Configuration](../admin/Import.md#configuration-setup-in-env)
|
||||
section explains how Nominatim is configured using the
|
||||
[dotenv](https://github.com/theskumar/python-dotenv) library.
|
||||
The same configuration mechanism is used with the
|
||||
Nominatim API library. You should therefore be sure you are familiar with
|
||||
the section.
|
||||
|
||||
The constructor of the 'Nominatim API class' takes one mandatory parameter:
|
||||
the path to the [project directory](../admin/Import.md#creating-the-project-directory).
|
||||
You should have set up this directory as part of the Nominatim import.
|
||||
Any configuration found in the `.env` file in this directory will automatically
|
||||
used.
|
||||
|
||||
Yo may also configure Nominatim be setting environment variables.
|
||||
Normally, Nominatim will check the operating system environment. This can be
|
||||
overwritten by giving the constructor a dictionary of configuration parameters.
|
||||
|
||||
Let us look up 'Brugge' in the special database named 'belgium' instead of the
|
||||
standard 'nominatim' database:
|
||||
|
||||
!!! example
|
||||
=== "NominatimAPIAsync"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
config_params = {
|
||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
||||
}
|
||||
|
||||
async def search(query):
|
||||
api = napi.NominatimAPIAsync(Path('.'), environ=config_params)
|
||||
|
||||
return await api.search(query)
|
||||
|
||||
results = asyncio.run(search('Brugge'))
|
||||
```
|
||||
|
||||
=== "NominatimAPI"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
config_params = {
|
||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
||||
}
|
||||
|
||||
api = napi.NominatimAPI(Path('.'), environ=config_params)
|
||||
|
||||
results = api.search('Brugge')
|
||||
```
|
||||
|
||||
### Presenting results to humans
|
||||
|
||||
All search functions return the raw results from the database. There is no
|
||||
full human-readable label. To create such a label, you need two things:
|
||||
|
||||
* the address details of the place
|
||||
* adapt the result to the language you wish to use for display
|
||||
|
||||
Again searching for 'Brugge', this time with a nicely formatted result:
|
||||
|
||||
!!! example
|
||||
=== "NominatimAPIAsync"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
async def search(query):
|
||||
api = napi.NominatimAPIAsync(Path('.'))
|
||||
|
||||
return await api.search(query, address_details=True)
|
||||
|
||||
results = asyncio.run(search('Brugge'))
|
||||
|
||||
locale = napi.Locales(['fr', 'en'])
|
||||
for i, result in enumerate(results):
|
||||
address_parts = result.address_rows.localize(locale)
|
||||
print(f"{i + 1}. {', '.join(address_parts)}")
|
||||
```
|
||||
|
||||
=== "NominatimAPI"
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
|
||||
api = napi.NominatimAPI(Path('.'))
|
||||
|
||||
results = api.search('Brugge', address_details=True)
|
||||
|
||||
locale = napi.Locales(['fr', 'en'])
|
||||
for i, result in enumerate(results):
|
||||
address_parts = result.address_rows.localize(locale)
|
||||
print(f"{i + 1}. {', '.join(address_parts)}")
|
||||
```
|
||||
|
||||
To request information about the address of a result, add the optional
|
||||
parameter 'address_details' to your search:
|
||||
|
||||
``` python
|
||||
>>> results = api.search('Brugge', address_details=True)
|
||||
```
|
||||
|
||||
An additional field `address_rows` will set in results that are returned.
|
||||
It contains a list of all places that make up the address of the place. For
|
||||
simplicity, this includes name and house number of the place itself. With
|
||||
the names in this list it is possible to create a human-readable description
|
||||
of the result. To do that, you first need to decide in which language the
|
||||
results should be presented. As with the names in the result itself, the
|
||||
places in `address_rows` contain all possible name translation for each row.
|
||||
|
||||
The library has a helper class `Locale` which helps extracting a name of a
|
||||
place in the preferred language. It takes a single parameter with a list
|
||||
of language codes in the order of preference. So
|
||||
|
||||
``` python
|
||||
locale = napi.Locale(['fr', 'en'])
|
||||
```
|
||||
|
||||
creates a helper class that returns the name preferably in French. If that is
|
||||
not possible, it tries English and eventually falls back to the default `name`
|
||||
or `ref`.
|
||||
|
||||
The `Locale` object can be applied to a name dictionary to return the best-matching
|
||||
name out of it:
|
||||
|
||||
``` python
|
||||
>>> print(locale.display_name(results[0].names))
|
||||
'Brugges'
|
||||
```
|
||||
|
||||
The `address_row` field has a helper function to apply the function to all
|
||||
its members and save the result in the `local_name` field. It also returns
|
||||
all the localized names as a convenient simple list. This list can be used
|
||||
to create a human-readable output:
|
||||
|
||||
``` python
|
||||
>>> address_parts = results[0].address_rows.localize(locale)
|
||||
>>> print(', '.join(address_parts))
|
||||
Bruges, Flandre-Occidentale, Flandre, Belgique
|
||||
```
|
||||
|
||||
This is a fairly simple way to create a human-readable description. The
|
||||
place information in `address_rows` contains further information about each
|
||||
place. For example, which OSM `adlin_level` was used, what category the place
|
||||
belongs to or what rank Nominatim has assigned. Use this to adapt the output
|
||||
to local address formats.
|
||||
|
||||
For more information on address rows, see
|
||||
[detailed address description](Result-Handling.md#detailed-address-description).
|
||||
62
docs/library/Input-Parameter-Types.md
Normal file
62
docs/library/Input-Parameter-Types.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Input Parameter Types
|
||||
|
||||
This page describes in more detail some of the input parameter types used
|
||||
in the query functions of the API object.
|
||||
|
||||
## Place identification
|
||||
|
||||
The [details](NominatimAPI.md#nominatim.api.core.NominatimAPI.details) and
|
||||
[lookup](NominatimAPI.md#nominatim.api.core.NominatimAPI.lookup) functions
|
||||
require references to places in the database. Below the possible
|
||||
types for place identification are listed. All types are dataclasses.
|
||||
|
||||
### PlaceID
|
||||
|
||||
::: nominatim.api.PlaceID
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### OsmID
|
||||
|
||||
::: nominatim.api.OsmID
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
## Geometry types
|
||||
|
||||
::: nominatim.api.GeometryFormat
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
|
||||
## Geometry input
|
||||
|
||||
### Point
|
||||
|
||||
::: nominatim.api.Point
|
||||
options:
|
||||
heading_level: 6
|
||||
show_signature_annotations: True
|
||||
|
||||
### Bbox
|
||||
|
||||
::: nominatim.api.Bbox
|
||||
options:
|
||||
heading_level: 6
|
||||
show_signature_annotations: True
|
||||
members_order: source
|
||||
group_by_category: False
|
||||
|
||||
## Layers
|
||||
|
||||
Layers allow to restrict the search result to thematic groups. This is
|
||||
orthogonal to restriction by address ranks, which groups places by their
|
||||
geographic extent.
|
||||
|
||||
|
||||
::: nominatim.api.DataLayer
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
|
||||
|
||||
56
docs/library/Low-Level-DB-Access.md
Normal file
56
docs/library/Low-Level-DB-Access.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Low-level connections
|
||||
|
||||
The `NominatimAPIAsync` class allows to directly access the underlying
|
||||
database connection to explore the raw data. Nominatim uses
|
||||
[SQLAlchemy](https://docs.sqlalchemy.org/) for building queries. Please
|
||||
refer to the documentation of the library to understand how to write SQL.
|
||||
|
||||
To get access to a search connection, use the `begin()` function of your
|
||||
API object. This returns a `SearchConnection` object described below
|
||||
wrapped in a context manager. Its
|
||||
`t` property has definitions for all Nominatim search tables. For an
|
||||
overview of available tables, refer to the
|
||||
[Development Layout](../develop/Database-Layout.md) in in the development
|
||||
chapter. Note that only tables that are needed for search are accessible
|
||||
as SQLAlchemy tables.
|
||||
|
||||
!!! warning
|
||||
The database layout is not part of the API definition and may change
|
||||
without notice. If you play with the low-level access functions, you
|
||||
need to be prepared for such changes.
|
||||
|
||||
Here is a simple example, which prints how many places are available in
|
||||
the placex table:
|
||||
|
||||
```
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
import sqlalchemy as sa
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
|
||||
async def print_table_size():
|
||||
api = NominatimAPIAsync(Path('.'))
|
||||
|
||||
async with api.begin() as conn:
|
||||
cnt = await conn.scalar(sa.select(sa.func.count()).select_from(conn.t.placex))
|
||||
print(f'placex table has {cnt} rows.')
|
||||
|
||||
asyncio.run(print_table_size())
|
||||
```
|
||||
|
||||
!!! warning
|
||||
Low-level connections may only be used to read data from the database.
|
||||
Do not use it to add or modify data or you might break Nominatim's
|
||||
normal functions.
|
||||
|
||||
## SearchConnection class
|
||||
|
||||
::: nominatim.api.SearchConnection
|
||||
options:
|
||||
members:
|
||||
- scalar
|
||||
- execute
|
||||
- get_class_table
|
||||
- get_db_property
|
||||
- get_property
|
||||
heading_level: 6
|
||||
36
docs/library/NominatimAPI.md
Normal file
36
docs/library/NominatimAPI.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# The Nominatim API classes
|
||||
|
||||
The API classes are the core object of the search library. Always instantiate
|
||||
one of these classes first. The API classes are **not threadsafe**. You need
|
||||
to instantiate a separate instance for each thread.
|
||||
|
||||
### NominatimAPI
|
||||
|
||||
::: nominatim.api.NominatimAPI
|
||||
options:
|
||||
members:
|
||||
- __init__
|
||||
- config
|
||||
- close
|
||||
- status
|
||||
- details
|
||||
- lookup
|
||||
- reverse
|
||||
- search
|
||||
- search_address
|
||||
- search_category
|
||||
heading_level: 6
|
||||
group_by_category: False
|
||||
|
||||
|
||||
### NominatimAPIAsync
|
||||
|
||||
::: nominatim.api.NominatimAPIAsync
|
||||
options:
|
||||
members:
|
||||
- __init__
|
||||
- setup_database
|
||||
- close
|
||||
- begin
|
||||
heading_level: 6
|
||||
group_by_category: False
|
||||
58
docs/library/Result-Handling.md
Normal file
58
docs/library/Result-Handling.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Result handling
|
||||
|
||||
The search functions of the Nominatim API always return a result object
|
||||
with the raw information about the place that is available in the
|
||||
database. This section discusses data types used in the results and utility
|
||||
functions that allow further processing of the results.
|
||||
|
||||
## Result fields
|
||||
|
||||
### Sources
|
||||
|
||||
Nominatim takes the result data from multiple sources. The `source_table` field
|
||||
in the result describes, from which source the result was retrieved.
|
||||
|
||||
::: nominatim.api.SourceTable
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
|
||||
### Detailed address description
|
||||
|
||||
When the `address_details` parameter is set, then functions return not
|
||||
only information about the result place but also about the place that
|
||||
make up the address. This information is almost always required when you
|
||||
want to present the user with a human-readable description of the result.
|
||||
See also [Localization](#localization) below.
|
||||
|
||||
The address details are available in the `address_rows` field as a ordered
|
||||
list of `AddressLine` objects with the country information last. The list also
|
||||
contains the result place itself and some artificial entries, for example,
|
||||
for the house number or the country code. This makes processing and creating
|
||||
a full address easier.
|
||||
|
||||
::: nominatim.api.AddressLine
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
|
||||
### Detailed search terms
|
||||
|
||||
The `details` function can return detailed information about which search terms
|
||||
may be used to find a place, when the `keywords` parameter is set. Search
|
||||
terms are split into terms for the name of the place and search terms for
|
||||
its address.
|
||||
|
||||
::: nominatim.api.WordInfo
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
## Localization
|
||||
|
||||
Results are always returned with the full list of available names.
|
||||
|
||||
### Locale
|
||||
|
||||
::: nominatim.api.Locales
|
||||
options:
|
||||
heading_level: 6
|
||||
@@ -1,9 +1,13 @@
|
||||
site_name: Nominatim Documentation
|
||||
theme: readthedocs
|
||||
site_name: Nominatim Manual
|
||||
theme:
|
||||
name: material
|
||||
features:
|
||||
- navigation.tabs
|
||||
copyright: Copyright © Nominatim developer community
|
||||
docs_dir: ${CMAKE_CURRENT_BINARY_DIR}
|
||||
site_url: https://nominatim.org
|
||||
repo_url: https://github.com/openstreetmap/Nominatim
|
||||
pages:
|
||||
nav:
|
||||
- 'Introduction' : 'index.md'
|
||||
- 'API Reference':
|
||||
- 'Overview': 'api/Overview.md'
|
||||
@@ -18,7 +22,8 @@ pages:
|
||||
- 'Basic Installation': 'admin/Installation.md'
|
||||
- 'Import' : 'admin/Import.md'
|
||||
- 'Update' : 'admin/Update.md'
|
||||
- 'Deploy' : 'admin/Deployment.md'
|
||||
- 'Deploy (PHP frontend)' : 'admin/Deployment-PHP.md'
|
||||
- 'Deploy (Python frontend)' : 'admin/Deployment-Python.md'
|
||||
- 'Nominatim UI' : 'admin/Setup-Nominatim-UI.md'
|
||||
- 'Advanced Installations' : 'admin/Advanced-Installations.md'
|
||||
- 'Maintenance' : 'admin/Maintenance.md'
|
||||
@@ -28,27 +33,38 @@ pages:
|
||||
- 'Overview': 'customize/Overview.md'
|
||||
- 'Import Styles': 'customize/Import-Styles.md'
|
||||
- 'Configuration Settings': 'customize/Settings.md'
|
||||
- 'Per-Country Data': 'customize/Country-Settings.md'
|
||||
- 'Place Ranking' : 'customize/Ranking.md'
|
||||
- 'Importance' : 'customize/Importance.md'
|
||||
- 'Tokenizers' : 'customize/Tokenizers.md'
|
||||
- 'Special Phrases': 'customize/Special-Phrases.md'
|
||||
- 'External data: US housenumbers from TIGER': 'customize/Tiger.md'
|
||||
- 'External data: Postcodes': 'customize/Postcodes.md'
|
||||
- 'Library Guide':
|
||||
- 'Getting Started': 'library/Getting-Started.md'
|
||||
- 'Nominatim API class': 'library/NominatimAPI.md'
|
||||
- 'Configuration': 'library/Configuration.md'
|
||||
- 'Input Parameter Types': 'library/Input-Parameter-Types.md'
|
||||
- 'Result Handling': 'library/Result-Handling.md'
|
||||
- 'Low-level DB Access': 'library/Low-Level-DB-Access.md'
|
||||
- 'Developers Guide':
|
||||
- 'Architecture Overview' : 'develop/overview.md'
|
||||
- 'Database Layout' : 'develop/Database-Layout.md'
|
||||
- 'Indexing' : 'develop/Indexing.md'
|
||||
- 'Tokenizers' : 'develop/Tokenizers.md'
|
||||
- 'Custom modules for ICU tokenizer': 'develop/ICU-Tokenizer-Modules.md'
|
||||
- 'Setup for Development' : 'develop/Development-Environment.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 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'
|
||||
- 'Installation on Ubuntu 22' : 'appendix/Install-on-Ubuntu-22.md'
|
||||
markdown_extensions:
|
||||
- codehilite
|
||||
- admonition
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- def_list
|
||||
- toc:
|
||||
permalink:
|
||||
@@ -58,6 +74,7 @@ plugins:
|
||||
- mkdocstrings:
|
||||
handlers:
|
||||
python:
|
||||
rendering:
|
||||
show_source: false
|
||||
show_signature_annotations: false
|
||||
paths: ["${PROJECT_SOURCE_DIR}"]
|
||||
options:
|
||||
show_source: False
|
||||
show_bases: False
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -84,6 +92,10 @@ class AddressDetails
|
||||
|| $aLine['class'] == 'place')
|
||||
) {
|
||||
$aAddress[$sTypeLabel] = $sName;
|
||||
|
||||
if (!empty($aLine['name'])) {
|
||||
$this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,4 +178,14 @@ class AddressDetails
|
||||
{
|
||||
return $this->aAddressLines;
|
||||
}
|
||||
|
||||
private function addSubdivisionCode(&$aAddress, $iAdminLevel, $nameDetails)
|
||||
{
|
||||
if (is_string($nameDetails)) {
|
||||
$nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true);
|
||||
}
|
||||
if (!empty($nameDetails['ISO3166-2'])) {
|
||||
$aAddress["ISO3166-2-lvl$iAdminLevel"] = $nameDetails['ISO3166-2'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\ClassTypes;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -30,20 +38,25 @@ class DB
|
||||
|
||||
// https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php
|
||||
try {
|
||||
$conn = new \PDO($this->sDSN, null, null, $aConnOptions);
|
||||
$this->connection = 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'");
|
||||
$this->connection->exec("SET DateStyle TO 'sql,european'");
|
||||
$this->connection->exec("SET client_encoding TO 'utf-8'");
|
||||
// Disable JIT and parallel workers. They interfere badly with search SQL.
|
||||
$this->connection->exec('SET max_parallel_workers_per_gather TO 0');
|
||||
if ($this->getPostgresVersion() >= 11) {
|
||||
$this->connection->exec('SET jit_above_cost TO -1');
|
||||
}
|
||||
|
||||
$iMaxExecution = ini_get('max_execution_time');
|
||||
if ($iMaxExecution > 0) {
|
||||
$conn->setAttribute(\PDO::ATTR_TIMEOUT, $iMaxExecution); // seconds
|
||||
$this->connection->setAttribute(\PDO::ATTR_TIMEOUT, $iMaxExecution); // seconds
|
||||
}
|
||||
|
||||
$this->connection = $conn;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -127,7 +135,7 @@ class Debug
|
||||
|
||||
public static function printSQL($sSQL)
|
||||
{
|
||||
echo '<p><tt><font color="#aaa">'.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'</font></tt></p>'."\n";
|
||||
echo '<p><tt><b>'.date('c').'</b> <font color="#aaa">'.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'</font></tt></p>'."\n";
|
||||
}
|
||||
|
||||
private static function outputVar($mVar, $sPreNL)
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -95,7 +103,7 @@ class Geocode
|
||||
}
|
||||
|
||||
$this->iFinalLimit = $iLimit;
|
||||
$this->iLimit = $iLimit + min($iLimit, 10);
|
||||
$this->iLimit = $iLimit + max($iLimit, 10);
|
||||
}
|
||||
|
||||
public function setFeatureType($sFeatureType)
|
||||
@@ -182,7 +190,7 @@ class Geocode
|
||||
|
||||
$this->bFallback = $oParams->getBool('fallback', $this->bFallback);
|
||||
|
||||
// List of excluded Place IDs - used for more acurate pageing
|
||||
// List of excluded Place IDs - used for more accurate pageing
|
||||
$sExcluded = $oParams->getStringList('exclude_place_ids');
|
||||
if ($sExcluded) {
|
||||
foreach ($sExcluded as $iExcludedPlaceID) {
|
||||
@@ -609,16 +617,15 @@ class Geocode
|
||||
}
|
||||
$aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $oValidTokens);
|
||||
|
||||
foreach ($aGroupedSearches as $aSearches) {
|
||||
foreach ($aReverseGroupedSearches as $aSearches) {
|
||||
foreach ($aSearches as $aSearch) {
|
||||
if (!isset($aReverseGroupedSearches[$aSearch->getRank()])) {
|
||||
$aReverseGroupedSearches[$aSearch->getRank()] = array();
|
||||
if (!isset($aGroupedSearches[$aSearch->getRank()])) {
|
||||
$aGroupedSearches[$aSearch->getRank()] = array();
|
||||
}
|
||||
$aReverseGroupedSearches[$aSearch->getRank()][] = $aSearch;
|
||||
$aGroupedSearches[$aSearch->getRank()][] = $aSearch;
|
||||
}
|
||||
}
|
||||
|
||||
$aGroupedSearches = $aReverseGroupedSearches;
|
||||
ksort($aGroupedSearches);
|
||||
}
|
||||
} else {
|
||||
@@ -836,7 +843,9 @@ class Geocode
|
||||
$aResult['importance'] = 0.001;
|
||||
$aResult['foundorder'] = $aResult['addressimportance'];
|
||||
} else {
|
||||
$aResult['importance'] = max(0.001, $aResult['importance']);
|
||||
if ($aResult['importance'] == 0) {
|
||||
$aResult['importance'] = 0.0001;
|
||||
}
|
||||
$aResult['importance'] *= $this->viewboxImportanceFactor(
|
||||
$aResult['lon'],
|
||||
$aResult['lat']
|
||||
@@ -865,7 +874,7 @@ class Geocode
|
||||
$iCountWords = 0;
|
||||
$sAddress = $aResult['langaddress'];
|
||||
foreach ($aRecheckWords as $i => $sWord) {
|
||||
if (stripos($sAddress, $sWord)!==false) {
|
||||
if (grapheme_stripos($sAddress, $sWord)!==false) {
|
||||
$iCountWords++;
|
||||
if (preg_match('/(^|,)\s*'.preg_quote($sWord, '/').'\s*(,|$)/', $sAddress)) {
|
||||
$iCountWords += 0.1;
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -14,7 +22,10 @@ class ParameterParser
|
||||
|
||||
public function getBool($sName, $bDefault = false)
|
||||
{
|
||||
if (!isset($this->aParams[$sName]) || strlen($this->aParams[$sName]) == 0) {
|
||||
if (!isset($this->aParams[$sName])
|
||||
|| !is_string($this->aParams[$sName])
|
||||
|| strlen($this->aParams[$sName]) == 0
|
||||
) {
|
||||
return $bDefault;
|
||||
}
|
||||
|
||||
@@ -23,7 +34,7 @@ class ParameterParser
|
||||
|
||||
public function getInt($sName, $bDefault = false)
|
||||
{
|
||||
if (!isset($this->aParams[$sName])) {
|
||||
if (!isset($this->aParams[$sName]) || is_array($this->aParams[$sName])) {
|
||||
return $bDefault;
|
||||
}
|
||||
|
||||
@@ -36,7 +47,7 @@ class ParameterParser
|
||||
|
||||
public function getFloat($sName, $bDefault = false)
|
||||
{
|
||||
if (!isset($this->aParams[$sName])) {
|
||||
if (!isset($this->aParams[$sName]) || is_array($this->aParams[$sName])) {
|
||||
return $bDefault;
|
||||
}
|
||||
|
||||
@@ -49,7 +60,10 @@ class ParameterParser
|
||||
|
||||
public function getString($sName, $bDefault = false)
|
||||
{
|
||||
if (!isset($this->aParams[$sName]) || strlen($this->aParams[$sName]) == 0) {
|
||||
if (!isset($this->aParams[$sName])
|
||||
|| !is_string($this->aParams[$sName])
|
||||
|| strlen($this->aParams[$sName]) == 0
|
||||
) {
|
||||
return $bDefault;
|
||||
}
|
||||
|
||||
@@ -58,11 +72,14 @@ class ParameterParser
|
||||
|
||||
public function getSet($sName, $aValues, $sDefault = false)
|
||||
{
|
||||
if (!isset($this->aParams[$sName]) || strlen($this->aParams[$sName]) == 0) {
|
||||
if (!isset($this->aParams[$sName])
|
||||
|| !is_string($this->aParams[$sName])
|
||||
|| strlen($this->aParams[$sName]) == 0
|
||||
) {
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
if (!in_array($this->aParams[$sName], $aValues)) {
|
||||
if (!in_array($this->aParams[$sName], $aValues, true)) {
|
||||
userError("Parameter '$sName' must be one of: ".join(', ', $aValues));
|
||||
}
|
||||
|
||||
@@ -106,21 +123,27 @@ class ParameterParser
|
||||
}
|
||||
|
||||
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
|
||||
$aLangPrefOrder['name:'.$sLanguage] = 'name:'.$sLanguage;
|
||||
$this->addNameTag($aLangPrefOrder, 'name:'.$sLanguage);
|
||||
}
|
||||
$aLangPrefOrder['name'] = 'name';
|
||||
$aLangPrefOrder['brand'] = 'brand';
|
||||
$this->addNameTag($aLangPrefOrder, 'name');
|
||||
$this->addNameTag($aLangPrefOrder, 'brand');
|
||||
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
|
||||
$aLangPrefOrder['official_name:'.$sLanguage] = 'official_name:'.$sLanguage;
|
||||
$aLangPrefOrder['short_name:'.$sLanguage] = 'short_name:'.$sLanguage;
|
||||
$this->addNameTag($aLangPrefOrder, 'official_name:'.$sLanguage);
|
||||
$this->addNameTag($aLangPrefOrder, 'short_name:'.$sLanguage);
|
||||
}
|
||||
$aLangPrefOrder['official_name'] = 'official_name';
|
||||
$aLangPrefOrder['short_name'] = 'short_name';
|
||||
$aLangPrefOrder['ref'] = 'ref';
|
||||
$aLangPrefOrder['type'] = 'type';
|
||||
$this->addNameTag($aLangPrefOrder, 'official_name');
|
||||
$this->addNameTag($aLangPrefOrder, 'short_name');
|
||||
$this->addNameTag($aLangPrefOrder, 'ref');
|
||||
$this->addNameTag($aLangPrefOrder, 'type');
|
||||
return $aLangPrefOrder;
|
||||
}
|
||||
|
||||
private function addNameTag(&$aLangPrefOrder, $sTag)
|
||||
{
|
||||
$aLangPrefOrder[$sTag] = $sTag;
|
||||
$aLangPrefOrder['_place_'.$sTag] = '_place_'.$sTag;
|
||||
}
|
||||
|
||||
public function hasSetAny($aParamNames)
|
||||
{
|
||||
foreach ($aParamNames as $sName) {
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -24,7 +32,7 @@ class Phrase
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the orginal phrase of the string.
|
||||
* Get the original phrase of the string.
|
||||
*/
|
||||
public function getPhrase()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -78,7 +86,7 @@ class PlaceLookup
|
||||
($this->bIncludePolygonAsSVG ? 1 : 0);
|
||||
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
|
||||
if (CONST_PolygonOutput_MaximumTypes) {
|
||||
userError('Select only '.CONST_PolygonOutput_MaximumTypes.' polgyon output option');
|
||||
userError('Select only '.CONST_PolygonOutput_MaximumTypes.' polygon output option');
|
||||
} else {
|
||||
userError('Polygon output is disabled');
|
||||
}
|
||||
@@ -179,12 +187,12 @@ class PlaceLookup
|
||||
return null;
|
||||
}
|
||||
|
||||
$aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)));
|
||||
$aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)), 0, 30, true);
|
||||
|
||||
return empty($aResults) ? null : reset($aResults);
|
||||
}
|
||||
|
||||
public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
|
||||
public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30, $bAllowLinked = false)
|
||||
{
|
||||
Debug::newFunction('Place lookup');
|
||||
|
||||
@@ -239,7 +247,9 @@ class PlaceLookup
|
||||
if ($this->sAllowedTypesSQLList) {
|
||||
$sSQL .= 'AND placex.class in '.$this->sAllowedTypesSQLList;
|
||||
}
|
||||
$sSQL .= ' AND linked_place_id is null ';
|
||||
if (!$bAllowLinked) {
|
||||
$sSQL .= ' AND linked_place_id is null ';
|
||||
}
|
||||
$sSQL .= ' GROUP BY ';
|
||||
$sSQL .= ' osm_type, ';
|
||||
$sSQL .= ' osm_id, ';
|
||||
@@ -340,7 +350,9 @@ class PlaceLookup
|
||||
$sSQL .= ' null::text AS extra_place ';
|
||||
$sSQL .= ' FROM (';
|
||||
$sSQL .= ' SELECT place_id, '; // interpolate the Tiger housenumbers here
|
||||
$sSQL .= ' ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) AS centroid, ';
|
||||
$sSQL .= ' CASE WHEN startnumber != endnumber';
|
||||
$sSQL .= ' THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float)';
|
||||
$sSQL .= ' ELSE ST_LineInterpolatePoint(linegeo, 0.5) END AS centroid, ';
|
||||
$sSQL .= ' parent_place_id, ';
|
||||
$sSQL .= ' housenumber_for_place';
|
||||
$sSQL .= ' FROM (';
|
||||
@@ -397,7 +409,7 @@ class PlaceLookup
|
||||
$sSQL .= ' CASE '; // interpolate the housenumbers here
|
||||
$sSQL .= ' WHEN startnumber != endnumber ';
|
||||
$sSQL .= ' THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ';
|
||||
$sSQL .= ' ELSE ST_LineInterpolatePoint(linegeo, 0.5) ';
|
||||
$sSQL .= ' ELSE linegeo ';
|
||||
$sSQL .= ' END as centroid, ';
|
||||
$sSQL .= ' parent_place_id, ';
|
||||
$sSQL .= ' housenumber_for_place ';
|
||||
@@ -435,18 +447,14 @@ class PlaceLookup
|
||||
|
||||
if ($this->bExtraTags) {
|
||||
if ($aPlace['extra']) {
|
||||
$aPlace['sExtraTags'] = json_decode($aPlace['extra']);
|
||||
$aPlace['sExtraTags'] = json_decode($aPlace['extra'], true);
|
||||
} else {
|
||||
$aPlace['sExtraTags'] = (object) array();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->bNameDetails) {
|
||||
if ($aPlace['names']) {
|
||||
$aPlace['sNameDetails'] = json_decode($aPlace['names']);
|
||||
} else {
|
||||
$aPlace['sNameDetails'] = (object) array();
|
||||
}
|
||||
$aPlace['sNameDetails'] = $this->extractNames($aPlace['names']);
|
||||
}
|
||||
|
||||
$aPlace['addresstype'] = ClassTypes\getLabelTag(
|
||||
@@ -469,6 +477,33 @@ class PlaceLookup
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
|
||||
private function extractNames($sNames)
|
||||
{
|
||||
if (!$sNames) {
|
||||
return (object) array();
|
||||
}
|
||||
|
||||
$aFullNames = json_decode($sNames, true);
|
||||
$aNames = array();
|
||||
|
||||
foreach ($aFullNames as $sKey => $sValue) {
|
||||
if (strpos($sKey, '_place_') === 0) {
|
||||
$sSubKey = substr($sKey, 7);
|
||||
if (array_key_exists($sSubKey, $aFullNames)) {
|
||||
$aNames[$sKey] = $sValue;
|
||||
} else {
|
||||
$aNames[$sSubKey] = $sValue;
|
||||
}
|
||||
} else {
|
||||
$aNames[$sKey] = $sValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $aNames;
|
||||
}
|
||||
|
||||
|
||||
/* returns an array which will contain the keys
|
||||
* aBoundingBox
|
||||
* and may also contain one or more of the keys
|
||||
@@ -479,8 +514,6 @@ class PlaceLookup
|
||||
* lat
|
||||
* lon
|
||||
*/
|
||||
|
||||
|
||||
public function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = null, $fLonReverse = null, $fLatReverse = null)
|
||||
{
|
||||
|
||||
@@ -491,12 +524,7 @@ class PlaceLookup
|
||||
|
||||
// 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_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) {
|
||||
@@ -511,19 +539,21 @@ class PlaceLookup
|
||||
if ($this->bIncludePolygonAsText) {
|
||||
$sSQL .= ',ST_AsText(geometry) as astext';
|
||||
}
|
||||
|
||||
$sSQL .= ' FROM (SELECT place_id';
|
||||
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';
|
||||
$sSQL .= ',CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
|
||||
$sSQL .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
|
||||
$sSQL .=' ELSE centroid END AS centroid';
|
||||
} else {
|
||||
$sFrom = ' from placex where place_id = '.$iPlaceID;
|
||||
$sSQL .= ',centroid';
|
||||
}
|
||||
if ($this->fPolygonSimplificationThreshold > 0) {
|
||||
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
|
||||
$sSQL .= ',ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry';
|
||||
} else {
|
||||
$sSQL .= $sFrom;
|
||||
$sSQL .= ',geometry';
|
||||
}
|
||||
$sSQL .= ' FROM placex where place_id = '.$iPlaceID.') as plx';
|
||||
|
||||
$aPointPolygon = $this->oDB->getRow($sSQL, null, 'Could not get outline');
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -32,10 +40,10 @@ class ReverseGeocode
|
||||
9 => 12,
|
||||
10 => 17, // City
|
||||
11 => 17,
|
||||
12 => 18, // Town / Village
|
||||
13 => 18,
|
||||
14 => 22, // Suburb
|
||||
15 => 22,
|
||||
12 => 18, // Town
|
||||
13 => 19, // Village
|
||||
14 => 22, // Neighbourhood
|
||||
15 => 25, // Locality
|
||||
16 => 26, // major street
|
||||
17 => 27, // minor street
|
||||
18 => 30, // or >, Building
|
||||
@@ -56,12 +64,15 @@ class ReverseGeocode
|
||||
{
|
||||
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,';
|
||||
$sSQL .= ' (CASE WHEN endnumber != startnumber';
|
||||
$sSQL .= ' THEN (endnumber - startnumber) * ST_LineLocatePoint(linegeo,'.$sPointSQL.')';
|
||||
$sSQL .= ' ELSE startnumber END) as fhnr,';
|
||||
$sSQL .= ' startnumber, endnumber, step,';
|
||||
$sSQL .= ' ST_Distance(linegeo,'.$sPointSQL.') as distance';
|
||||
$sSQL .= ' FROM location_property_osmline';
|
||||
$sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', linegeo, '.$fSearchDiam.')';
|
||||
$sSQL .= ' and indexed_status = 0 and startnumber is not NULL ';
|
||||
$sSQL .= ' and indexed_status = 0 and startnumber is not NULL ';
|
||||
$sSQL .= ' and parent_place_id != 0';
|
||||
$sSQL .= ' ORDER BY distance ASC limit 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
@@ -74,6 +85,11 @@ class ReverseGeocode
|
||||
|
||||
protected function lookupLargeArea($sPointSQL, $iMaxRank)
|
||||
{
|
||||
$sCountryCode = $this->getCountryCode($sPointSQL);
|
||||
if (CONST_Search_WithinCountries and $sCountryCode == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($iMaxRank > 4) {
|
||||
$aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
|
||||
if ($aPlace) {
|
||||
@@ -83,12 +99,12 @@ class ReverseGeocode
|
||||
|
||||
// If no polygon which contains the searchpoint is found,
|
||||
// searches in the country_osm_grid table for a polygon.
|
||||
return $this->lookupInCountry($sPointSQL, $iMaxRank);
|
||||
return $this->lookupInCountry($sPointSQL, $iMaxRank, $sCountryCode);
|
||||
}
|
||||
|
||||
protected function lookupInCountry($sPointSQL, $iMaxRank)
|
||||
protected function getCountryCode($sPointSQL)
|
||||
{
|
||||
Debug::newFunction('lookupInCountry');
|
||||
Debug::newFunction('getCountryCode');
|
||||
// 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';
|
||||
@@ -100,8 +116,12 @@ class ReverseGeocode
|
||||
null,
|
||||
'Could not determine country polygon containing the point.'
|
||||
);
|
||||
Debug::printVar('Country code', $sCountryCode);
|
||||
return $sCountryCode;
|
||||
}
|
||||
|
||||
protected function lookupInCountry($sPointSQL, $iMaxRank, $sCountryCode)
|
||||
{
|
||||
Debug::newFunction('lookupInCountry');
|
||||
if ($sCountryCode) {
|
||||
if ($iMaxRank > 4) {
|
||||
// look for place nodes with the given country code
|
||||
@@ -111,12 +131,13 @@ class ReverseGeocode
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= ' WHERE osm_type = \'N\'';
|
||||
$sSQL .= ' AND country_code = \''.$sCountryCode.'\'';
|
||||
$sSQL .= ' AND rank_search < 26 '; // needed to select right index
|
||||
$sSQL .= ' AND rank_address between 4 and 25'; // needed to select right index
|
||||
$sSQL .= ' AND rank_search between 5 and ' .min(25, $iMaxRank);
|
||||
$sSQL .= ' AND class = \'place\' AND type != \'postcode\'';
|
||||
$sSQL .= ' AND type != \'postcode\'';
|
||||
$sSQL .= ' AND name IS NOT NULL ';
|
||||
$sSQL .= ' and indexed_status = 0 and linked_place_id is null';
|
||||
$sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, 1.8)) p ';
|
||||
$sSQL .= ' AND ST_Buffer(geometry, reverse_place_diameter(rank_search)) && '.$sPointSQL;
|
||||
$sSQL .= ') as a ';
|
||||
$sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)';
|
||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
@@ -178,14 +199,16 @@ class ReverseGeocode
|
||||
$sSQL .= '(select place_id, parent_place_id, rank_address, rank_search, country_code, geometry';
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= ' WHERE ST_GeometryType(geometry) in (\'ST_Polygon\', \'ST_MultiPolygon\')';
|
||||
$sSQL .= ' AND rank_address Between 5 AND ' .$iMaxRank;
|
||||
// Ensure that query planner doesn't use the index on rank_search.
|
||||
$sSQL .= ' AND coalesce(rank_search, 0) between 5 and ' .$iMaxRank;
|
||||
$sSQL .= ' AND rank_address between 4 and 25'; // needed for index selection
|
||||
$sSQL .= ' AND geometry && '.$sPointSQL;
|
||||
$sSQL .= ' AND type != \'postcode\' ';
|
||||
$sSQL .= ' AND name is not null';
|
||||
$sSQL .= ' AND indexed_status = 0 and linked_place_id is null';
|
||||
$sSQL .= ' ORDER BY rank_address DESC LIMIT 50 ) as a';
|
||||
$sSQL .= ' WHERE ST_CONTAINS(geometry, '.$sPointSQL.' )';
|
||||
$sSQL .= ' ORDER BY rank_address DESC LIMIT 1';
|
||||
$sSQL .= ' ORDER BY rank_search DESC LIMIT 50 ) as a';
|
||||
$sSQL .= ' WHERE ST_Contains(geometry, '.$sPointSQL.' )';
|
||||
$sSQL .= ' ORDER BY rank_search DESC LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$aPoly = $this->oDB->getRow($sSQL, null, 'Could not determine polygon containing the point.');
|
||||
@@ -197,29 +220,24 @@ class ReverseGeocode
|
||||
$iRankSearch = $aPoly['rank_search'];
|
||||
$iPlaceID = $aPoly['place_id'];
|
||||
|
||||
if ($iRankAddress != $iMaxRank) {
|
||||
if ($iRankSearch != $iMaxRank) {
|
||||
$sSQL = 'SELECT place_id FROM ';
|
||||
$sSQL .= '(SELECT place_id, rank_search, country_code, geometry,';
|
||||
$sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance';
|
||||
$sSQL .= ' FROM placex';
|
||||
$sSQL .= ' WHERE osm_type = \'N\'';
|
||||
// using rank_search because of a better differentiation
|
||||
// for place nodes at rank_address 16
|
||||
$sSQL .= ' AND rank_search > '.$iRankSearch;
|
||||
$sSQL .= ' AND rank_search <= '.$iMaxRank;
|
||||
$sSQL .= ' AND rank_search < 26 '; // needed to select right index
|
||||
$sSQL .= ' AND rank_address > 0';
|
||||
$sSQL .= ' AND class = \'place\'';
|
||||
$sSQL .= ' AND rank_address between 4 and 25'; // needed to select right index
|
||||
$sSQL .= ' AND type != \'postcode\'';
|
||||
$sSQL .= ' AND name IS NOT NULL ';
|
||||
$sSQL .= ' AND indexed_status = 0 AND linked_place_id is null';
|
||||
$sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, reverse_place_diameter('.$iRankSearch.'::smallint))';
|
||||
$sSQL .= ' ORDER BY distance ASC,';
|
||||
$sSQL .= ' rank_address DESC';
|
||||
$sSQL .= ' limit 500) as a';
|
||||
$sSQL .= ' WHERE ST_CONTAINS((SELECT geometry FROM placex WHERE place_id = '.$iPlaceID.'), geometry )';
|
||||
$sSQL .= ' AND ST_Buffer(geometry, reverse_place_diameter(rank_search)) && '.$sPointSQL;
|
||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
||||
$sSQL .= ' limit 100) as a';
|
||||
$sSQL .= ' WHERE ST_Contains((SELECT geometry FROM placex WHERE place_id = '.$iPlaceID.'), geometry )';
|
||||
$sSQL .= ' AND distance <= reverse_place_diameter(rank_search)';
|
||||
$sSQL .= ' ORDER BY distance ASC, rank_search DESC';
|
||||
$sSQL .= ' ORDER BY rank_search DESC, distance ASC';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
@@ -255,7 +273,7 @@ class ReverseGeocode
|
||||
// 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,
|
||||
// the nearest POI which the found street is a parent of is choosen.
|
||||
// the nearest POI which the found street is a parent of is chosen.
|
||||
$sSQL = 'select place_id,parent_place_id,rank_address,country_code,';
|
||||
$sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance';
|
||||
$sSQL .= ' FROM ';
|
||||
@@ -319,9 +337,9 @@ class ReverseGeocode
|
||||
&& $this->iMaxRank >= 28
|
||||
) {
|
||||
$sSQL = 'SELECT place_id,parent_place_id,30 as rank_search,';
|
||||
$sSQL .= 'ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fraction,';
|
||||
$sSQL .= 'ST_distance('.$sPointSQL.', linegeo) as distance,';
|
||||
$sSQL .= 'startnumber,endnumber,interpolationtype';
|
||||
$sSQL .= ' (endnumber - startnumber) * ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fhnr,';
|
||||
$sSQL .= ' startnumber, endnumber, step,';
|
||||
$sSQL .= ' ST_Distance('.$sPointSQL.', linegeo) as distance';
|
||||
$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';
|
||||
@@ -333,7 +351,11 @@ class ReverseGeocode
|
||||
if ($aPlaceTiger) {
|
||||
$aPlace = $aPlaceTiger;
|
||||
$oResult = new Result($aPlaceTiger['place_id'], Result::TABLE_TIGER);
|
||||
$oResult->iHouseNumber = closestHouseNumber($aPlaceTiger);
|
||||
$iRndNum = max(0, round($aPlaceTiger['fhnr'] / $aPlaceTiger['step']) * $aPlaceTiger['step']);
|
||||
$oResult->iHouseNumber = $aPlaceTiger['startnumber'] + $iRndNum;
|
||||
if ($oResult->iHouseNumber > $aPlaceTiger['endnumber']) {
|
||||
$oResult->iHouseNumber = $aPlaceTiger['endnumber'];
|
||||
}
|
||||
$iRankAddress = 30;
|
||||
}
|
||||
}
|
||||
@@ -345,7 +367,7 @@ class ReverseGeocode
|
||||
// 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
|
||||
// Therefore allow an interpolation line to take precedence
|
||||
// even when the street is closer.
|
||||
$fDistance = $iRankAddress < 28 ? 0.001 : $aPlace['distance'];
|
||||
}
|
||||
@@ -355,7 +377,11 @@ class ReverseGeocode
|
||||
|
||||
if ($aHouse) {
|
||||
$oResult = new Result($aHouse['place_id'], Result::TABLE_OSMLINE);
|
||||
$oResult->iHouseNumber = closestHouseNumber($aHouse);
|
||||
$iRndNum = max(0, round($aHouse['fhnr'] / $aHouse['step']) * $aHouse['step']);
|
||||
$oResult->iHouseNumber = $aHouse['startnumber'] + $iRndNum;
|
||||
if ($oResult->iHouseNumber > $aHouse['endnumber']) {
|
||||
$oResult->iHouseNumber = $aHouse['endnumber'];
|
||||
}
|
||||
$aPlace = $aHouse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -228,7 +236,7 @@ class SearchDescription
|
||||
* Add the given full-word token to the list of terms to search for in the
|
||||
* name.
|
||||
*
|
||||
* @param interger iId ID of term to add.
|
||||
* @param integer iId ID of term to add.
|
||||
* @param bool bRareName True if the term is infrequent enough to not
|
||||
* require other constraints for efficient search.
|
||||
*/
|
||||
@@ -256,6 +264,8 @@ class SearchDescription
|
||||
{
|
||||
if (empty($this->aName)) {
|
||||
$this->bNameNeedsAddress = $bNeedsAddress;
|
||||
} elseif ($bSearchable && count($this->aName) >= 2) {
|
||||
$this->bNameNeedsAddress = false;
|
||||
} else {
|
||||
$this->bNameNeedsAddress &= $bNeedsAddress;
|
||||
}
|
||||
@@ -377,7 +387,7 @@ class SearchDescription
|
||||
*
|
||||
* @return mixed[] An array with two fields: IDs contains the list of
|
||||
* matching place IDs and houseNumber the houseNumber
|
||||
* if appicable or -1 if not.
|
||||
* if applicable or -1 if not.
|
||||
*/
|
||||
public function query(&$oDB, $iMinRank, $iMaxRank, $iLimit)
|
||||
{
|
||||
@@ -412,28 +422,6 @@ class SearchDescription
|
||||
$iLimit
|
||||
);
|
||||
|
||||
// Now search for housenumber, if housenumber provided. Can be zero.
|
||||
if (($this->sHouseNumber || $this->sHouseNumber === '0') && !empty($aResults)) {
|
||||
$aHnResults = $this->queryHouseNumber($oDB, $aResults);
|
||||
|
||||
// Downgrade the rank of the street results, they are missing
|
||||
// the housenumber. Also drop POI places (rank 30) here, they
|
||||
// cannot be a parent place and therefore must not be shown
|
||||
// as a result for a search with a missing housenumber.
|
||||
foreach ($aResults as $oRes) {
|
||||
if ($oRes->iAddressRank < 28) {
|
||||
if ($oRes->iAddressRank >= 26) {
|
||||
$oRes->iResultRank++;
|
||||
} else {
|
||||
$oRes->iResultRank += 2;
|
||||
}
|
||||
$aHnResults[$oRes->iId] = $oRes;
|
||||
}
|
||||
}
|
||||
|
||||
$aResults = $aHnResults;
|
||||
}
|
||||
|
||||
// finally get POIs if requested
|
||||
if ($this->sClass && !empty($aResults)) {
|
||||
$aResults = $this->queryPoiByOperator($oDB, $aResults, $iLimit);
|
||||
@@ -579,41 +567,6 @@ class SearchDescription
|
||||
$aTerms = array();
|
||||
$aOrder = array();
|
||||
|
||||
// Sort by existence of the requested house number but only if not
|
||||
// too many results are expected for the street, i.e. if the result
|
||||
// will be narrowed down by an address. Remember that with ordering
|
||||
// every single result has to be checked.
|
||||
if ($this->sHouseNumber && ($this->bRareName || !empty($this->aAddress) || $this->sPostcode)) {
|
||||
$sHouseNumberRegex = $oDB->getDBQuoted('\\\\m'.$this->sHouseNumber.'\\\\M');
|
||||
|
||||
// Housenumbers on streets and places.
|
||||
$sChildHnr = 'SELECT * FROM placex WHERE parent_place_id = search_name.place_id';
|
||||
$sChildHnr .= ' AND housenumber ~* E'.$sHouseNumberRegex;
|
||||
// Interpolations on streets and places.
|
||||
if (preg_match('/^[0-9]+$/', $this->sHouseNumber)) {
|
||||
$sIpolHnr = 'SELECT * FROM location_property_osmline ';
|
||||
$sIpolHnr .= 'WHERE parent_place_id = search_name.place_id ';
|
||||
$sIpolHnr .= ' AND startnumber is not NULL';
|
||||
$sIpolHnr .= ' AND '.$this->sHouseNumber.'>=startnumber ';
|
||||
$sIpolHnr .= ' AND '.$this->sHouseNumber.'<=endnumber ';
|
||||
} else {
|
||||
$sIpolHnr = false;
|
||||
}
|
||||
// Housenumbers on the object iteself for unlisted places.
|
||||
$sSelfHnr = 'SELECT * FROM placex WHERE place_id = search_name.place_id';
|
||||
$sSelfHnr .= ' AND housenumber ~* E'.$sHouseNumberRegex;
|
||||
|
||||
$sSql = '(CASE WHEN address_rank = 30 THEN EXISTS('.$sSelfHnr.') ';
|
||||
$sSql .= ' ELSE EXISTS('.$sChildHnr.') ';
|
||||
if ($sIpolHnr) {
|
||||
$sSql .= 'OR EXISTS('.$sIpolHnr.') ';
|
||||
}
|
||||
$sSql .= 'END) DESC';
|
||||
|
||||
|
||||
$aOrder[] = $sSql;
|
||||
}
|
||||
|
||||
if (!empty($this->aName)) {
|
||||
$aTerms[] = 'name_vector @> '.$oDB->getArraySQL($this->aName);
|
||||
}
|
||||
@@ -659,10 +612,6 @@ class SearchDescription
|
||||
$aTerms[] = 'centroid && '.$this->oContext->sqlViewboxSmall;
|
||||
}
|
||||
|
||||
if ($this->oContext->hasNearPoint()) {
|
||||
$aOrder[] = $this->oContext->distanceSQL('centroid');
|
||||
}
|
||||
|
||||
if ($this->sHouseNumber) {
|
||||
$sImportanceSQL = '- abs(26 - address_rank) + 3';
|
||||
} else {
|
||||
@@ -685,122 +634,128 @@ class SearchDescription
|
||||
$sExactMatchSQL = '0::int as exactmatch';
|
||||
}
|
||||
|
||||
if ($this->sHouseNumber || $this->sClass) {
|
||||
$iLimit = 40;
|
||||
if (empty($aTerms)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$aResults = array();
|
||||
if ($this->hasHousenumber()) {
|
||||
$sHouseNumberRegex = $oDB->getDBQuoted('\\\\m'.$this->sHouseNumber.'\\\\M');
|
||||
|
||||
if (!empty($aTerms)) {
|
||||
$sSQL = 'SELECT place_id, address_rank,'.$sExactMatchSQL;
|
||||
// Housenumbers on streets and places.
|
||||
$sPlacexSql = 'SELECT array_agg(place_id) FROM placex';
|
||||
$sPlacexSql .= ' WHERE parent_place_id = sin.place_id AND sin.address_rank < 30';
|
||||
$sPlacexSql .= $this->oContext->excludeSQL(' AND place_id');
|
||||
$sPlacexSql .= ' and housenumber ~* E'.$sHouseNumberRegex;
|
||||
|
||||
// Interpolations on streets and places.
|
||||
$sInterpolSql = 'null';
|
||||
$sTigerSql = 'null';
|
||||
if (preg_match('/^[0-9]+$/', $this->sHouseNumber)) {
|
||||
$sIpolHnr = 'WHERE parent_place_id = sin.place_id ';
|
||||
$sIpolHnr .= ' AND startnumber is not NULL AND sin.address_rank < 30';
|
||||
$sIpolHnr .= ' AND '.$this->sHouseNumber.' between startnumber and endnumber';
|
||||
$sIpolHnr .= ' AND ('.$this->sHouseNumber.' - startnumber) % step = 0';
|
||||
|
||||
$sInterpolSql = 'SELECT array_agg(place_id) FROM location_property_osmline '.$sIpolHnr;
|
||||
if (CONST_Use_US_Tiger_Data) {
|
||||
$sTigerSql = 'SELECT array_agg(place_id) FROM location_property_tiger '.$sIpolHnr;
|
||||
$sTigerSql .= " and sin.country_code = 'us'";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sClass) {
|
||||
$iLimit = 40;
|
||||
}
|
||||
|
||||
$sSelfHnr = 'SELECT * FROM placex WHERE place_id = search_name.place_id';
|
||||
$sSelfHnr .= ' AND housenumber ~* E'.$sHouseNumberRegex;
|
||||
|
||||
$aTerms[] = '(address_rank < 30 or exists('.$sSelfHnr.'))';
|
||||
|
||||
|
||||
$sSQL = 'SELECT sin.*, ';
|
||||
$sSQL .= '('.$sPlacexSql.') as placex_hnr, ';
|
||||
$sSQL .= '('.$sInterpolSql.') as interpol_hnr, ';
|
||||
$sSQL .= '('.$sTigerSql.') as tiger_hnr ';
|
||||
$sSQL .= ' FROM (';
|
||||
$sSQL .= ' SELECT place_id, address_rank, country_code,'.$sExactMatchSQL.',';
|
||||
$sSQL .= ' CASE WHEN importance = 0 OR importance IS NULL';
|
||||
$sSQL .= ' THEN 0.75001-(search_rank::float/40) ELSE importance END as importance';
|
||||
$sSQL .= ' FROM search_name';
|
||||
$sSQL .= ' WHERE '.join(' and ', $aTerms);
|
||||
$sSQL .= ' ORDER BY '.join(', ', $aOrder);
|
||||
$sSQL .= ' LIMIT 40000';
|
||||
$sSQL .= ') as sin';
|
||||
$sSQL .= ' ORDER BY address_rank = 30 desc, placex_hnr, interpol_hnr, tiger_hnr,';
|
||||
$sSQL .= ' importance';
|
||||
$sSQL .= ' LIMIT '.$iLimit;
|
||||
} else {
|
||||
if ($this->sClass) {
|
||||
$iLimit = 40;
|
||||
}
|
||||
|
||||
$sSQL = 'SELECT place_id, address_rank, '.$sExactMatchSQL;
|
||||
$sSQL .= ' FROM search_name';
|
||||
$sSQL .= ' WHERE '.join(' and ', $aTerms);
|
||||
$sSQL .= ' ORDER BY '.join(', ', $aOrder);
|
||||
$sSQL .= ' LIMIT '.$iLimit;
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
private function queryHouseNumber(&$oDB, $aRoadPlaceIDs)
|
||||
{
|
||||
$aResults = array();
|
||||
$sRoadPlaceIDs = Result::joinIdsByTableMaxRank(
|
||||
$aRoadPlaceIDs,
|
||||
Result::TABLE_PLACEX,
|
||||
27
|
||||
);
|
||||
$sPOIPlaceIDs = Result::joinIdsByTableMinRank(
|
||||
$aRoadPlaceIDs,
|
||||
Result::TABLE_PLACEX,
|
||||
30
|
||||
);
|
||||
|
||||
$aIDCondition = array();
|
||||
if ($sRoadPlaceIDs) {
|
||||
$aIDCondition[] = 'parent_place_id in ('.$sRoadPlaceIDs.')';
|
||||
}
|
||||
if ($sPOIPlaceIDs) {
|
||||
$aIDCondition[] = 'place_id in ('.$sPOIPlaceIDs.')';
|
||||
}
|
||||
|
||||
if (empty($aIDCondition)) {
|
||||
return $aResults;
|
||||
}
|
||||
|
||||
$sHouseNumberRegex = $oDB->getDBQuoted('\\\\m'.$this->sHouseNumber.'\\\\M');
|
||||
$sSQL = 'SELECT place_id FROM placex WHERE';
|
||||
$sSQL .= ' housenumber ~* E'.$sHouseNumberRegex;
|
||||
$sSQL .= ' AND ('.join(' OR ', $aIDCondition).')';
|
||||
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
// XXX should inherit the exactMatches from its parent
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$aResults[$iPlaceId] = new Result($iPlaceId);
|
||||
}
|
||||
$aDBResults = $oDB->getAll($sSQL, null, 'Could not get places for search terms.');
|
||||
|
||||
$bIsIntHouseNumber= (bool) preg_match('/[0-9]+/', $this->sHouseNumber);
|
||||
$iHousenumber = intval($this->sHouseNumber);
|
||||
if ($bIsIntHouseNumber && $sRoadPlaceIDs && empty($aResults)) {
|
||||
// if nothing found, search in the interpolation line table
|
||||
$sSQL = 'SELECT distinct place_id FROM location_property_osmline';
|
||||
$sSQL .= ' WHERE startnumber is not NULL';
|
||||
$sSQL .= ' AND parent_place_id in ('.$sRoadPlaceIDs.') AND (';
|
||||
if ($iHousenumber % 2 == 0) {
|
||||
// If housenumber is even, look for housenumber in streets
|
||||
// with interpolationtype even or all.
|
||||
$sSQL .= "interpolationtype='even'";
|
||||
} else {
|
||||
// Else look for housenumber with interpolationtype odd or all.
|
||||
$sSQL .= "interpolationtype='odd'";
|
||||
$aResults = array();
|
||||
|
||||
foreach ($aDBResults as $aResult) {
|
||||
$oResult = new Result($aResult['place_id']);
|
||||
$oResult->iExactMatches = $aResult['exactmatch'];
|
||||
$oResult->iAddressRank = $aResult['address_rank'];
|
||||
|
||||
$bNeedResult = true;
|
||||
if ($this->hasHousenumber() && $aResult['address_rank'] < 30) {
|
||||
if ($aResult['placex_hnr']) {
|
||||
foreach (explode(',', substr($aResult['placex_hnr'], 1, -1)) as $sPlaceID) {
|
||||
$iPlaceID = intval($sPlaceID);
|
||||
$oHnrResult = new Result($iPlaceID);
|
||||
$oHnrResult->iExactMatches = $aResult['exactmatch'];
|
||||
$oHnrResult->iAddressRank = 30;
|
||||
$aResults[$iPlaceID] = $oHnrResult;
|
||||
$bNeedResult = false;
|
||||
}
|
||||
}
|
||||
if ($aResult['interpol_hnr']) {
|
||||
foreach (explode(',', substr($aResult['interpol_hnr'], 1, -1)) as $sPlaceID) {
|
||||
$iPlaceID = intval($sPlaceID);
|
||||
$oHnrResult = new Result($iPlaceID, Result::TABLE_OSMLINE);
|
||||
$oHnrResult->iExactMatches = $aResult['exactmatch'];
|
||||
$oHnrResult->iAddressRank = 30;
|
||||
$oHnrResult->iHouseNumber = intval($this->sHouseNumber);
|
||||
$aResults[$iPlaceID] = $oHnrResult;
|
||||
$bNeedResult = false;
|
||||
}
|
||||
}
|
||||
if ($aResult['tiger_hnr']) {
|
||||
foreach (explode(',', substr($aResult['tiger_hnr'], 1, -1)) as $sPlaceID) {
|
||||
$iPlaceID = intval($sPlaceID);
|
||||
$oHnrResult = new Result($iPlaceID, Result::TABLE_TIGER);
|
||||
$oHnrResult->iExactMatches = $aResult['exactmatch'];
|
||||
$oHnrResult->iAddressRank = 30;
|
||||
$oHnrResult->iHouseNumber = intval($this->sHouseNumber);
|
||||
$aResults[$iPlaceID] = $oHnrResult;
|
||||
$bNeedResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($aResult['address_rank'] < 26) {
|
||||
$oResult->iResultRank += 2;
|
||||
} else {
|
||||
$oResult->iResultRank++;
|
||||
}
|
||||
}
|
||||
$sSQL .= " or interpolationtype='all') and ";
|
||||
$sSQL .= $iHousenumber.'>=startnumber and ';
|
||||
$sSQL .= $iHousenumber.'<=endnumber';
|
||||
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$oResult = new Result($iPlaceId, Result::TABLE_OSMLINE);
|
||||
$oResult->iHouseNumber = $iHousenumber;
|
||||
$aResults[$iPlaceId] = $oResult;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing found then search in Tiger data (location_property_tiger)
|
||||
if (CONST_Use_US_Tiger_Data && $sRoadPlaceIDs && $bIsIntHouseNumber && empty($aResults)) {
|
||||
$sSQL = 'SELECT place_id FROM location_property_tiger';
|
||||
$sSQL .= ' WHERE parent_place_id in ('.$sRoadPlaceIDs.') and (';
|
||||
if ($iHousenumber % 2 == 0) {
|
||||
$sSQL .= "interpolationtype='even'";
|
||||
} else {
|
||||
$sSQL .= "interpolationtype='odd'";
|
||||
}
|
||||
$sSQL .= " or interpolationtype='all') and ";
|
||||
$sSQL .= $iHousenumber.'>=startnumber and ';
|
||||
$sSQL .= $iHousenumber.'<=endnumber';
|
||||
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
|
||||
|
||||
Debug::printSQL($sSQL);
|
||||
|
||||
foreach ($oDB->getCol($sSQL) as $iPlaceId) {
|
||||
$oResult = new Result($iPlaceId, Result::TABLE_TIGER);
|
||||
$oResult->iHouseNumber = $iHousenumber;
|
||||
$aResults[$iPlaceId] = $oResult;
|
||||
if ($bNeedResult) {
|
||||
$aResults[$aResult['place_id']] = $oResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,6 +807,7 @@ class SearchDescription
|
||||
$sSQL = 'SELECT geometry FROM placex';
|
||||
$sSQL .= " WHERE place_id in ($sPlaceIDs)";
|
||||
$sSQL .= " AND rank_search < $iMaxRank + 5";
|
||||
$sSQL .= ' AND ST_Area(Box2d(geometry)) < 20';
|
||||
$sSQL .= " AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
|
||||
$sSQL .= ' ORDER BY rank_search ASC ';
|
||||
$sSQL .= ' LIMIT 1';
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
@@ -112,13 +120,18 @@ class SimpleWordList
|
||||
return array_slice($aWordSets, 0, SimpleWordList::MAX_WORDSETS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom search routine which takes two arrays. The array with the fewest
|
||||
* items wins. If same number of items then the one with the longest first
|
||||
* element wins.
|
||||
*/
|
||||
public static function cmpByArraylen($aA, $aB)
|
||||
{
|
||||
$iALen = count($aA);
|
||||
$iBLen = count($aB);
|
||||
|
||||
if ($iALen == $iBLen) {
|
||||
return 0;
|
||||
return strlen($aB[0]) <=> strlen($aA[0]);
|
||||
}
|
||||
|
||||
return ($iALen < $iBLen) ? -1 : 1;
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
@@ -9,7 +17,7 @@ class Postcode
|
||||
{
|
||||
/// Database word id, if available.
|
||||
private $iId;
|
||||
/// Full nomralized postcode (upper cased).
|
||||
/// Full normalized postcode (upper cased).
|
||||
private $sPostcode;
|
||||
// Optional country code the postcode belongs to (currently unused).
|
||||
private $sCountryCode;
|
||||
@@ -17,7 +25,12 @@ class Postcode
|
||||
public function __construct($iId, $sPostcode, $sCountryCode = '')
|
||||
{
|
||||
$this->iId = $iId;
|
||||
$this->sPostcode = $sPostcode;
|
||||
$iSplitPos = strpos($sPostcode, '@');
|
||||
if ($iSplitPos === false) {
|
||||
$this->sPostcode = $sPostcode;
|
||||
} else {
|
||||
$this->sPostcode = substr($sPostcode, 0, $iSplitPos);
|
||||
}
|
||||
$this->sCountryCode = empty($sCountryCode) ? '' : $sCountryCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
@@ -61,19 +69,31 @@ class SpecialTerm
|
||||
*/
|
||||
public function extendSearch($oSearch, $oPosition)
|
||||
{
|
||||
$iSearchCost = 2;
|
||||
$iSearchCost = 0;
|
||||
|
||||
$iOp = $this->iOperator;
|
||||
if ($iOp == \Nominatim\Operator::NONE) {
|
||||
if ($oSearch->hasName() || $oSearch->getContext()->isBoundedSearch()) {
|
||||
if ($oPosition->isFirstToken()
|
||||
|| $oSearch->hasName()
|
||||
|| $oSearch->getContext()->isBoundedSearch()
|
||||
) {
|
||||
$iOp = \Nominatim\Operator::NAME;
|
||||
$iSearchCost += 3;
|
||||
} else {
|
||||
$iOp = \Nominatim\Operator::NEAR;
|
||||
$iSearchCost += 2;
|
||||
$iSearchCost += 4;
|
||||
if (!$oPosition->isFirstToken()) {
|
||||
$iSearchCost += 3;
|
||||
}
|
||||
}
|
||||
} elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) {
|
||||
} elseif ($oPosition->isFirstToken()) {
|
||||
$iSearchCost += 2;
|
||||
} elseif ($oPosition->isLastToken()) {
|
||||
$iSearchCost += 4;
|
||||
} else {
|
||||
$iSearchCost += 6;
|
||||
}
|
||||
|
||||
if ($oSearch->hasHousenumber()) {
|
||||
$iSearchCost ++;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
namespace Nominatim\Token;
|
||||
|
||||
@@ -54,7 +62,7 @@ class Word
|
||||
public function extendSearch($oSearch, $oPosition)
|
||||
{
|
||||
// Full words can only be a name if they appear at the beginning
|
||||
// of the phrase. In structured search the name must forcably in
|
||||
// of the phrase. In structured search the name must forcibly in
|
||||
// the first phrase. In unstructured search it may be in a later
|
||||
// phrase when the first phrase is a house number.
|
||||
if ($oSearch->hasName()
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
<?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(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/ParameterParser.php');
|
||||
ini_set('memory_limit', '800M');
|
||||
|
||||
$aCMDOptions = array(
|
||||
'Export addresses as CSV file from a Nominatim database',
|
||||
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('output-type', '', 0, 1, 1, 1, 'str', 'Type of places to output (see below)'),
|
||||
array('output-format', '', 0, 1, 1, 1, 'str', 'Column mapping (see below)'),
|
||||
array('output-all-postcodes', '', 0, 1, 0, 0, 'bool', 'List all postcodes for address instead of just the most likely one'),
|
||||
array('language', '', 0, 1, 1, 1, 'str', 'Preferred language for output (local name, if omitted)'),
|
||||
array('restrict-to-country', '', 0, 1, 1, 1, 'str', 'Export only objects within country (country code)'),
|
||||
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",
|
||||
'can be merged into one column by simply using a comma-separated list.',
|
||||
"\nDefault output-type: street",
|
||||
'Default output format: street;suburb;city;county;state;country'
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
loadSettings($aCMDResult['project-dir'] ?? getcwd());
|
||||
|
||||
$aRankmap = array(
|
||||
'continent' => 1,
|
||||
'country' => 4,
|
||||
'state' => 8,
|
||||
'county' => 12,
|
||||
'city' => 16,
|
||||
'suburb' => 20,
|
||||
'street' => 26,
|
||||
'path' => 27
|
||||
);
|
||||
|
||||
$oDB = new Nominatim\DB();
|
||||
$oDB->connect();
|
||||
|
||||
if (isset($aCMDResult['output-type'])) {
|
||||
if (!isset($aRankmap[$aCMDResult['output-type']])) {
|
||||
fail('unknown output-type: '.$aCMDResult['output-type']);
|
||||
}
|
||||
$iOutputRank = $aRankmap[$aCMDResult['output-type']];
|
||||
} else {
|
||||
$iOutputRank = $aRankmap['street'];
|
||||
}
|
||||
|
||||
|
||||
// Preferred language
|
||||
$oParams = new Nominatim\ParameterParser();
|
||||
if (!isset($aCMDResult['language'])) {
|
||||
$aCMDResult['language'] = 'xx';
|
||||
}
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages($aCMDResult['language']);
|
||||
$sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder));
|
||||
|
||||
// output formatting: build up a lookup table that maps address ranks to columns
|
||||
$aColumnMapping = array();
|
||||
$iNumCol = 0;
|
||||
if (!isset($aCMDResult['output-format'])) {
|
||||
$aCMDResult['output-format'] = 'street;suburb;city;county;state;country';
|
||||
}
|
||||
foreach (preg_split('/\s*;\s*/', $aCMDResult['output-format']) as $sColumn) {
|
||||
$bHasData = false;
|
||||
foreach (preg_split('/\s*,\s*/', $sColumn) as $sRank) {
|
||||
if ($sRank == 'postcode' || $sRank == 'placeid') {
|
||||
$aColumnMapping[$sRank] = $iNumCol;
|
||||
$bHasData = true;
|
||||
} elseif (isset($aRankmap[$sRank])) {
|
||||
$iRank = $aRankmap[$sRank];
|
||||
if ($iRank <= $iOutputRank) {
|
||||
$aColumnMapping[(string)$iRank] = $iNumCol;
|
||||
$bHasData = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($bHasData) {
|
||||
$iNumCol++;
|
||||
}
|
||||
}
|
||||
|
||||
// build the query for objects
|
||||
$sPlacexSQL = 'select min(place_id) as place_id, ';
|
||||
$sPlacexSQL .= 'array_agg(place_id) as place_ids, ';
|
||||
$sPlacexSQL .= 'country_code as cc, ';
|
||||
$sPlacexSQL .= 'postcode, ';
|
||||
// get the address places excluding postcodes
|
||||
$sPlacexSQL .= 'array(select address_place_id from place_addressline a';
|
||||
$sPlacexSQL .= ' where a.place_id = placex.place_id and isaddress';
|
||||
$sPlacexSQL .= ' and address_place_id != placex.place_id';
|
||||
$sPlacexSQL .= ' and not cached_rank_address in (5,11)';
|
||||
$sPlacexSQL .= ' and cached_rank_address > 2 order by cached_rank_address)';
|
||||
$sPlacexSQL .= ' as address';
|
||||
$sPlacexSQL .= ' from placex where name is not null and linked_place_id is null';
|
||||
|
||||
$sPlacexSQL .= ' and rank_address = '.$iOutputRank;
|
||||
|
||||
if (isset($aCMDResult['restrict-to-country'])) {
|
||||
$sPlacexSQL .= ' and country_code = '.$oDB->getDBQuoted($aCMDResult['restrict-to-country']);
|
||||
}
|
||||
|
||||
// restriction to parent place id
|
||||
$sParentId = false;
|
||||
$sOsmType = false;
|
||||
|
||||
if (isset($aCMDResult['restrict-to-osm-node'])) {
|
||||
$sOsmType = 'N';
|
||||
$sOsmId = $aCMDResult['restrict-to-osm-node'];
|
||||
}
|
||||
if (isset($aCMDResult['restrict-to-osm-way'])) {
|
||||
$sOsmType = 'W';
|
||||
$sOsmId = $aCMDResult['restrict-to-osm-way'];
|
||||
}
|
||||
if (isset($aCMDResult['restrict-to-osm-relation'])) {
|
||||
$sOsmType = 'R';
|
||||
$sOsmId = $aCMDResult['restrict-to-osm-relation'];
|
||||
}
|
||||
if ($sOsmType) {
|
||||
$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) {
|
||||
$sPlacexSQL .= ' and place_id in (select place_id from place_addressline where address_place_id = '.$sParentId.' and isaddress)';
|
||||
}
|
||||
|
||||
$sPlacexSQL .= " group by name->'name', address, postcode, country_code, placex.place_id";
|
||||
|
||||
// Iterate over placeids
|
||||
// to get further hierarchical information
|
||||
//var_dump($sPlacexSQL);
|
||||
$oResults = $oDB->getQueryStatement($sPlacexSQL);
|
||||
$fOutstream = fopen('php://output', 'w');
|
||||
while ($aRow = $oResults->fetch()) {
|
||||
$iPlaceID = $aRow['place_id'];
|
||||
$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, array('place_id' => $iPlaceID));
|
||||
|
||||
$aOutput = array_fill(0, $iNumCol, '');
|
||||
// output address parts
|
||||
foreach ($aAddressLines as $aAddress) {
|
||||
if (isset($aColumnMapping[$aAddress['rank_address']])) {
|
||||
$aOutput[$aColumnMapping[$aAddress['rank_address']]] = $aAddress['localname'];
|
||||
}
|
||||
}
|
||||
// output postcode
|
||||
if (isset($aColumnMapping['postcode'])) {
|
||||
if ($aCMDResult['output-all-postcodes']) {
|
||||
$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 (:first_place_id)) ';
|
||||
$sSQL .= 'group by postcode order by count(*) desc limit 1';
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
if (isset($aColumnMapping['placeid'])) {
|
||||
$aOutput[$aColumnMapping['placeid']] = substr($aRow['place_ids'], 1, -1);
|
||||
}
|
||||
fputcsv($fOutstream, $aOutput);
|
||||
}
|
||||
fclose($fOutstream);
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
@define('CONST_LibDir', dirname(dirname(__FILE__)));
|
||||
|
||||
require_once(CONST_LibDir.'/init-cmd.php');
|
||||
require_once(CONST_LibDir.'/log.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_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_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
|
||||
@define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
|
||||
@define('CONST_TokenizerDir', CONST_InstallDir.'/tokenizer');
|
||||
|
||||
require_once(CONST_LibDir.'/Geocode.php');
|
||||
|
||||
$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";
|
||||
}
|
||||
|
||||
$oTokenizer = new \Nominatim\Tokenizer($oDB);
|
||||
|
||||
$aWords = $oTokenizer->mostFrequentWords(1000);
|
||||
|
||||
$sSQL = 'SELECT word FROM word WHERE word is not null ORDER BY search_name_count DESC LIMIT 1000';
|
||||
foreach ($aWords as $sWord) {
|
||||
if ($bVerbose) {
|
||||
echo "$sWord = ";
|
||||
}
|
||||
|
||||
$oGeocode->setLanguagePreference(array('en'));
|
||||
$oGeocode->setQuery($sWord);
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
print_results($aSearchResults, $bVerbose);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
require_once(CONST_LibDir.'/Shell.php');
|
||||
|
||||
@@ -98,7 +106,7 @@ function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnkn
|
||||
showUsage($aSpec, $bExitOnError, 'Option \''.$aLine[0].'\' is missing');
|
||||
}
|
||||
if ($aCounts[$aLine[0]] > $aLine[3]) {
|
||||
showUsage($aSpec, $bExitOnError, 'Option \''.$aLine[0].'\' is pressent too many times');
|
||||
showUsage($aSpec, $bExitOnError, 'Option \''.$aLine[0].'\' is present too many times');
|
||||
}
|
||||
if ($aLine[6] == 'bool' && !array_key_exists($aLine[0], $aResult)) {
|
||||
$aResult[$aLine[0]] = false;
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
require('Symfony/Component/Dotenv/autoload.php');
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
require_once('init.php');
|
||||
require_once('cmd.php');
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
require_once('init.php');
|
||||
require_once('ParameterParser.php');
|
||||
@@ -18,7 +26,7 @@ function userError($sMsg)
|
||||
|
||||
function exception_handler_json($exception)
|
||||
{
|
||||
http_response_code($exception->getCode());
|
||||
http_response_code($exception->getCode() == 0 ? 500 : $exception->getCode());
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
include(CONST_LibDir.'/template/error-json.php');
|
||||
exit();
|
||||
@@ -26,7 +34,7 @@ function exception_handler_json($exception)
|
||||
|
||||
function exception_handler_xml($exception)
|
||||
{
|
||||
http_response_code($exception->getCode());
|
||||
http_response_code($exception->getCode() == 0 ? 500 : $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');
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
require_once(CONST_LibDir.'/lib.php');
|
||||
require_once(CONST_LibDir.'/DB.php');
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
function loadSettings($sProjectDir)
|
||||
{
|
||||
@define('CONST_InstallDir', $sProjectDir);
|
||||
// Temporary hack to set the direcory via environment instead of
|
||||
// Temporary hack to set the directory via environment instead of
|
||||
// the installed scripts. Neither setting is part of the official
|
||||
// set of settings.
|
||||
defined('CONST_ConfigDir') or define('CONST_ConfigDir', $_SERVER['NOMINATIM_CONFIGDIR']);
|
||||
@@ -198,24 +206,34 @@ function parseLatLon($sQuery)
|
||||
return array($sFound, $fQueryLat, $fQueryLon);
|
||||
}
|
||||
|
||||
function closestHouseNumber($aRow)
|
||||
function addressRankToGeocodeJsonType($iAddressRank)
|
||||
{
|
||||
$fHouse = $aRow['startnumber']
|
||||
+ ($aRow['endnumber'] - $aRow['startnumber']) * $aRow['fraction'];
|
||||
|
||||
switch ($aRow['interpolationtype']) {
|
||||
case 'odd':
|
||||
$iHn = (int)($fHouse/2) * 2 + 1;
|
||||
break;
|
||||
case 'even':
|
||||
$iHn = (int)(round($fHouse/2)) * 2;
|
||||
break;
|
||||
default:
|
||||
$iHn = (int)(round($fHouse));
|
||||
break;
|
||||
if ($iAddressRank >= 29 && $iAddressRank <= 30) {
|
||||
return 'house';
|
||||
}
|
||||
if ($iAddressRank >= 26 && $iAddressRank < 28) {
|
||||
return 'street';
|
||||
}
|
||||
if ($iAddressRank >= 22 && $iAddressRank < 26) {
|
||||
return 'locality';
|
||||
}
|
||||
if ($iAddressRank >= 17 && $iAddressRank < 22) {
|
||||
return 'district';
|
||||
}
|
||||
if ($iAddressRank >= 13 && $iAddressRank < 17) {
|
||||
return 'city';
|
||||
}
|
||||
if ($iAddressRank >= 10 && $iAddressRank < 13) {
|
||||
return 'county';
|
||||
}
|
||||
if ($iAddressRank >= 5 && $iAddressRank < 10) {
|
||||
return 'state';
|
||||
}
|
||||
if ($iAddressRank >= 4 && $iAddressRank < 5) {
|
||||
return 'country';
|
||||
}
|
||||
|
||||
return max(min($aRow['endnumber'], $iHn), $aRow['startnumber']);
|
||||
return 'locality';
|
||||
}
|
||||
|
||||
if (!function_exists('array_key_last')) {
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
|
||||
function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
|
||||
@@ -70,7 +78,7 @@ function logEnd(&$oDB, $hLog, $iNumResults)
|
||||
|
||||
if (CONST_Log_DB) {
|
||||
$aEndTime = explode('.', $fEndTime);
|
||||
if (!$aEndTime[1]) {
|
||||
if (!isset($aEndTime[1])) {
|
||||
$aEndTime[1] = '0';
|
||||
}
|
||||
$sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
|
||||
function formatOSMType($sType, $bIncludeExternal = true)
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
function getOsm2pgsqlBinary()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
// https://github.com/geocoders/geocodejson-spec/
|
||||
|
||||
@@ -28,7 +36,10 @@ if (empty($aPlace)) {
|
||||
$aFilteredPlaces['properties']['geocoding']['osm_id'] = $aPlace['osm_id'];
|
||||
}
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['type'] = $aPlace['type'];
|
||||
$aFilteredPlaces['properties']['geocoding']['osm_key'] = $aPlace['class'];
|
||||
$aFilteredPlaces['properties']['geocoding']['osm_value'] = $aPlace['type'];
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['type'] = addressRankToGeocodeJsonType($aPlace['rank_address']);
|
||||
|
||||
$aFilteredPlaces['properties']['geocoding']['accuracy'] = (int) $fDistance;
|
||||
|
||||
@@ -48,7 +59,7 @@ if (empty($aPlace)) {
|
||||
}
|
||||
|
||||
if (isset($aPlace['asgeojson'])) {
|
||||
$aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
|
||||
$aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson'], true);
|
||||
} else {
|
||||
$aFilteredPlaces['geometry'] = array(
|
||||
'type' => 'Point',
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
$aFilteredPlaces = array();
|
||||
|
||||
@@ -57,7 +65,7 @@ if (empty($aPlace)) {
|
||||
}
|
||||
|
||||
if (isset($aPlace['asgeojson'])) {
|
||||
$aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
|
||||
$aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson'], true);
|
||||
} else {
|
||||
$aFilteredPlaces['geometry'] = array(
|
||||
'type' => 'Point',
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
*
|
||||
* This file is part of Nominatim. (https://nominatim.org)
|
||||
*
|
||||
* Copyright (C) 2022 by the Nominatim developer community.
|
||||
* For a full list of authors see the git log.
|
||||
*/
|
||||
|
||||
$aFilteredPlaces = array();
|
||||
|
||||
@@ -55,7 +63,7 @@ if (empty($aPlace)) {
|
||||
}
|
||||
|
||||
if (isset($aPlace['asgeojson'])) {
|
||||
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
|
||||
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson'], true);
|
||||
}
|
||||
|
||||
if (isset($aPlace['assvg'])) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user