mirror of
https://github.com/juancarlospaco/nim-nominatim
synced 2026-01-03 01:44:52 +00:00
No description
| .github | ||
| src | ||
| .gitignore | ||
| LICENSE | ||
| nominatim.nimble | ||
| README.md | ||
nim-nominatim
- OpenStreetMap Nominatim API Lib for Nim, Async & Sync, Pull Requests welcome.
Install
nimble install nominatim
Use
From Nim code:
import nominatim
# Sync Client.
let openstreetmap_client = Nominatim(timeout: 5)
# Searching OpenStreetMap Example.
echo openstreetmap_client.search(query="135+pilkington+avenue,+birmingham").pretty
# Lookup on OpenStreetMap Example.
echo openstreetmap_client.lookup(osm_ids="R146656,W104393803,N240109189").pretty
# Reverse query on OpenStreetMap Example.
echo openstreetmap_client.reverse(lat = -34.44076, lon = -58.70521).pretty
## Async client.
proc async_nominatim() {.async.} =
let
async_nominatim_client = AsyncNominatim(timeout: 9)
async_response = await async_nominatim_client.search(query="135+pilkington+avenue,+birmingham")
echo async_response.pretty
wait_for async_nominatim()
Search as a command line app:
$ ./nominatim --color --lower --timeout=9 --search "135 pilkington avenue, birmingham"
Lookup as a command line app:
$ ./nominatim --color --lower --lookup "R146656,W104393803,N240109189"
Reverse as a command line app:
$ ./nominatim --color --lower --lon=-58.70521 --lat=-34.44076 --reverse "reverse"
Requisites
- None.
API
- The
timeoutargument is on Seconds. - All the responses are JSON,
JsonNodetype. - OpenStreetMap API limits the length of all key and value strings to a maximum of 255 characters.
- For Proxy support define a
Nominatim.proxyorAsyncNominatim.proxyofProxytype. - No OS-specific code, so it should work on Linux, Windows and Mac. Not JS.
Search
search*(this: Nominatim | AsyncNominatim, query: string, api_url = api_url)
thisisNominatim(timeout=int8)for Synchronous code orAsyncNominatim(timeout=int8)for Asynchronous code.queryis an Nominatim query,stringtype, required.api_urlis an Nominatim HTTP API URL,stringtype, optional.
Lookup
lookup*(this: Nominatim | AsyncNominatim, osm_ids: string, addressdetails = true, extratags = true, namedetails = true, email = "", accept_language = "EN", api_url = api_url)
thisisNominatim(timeout=int8)for Synchronous code orAsyncNominatim(timeout=int8)for Asynchronous code.osm_idsis an Nominatim OpenStreetMap IDs,stringtype, comma separated, max 50 items, required.addressdetailsSet totrueto show address details,booltype, optional, defaults totrue.extratagsSet totrueto show extra tags,booltype, optional, defaults totrue.namedetailsSet totrueto show name details,booltype, optional, defaults totrue.emailSet to your email address (for massive heavy use of the API),stringtype, defaults to"", optional.accept_languageSet output spoken language,stringtype, defaults to"EN", optional.api_urlis an Nominatim HTTP API URL,stringtype, optional.
Reverse
reverse*(this: Nominatim | AsyncNominatim, lat: float, lon: float, osm_ids = "", osm_type = ' ', zoom: range[-1..18] = -1, addressdetails = true, extratags = true, namedetails = true, email = "", accept_language = "EN", api_url = api_url)
thisisNominatim(timeout=int8)for Synchronous code orAsyncNominatim(timeout=int8)for Asynchronous code.osm_idsis an Nominatim OpenStreetMap IDs,stringtype, comma separated, max 50 items, required.addressdetailsSet totrueto show address details,booltype, optional, defaults totrue.extratagsSet totrueto show extra tags,booltype, optional, defaults totrue.namedetailsSet totrueto show name details,booltype, optional, defaults totrue.emailSet to your email address (for massive heavy use of the API),stringtype, defaults to"", optional.accept_languageSet output spoken language,stringtype, defaults to"EN", optional.api_urlis an Nominatim HTTP API URL,stringtype, optional.zoomis the Zoom, a positive integer between-1and18,range[-1..18]type, defaults to-1,-1means disabled, optional.latis the Latitude,floattype, required.lonis the Longitude,floattype, required.
