improve doc

Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
Frank Villaro-Dixon 2024-04-21 14:11:37 +02:00
parent 8b85c31411
commit 032b735a41
2 changed files with 25 additions and 13 deletions

View file

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -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;
}
</style>
</head>
<body>
<header>
<h1>Free Elevation API Service</h1>
@ -55,33 +62,38 @@
</section>
<section>
<h2>API Usage</h2>
<p>To use the API, make a GET request to this endpoint with the required parameters. Here is an example request:</p>
<code>https://www.elevation-api.eu/elevation/:lat/:lon</code>
<p>To use the API, make a GET request to this endpoint with the required parameters. Here is an example request:
</p>
<code>https://www.elevation-api.eu/v1/elevation/:lat/:lon[?json]</code>
<h3>Parameters:</h3>
<ul>
<li><strong>lat</strong> - Latitude of the location, WGS-84</li>
<li><strong>lon</strong> - Longitude of the location, WGS-84</li>
<li><strong>?json</strong> - Append this to have the result retuned as JSON</li>
</ul>
<h3>Response:</h3>
<p>The API will return the elevation in meters. For example:</p>
<code>42</code>
<p>If the point is not into the DEM dataset, the response code will be 501 (or <code>Null</code> in JSON mode)</p>
<p>If the point is not into the DEM dataset, the response code will be 501 (or <code>Null</code> in JSON mode)
</p>
<h3>Try it out:</h3>
<a href="http://www.elevation-api.eu/elevation/46.24566/6.17081">Get the elevation of the Lake Leman</a>
<a href="http://www.elevation-api.eu/v1/elevation/46.24566/6.17081">Get the elevation of the Lake Leman</a>
</section>
<section>
<h2>Alternative API endpoints</h2>
<h3>JSON result</h3>
<p>Append <code>?json</code> to your query to have the return content as a json payload</p>
<h2>JSON API endpoint (multi coordinates)</h2>
You can also request many coordinates at once by using the following endpoint:
<code>https://www.elevation-api.eu/v1/elevation?pts=[[lat1,lon1],[lat2,lon2],[lat3,lon3]]</code>
<h4>Example</h4>
<code><a href="https://www.elevation-api.eu/elevation/46.24566/6.17081?json">https://www.elevation-api.eu/elevation/46.24566/6.17081?json</a></code>
<code><a href="https://www.elevation-api.eu/v1/elevation?pts=[[46.24566,6.17081],[46.85499,6.78134]]">
https://www.elevation-api.eu/v1/elevation?pts=[[46.24566,6.17081],[46.85499,6.78134]]
</a></code>
</section>
<section>
<h2>Misc</h2>
<h3>Data source</h3>
<p>The digital elevation data comes from ESA's Copernicus program.</p>
<h3>Rate limits</h3>
<p>Don't be a dick. Less than 10/s is okay</p>
<p>Don't be an idiot. Less than 10/s is okay</p>
<h3>Contact</h3>
<p>For more information, you can reach me at f@vi-di.fr</p>
</section>
@ -89,5 +101,5 @@
<p>© 2024 Frank Villaro-Dixon. No rights reserved</p>
</footer>
</body>
</html>
</html>

View file

@ -101,8 +101,8 @@ async fn main() {
let serve_dir = ServeDir::new("assets");
let app = Router::<DatasetRepository>::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(