open_elevation

OpenStreetMap Elevation API MultiSync Client for Nim


Keywords
openstreetmap, geo, elevation, multisync, async, geospatial, nim, nim-lang
License
MIT
Install
nimble install open_elevation

Documentation

Nim-Open-Elevation

Install

  • nimble install openelevation

Use

import asyncdispatch, json, openelevation

let sample_query = %*{
  "locations":
  [
    {
      "latitude": 10.55,
      "longitude": 10.75
    },
    {
      "latitude": 20.42,
      "longitude": 20.5
    },
    {
      "latitude": 41.161758,
      "longitude": -8.583933
    }
  ]
}  # Example query taken from the Documentation.

## Sync client.
let client = OpenElevation(timeout: 99.byte)
echo client.lookup(42.0, 50.0)              # GET  (1 query max)
echo client.lookup(locations=sample_query)  # POST (multiple queries)

## Async client.
proc async_oe() {.async.} =
  let
    async_client = AsyncOpenElevation(timeout: 99.byte)
    async_response = await async_client.lookup(42.0, 50.0)
  echo async_response.pretty

wait_for async_oe()

# Check the Docs for more API Calls...

Command Line App

  • For Uglyfied JSON use --ugly (does not reduce bandwith usage).
  • The App supports English and Spanish.

1 Query:

./open_elevation --color --lower --timeout=9 --lat=42.5 --lon=55.75

Multiple Queries:

./open_elevation --color --lower --timeout=9 '{"locations":[{"latitude":9,"longitude":10},{"latitude":41.68,"longitude":-8.58}]}'

API

  • API Calls use the DoNotTrack HTTP Header.
  • This Library uses API Version from Year 2018.
  • All procs should return an JSON Object JsonNode type.
  • API Calls use HTTP GET and POST.
  • Coordinates are float32.
  • API Calls are Anonymous and use a blank User-Agent.
  • The timeout argument is on Seconds.
  • For Proxy support define a 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.
  • Run nim doc open_elevation.nim for more Documentation.

FAQ

Click to see FAQ
  • Yo solo hablo Espanol ?

La aplicacion de linea de comandos soporta Espanol.

  • This works without SSL ?.

No.

  • This works with SSL ?.

Yes.

  • This works with Asynchronous code ?.

Yes.

  • This works with Synchronous code ?.

Yes.

  • This requires API Key or Login ?.

No.

  • This requires Credit Card or Payments ?.

No.

  • Can I use the OpenStreetMap data ?.

Yes. You MUST give Credit to OpenStreetMap Contributors!.

  • How to Uglify the output?

--ugly

  • How to Lowercase the output?

--lower

  • How to set a Timeout ?

--timeout=99

  • How to set the Coordinates ?

--lat=15.42 --lon=12.75

  • How to use colors ?

--color

  • How to see the Help ?

--help

Requisites

  • None.