From 032b735a41e865ef0e6e98324d3c2791963bfbfb Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Sun, 21 Apr 2024 14:11:37 +0200 Subject: [PATCH] improve doc Signed-off-by: Frank Villaro-Dixon --- assets/index.html | 34 +++++++++++++++++++++++----------- src/main.rs | 4 ++-- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/assets/index.html b/assets/index.html index 3ef389d..ba418af 100644 --- a/assets/index.html +++ b/assets/index.html @@ -1,5 +1,6 @@ + @@ -12,19 +13,22 @@ background: #f4f4f4; color: #454545; } + header { background: #007BFF; color: #ffffff; padding: 10px 20px; text-align: center; } + section { padding: 20px; margin: 0 10px; background: #ffffff; border-radius: 8px; - box-shadow: 0 2px 5px rgba(0,0,0,0.1); + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } + footer { text-align: center; padding: 10px 0; @@ -34,16 +38,19 @@ bottom: 0; width: 100%; } + code { background: #eee; padding: 2px 5px; border-radius: 3px; } + a { color: #07a; } +

Free Elevation API Service

@@ -55,33 +62,38 @@

API Usage

-

To use the API, make a GET request to this endpoint with the required parameters. Here is an example request:

- https://www.elevation-api.eu/elevation/:lat/:lon +

To use the API, make a GET request to this endpoint with the required parameters. Here is an example request: +

+ https://www.elevation-api.eu/v1/elevation/:lat/:lon[?json]

Parameters:

  • lat - Latitude of the location, WGS-84
  • lon - Longitude of the location, WGS-84
  • +
  • ?json - Append this to have the result retuned as JSON

Response:

The API will return the elevation in meters. For example:

42 -

If the point is not into the DEM dataset, the response code will be 501 (or Null in JSON mode)

+

If the point is not into the DEM dataset, the response code will be 501 (or Null in JSON mode) +

Try it out:

- Get the elevation of the Lake Leman + Get the elevation of the Lake Leman
-

Alternative API endpoints

-

JSON result

-

Append ?json to your query to have the return content as a json payload

+

JSON API endpoint (multi coordinates)

+ You can also request many coordinates at once by using the following endpoint: + https://www.elevation-api.eu/v1/elevation?pts=[[lat1,lon1],[lat2,lon2],[lat3,lon3]]

Example

- https://www.elevation-api.eu/elevation/46.24566/6.17081?json + + https://www.elevation-api.eu/v1/elevation?pts=[[46.24566,6.17081],[46.85499,6.78134]] +

Misc

Data source

The digital elevation data comes from ESA's Copernicus program.

Rate limits

-

Don't be a dick. Less than 10/s is okay

+

Don't be an idiot. Less than 10/s is okay

Contact

For more information, you can reach me at f@vi-di.fr

@@ -89,5 +101,5 @@

© 2024 Frank Villaro-Dixon. No rights reserved

- + \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 15422ee..28241f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,8 +101,8 @@ async fn main() { let serve_dir = ServeDir::new("assets"); let app = Router::::new() - .route("/elevation/:lat/:lon", get(get_elevation)) - .route("/ele", get(get_elevation_js)) + .route("/v1/elevation/:lat/:lon", get(get_elevation)) + .route("/v1/elevation", get(get_elevation_js)) .nest_service("/", serve_dir) .with_state(cache) .layer(