File size: 1,776 Bytes
6afc01a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
All MCP Server Implementations
Deploy as: src/servers/__init__.py OR separate files

Contains:
- WeatherServer (Open-Meteo)
- SoilPropertiesServer (SoilGrids)
- WaterServer (GRACE)
- ElevationServer (OpenElevation)
- PestsServer (iNaturalist)
"""

import aiohttp
import asyncio
import os
import xarray as xr
import requests
from datetime import datetime
from typing import Dict, Any

# ============================================================================
# ELEVATION SERVER (OpenElevation)
# ============================================================================

class ElevationServer:
    """OpenElevation API Server"""

    async def get_data(self, lat: float, lon: float) -> Dict[str, Any]:
        try:
            url = "https://api.open-elevation.com/api/v1/lookup"
            params = {"locations": f"{lat},{lon}"}

            async with aiohttp.ClientSession() as session:
                async with session.get(url, params=params, timeout=aiohttp.ClientTimeout(total=10)) as response:
                    if response.status == 200:
                        data = await response.json()
                        elevation_m = data["results"][0]["elevation"]
                        return {
                            "status": "success",
                            "data": {
                                "elevation_meters": elevation_m,
                                "elevation_feet": round(elevation_m * 3.28084, 1),
                                "data_source": "OpenElevation API"
                            }
                        }
                    else:
                        return {"status": "error", "error": f"HTTP {response.status}"}
        except Exception as e:
            return {"status": "error", "error": str(e)}