[Geocoding] Batch mode
Marc Tobias
mtm at opencagedata.com
Tue Feb 3 13:45:33 UTC 2015
Hi,
The feature exists, but like you said it's undocumented, we don't
have test for it in the test suite, it's disabled by default and
disabled on http://nominatim.openstreetmap.org/. Still useful if
you have your own Nominatim installation running.
You need to set
@define('CONST_Search_BatchMode', true);
in settings/local.php
Create a data structure like
[
{'q' => 'London' },
{'q' => 'Paris, France' },
{'q' => 'Köln' }
]
then JSON encode it, which looks something like
[{"q":"London"},{"q":"Paris, France"},{"q":"K\u00f6ln"}]
Now create a request where instead of &q= you use &batch=
<your nominatim URL>/search?format=json&batch=
%5B%7B%22q%22%3A%22London%22%7D%2C%7B%22q%22%3A%22Paris%2C%20France%22%7D%2C%7B%22q%22%3A%22K%5Cu00f6ln%22%7D%5D
Other parameters like &countrycode, &viewbox etc still work and
are applied to all queries in the batch.
There is no hard limit in Nominatim how many queries you can have
in one batch. Webservers usually only support URLs of around
2000-4000 characters length though.
In this case on our installation see output like
{
"licence": "Data © OpenStreetMap contributors, ODbL 1.0.
http://www.openstreetmap.org/copyright",
"batch": [
[ 10 London results ],
[ 10 Paris results ],
[ 4 Köln results ]
]
}
marc tobias
http://opencagedata.com
More information about the Geocoding
mailing list