openstreetmap

OpenStreetMap API Lib for Nim


Keywords
openstreetmap, multisync, async, geo, map, api-client, nim, nim-lang
License
MIT
Install
nimble install openstreetmap

Documentation

nim-openstreetmap

OpenStreetMap

Install

  • nimble install openstreetmap

Use

import openstreetmap

# Sync client.
let osm_client = OSM(timeout: 9, username: "user", password: "pass", use_prod_server: true, proxy: nil)
echo $osm_client.get_capabilities()
echo $osm_client.get_bounding_box(90.0, -90.0, 90.0, -90.0)
echo $osm_client.get_permissions()
echo $osm_client.get_changeset(61972594)
echo $osm_client.get_changeset_download(61972594)
echo $osm_client.get_changesets_bbox(90.0, -90.0, 90.0, -90.0)
echo $osm_client.get_changesets_open(true)
echo $osm_client.get_changesets_cid(@[61972594])
echo $osm_client.get_trackpoints(90.0, -90.0, 90.0, -90.0, 1)
echo $osm_client.get_notes(90.0, -90.0, 90.0, -90.0, limit=2)
echo $osm_client.get_notes_search(q="Argentina", limit=2)

# Async client.
proc test {.async.} =
  let
    osm_client = AsyncOSM(timeout: 9, username: "user", password: "pass", use_prod_server: true, proxy: nil)
    async_resp = await osm_client.get_capabilities()
  echo $async_resp

waitFor(test())
# Check the Docs for more API Calls...

API

  • Check the OpenStreetMap Wiki, the Lib is a 1:1 copy of the official Docs.
  • This Library uses API Version 0.6 from Year 2018.
  • Each proc links to the official OSM API docs.
  • All procs should return an XML Object PDocument.
  • The order of the procs follows the order on the OSM Wiki.
  • The naming of the procs follows the naming on the OSM Wiki.
  • The errors on the procs follows the errors on the OSM Wiki.
  • The limit key is limit: range[1..10000] = 100 as documented on the OSM Wiki.
  • API Calls that use HTTP GET start with get_*.
  • API Calls that use HTTP POST start with post_*.
  • API Calls that use HTTP PUT start with put_*.
  • API Calls that use HTTP DELETE start with delete_*.
  • API Calls use the DoNotTrack HTTP Header.
  • The timeout argument is on Seconds.
  • OpenStreetMap API limits the length of all key and value strings to a maximum of 255 characters.
  • For Proxy support define a OSM.proxy or AsyncOSM.proxy of Proxy type.
  • No OS-specific code, so it should work on Linux, Windows and Mac. Not JS.
  • Run the module itself for an Example.

Support

All OpenStreetMap API is supported, except 2 API calls:

FAQ

  • How to Edit the OpenStreetMap using this lib ?.

You must provide a valid active OpenStreetMap User and Password.

  • This works without SSL ?.

No.

  • This works with Asynchronous code ?.

Yes.

  • This works with Synchronous code ?.

Yes.

  • This requires API Key or Login ?.

Yes. User and Password.

  • This requires Credit Card or Payments ?.

No.

  • Why is slow to read data ?.

Use Overpass for Reading. This is optimized for Writing speed.

  • How to Search by Name ?.

Use Nominatim for Search.

  • Can I use the OpenStreetMap data ?.

Yes. You MUST give Credit to OpenStreetMap Contributors!.

  • Can I use a Sandbox fake server for testing purposes ?.

Yes. Set OSM.use_prod_server or AsyncOSM.use_prod_server of bool type, true to use "https://api.openstreetmap.org/api/0.6/", false to use "https://master.apis.dev.openstreetmap.org/api/0.6/".

Requisites

  • None.