seledamap 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
seledamap/__init__.py
ADDED
seledamap/client.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import urllib.parse
|
|
3
|
+
import urllib.request
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SeledaMapClient:
|
|
7
|
+
"""Official Python SDK for SeledaMap."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, api_key: str, base_url: str = "http://localhost:8081", timeout: int = 10):
|
|
10
|
+
self.api_key = api_key
|
|
11
|
+
self.base_url = base_url.rstrip("/")
|
|
12
|
+
self.timeout = timeout
|
|
13
|
+
|
|
14
|
+
def _request(self, method: str, path: str, payload: dict = None) -> dict:
|
|
15
|
+
url = f"{self.base_url}/api/v1{path}"
|
|
16
|
+
headers = {"X-API-Key": self.api_key, "Accept": "application/json"}
|
|
17
|
+
data = None
|
|
18
|
+
if payload is not None:
|
|
19
|
+
data = json.dumps(payload).encode("utf-8")
|
|
20
|
+
headers["Content-Type"] = "application/json"
|
|
21
|
+
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
|
22
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as resp:
|
|
23
|
+
return json.loads(resp.read().decode("utf-8"))
|
|
24
|
+
|
|
25
|
+
def get_style_url(self, theme: str = "light", include_3d: bool = False) -> str:
|
|
26
|
+
qs = urllib.parse.urlencode({
|
|
27
|
+
"theme": theme,
|
|
28
|
+
"include_3d": "true" if include_3d else "false",
|
|
29
|
+
"api_key": self.api_key,
|
|
30
|
+
})
|
|
31
|
+
return f"{self.base_url}/api/v1/tiles/style.json?{qs}"
|
|
32
|
+
|
|
33
|
+
def validate_key(self) -> dict:
|
|
34
|
+
return self._request("GET", "/auth/api-keys/validate")
|
|
35
|
+
|
|
36
|
+
def get_route(self, origin: dict, destination: dict, mode: str = "driving") -> dict:
|
|
37
|
+
return self._request("POST", "/routes", {"origin": origin, "destination": destination, "mode": mode})
|
|
38
|
+
|
|
39
|
+
def get_distance_matrix(self, origins: list, destinations: list, mode: str = "car") -> dict:
|
|
40
|
+
return self._request("POST", "/routing/matrix", {"origins": origins, "destinations": destinations, "mode": mode})
|
|
41
|
+
|
|
42
|
+
def search_places(self, query: str, limit: int = 10) -> dict:
|
|
43
|
+
qs = urllib.parse.urlencode({"q": query, "limit": limit})
|
|
44
|
+
return self._request("GET", f"/places/search?{qs}")
|
|
45
|
+
|
|
46
|
+
def where_am_i(self, lat: float, lng: float) -> dict:
|
|
47
|
+
return self._request("GET", f"/location/where-am-i?lat={lat}&lng={lng}")
|
|
48
|
+
|
|
49
|
+
def validate_spatial_ml(self, lat: float = 9.0108, lng: float = 38.7578, res: int = 8) -> dict:
|
|
50
|
+
return self._request("GET", f"/spatial-ml/validate?lat={lat}&lng={lng}&res={res}")
|
|
51
|
+
|
|
52
|
+
def get_h3_grid(self, min_lng: float, min_lat: float, max_lng: float, max_lat: float, resolution: int = 8) -> dict:
|
|
53
|
+
return self._request("POST", "/spatial-ml/h3/grid", {
|
|
54
|
+
"min_lng": min_lng, "min_lat": min_lat, "max_lng": max_lng, "max_lat": max_lat, "resolution": resolution
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
def solve_bipartite_match(self, supply: list, demand: list, h3_resolution: int = 8) -> dict:
|
|
58
|
+
return self._request("POST", "/spatial-ml/bipartite/match", {
|
|
59
|
+
"supply": supply, "demand": demand, "h3_resolution": h3_resolution
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
def build_lstm_sequence(self, observations: list, h3_resolution: int = 8) -> dict:
|
|
63
|
+
return self._request("POST", "/spatial-ml/lstm/sequence", {
|
|
64
|
+
"observations": observations, "h3_resolution": h3_resolution
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Backwards-compatible alias
|
|
69
|
+
EthiopiaMapClient = SeledaMapClient
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seledamap
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for SeledaMap — Routing, Distance Matrix, Geocoding, H3, Bipartite Matching & LSTM Tensors
|
|
5
|
+
Author: SeledaMap Platform Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://seledamap.org
|
|
8
|
+
Project-URL: Documentation, https://docs.seledamap.org
|
|
9
|
+
Keywords: seledamap,ethiopia,map,gis,routing,h3,bipartite,lstm
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# seledamap (Python SDK)
|
|
14
|
+
|
|
15
|
+
Official Python client for **SeledaMap** — zero external dependencies, standard library `urllib`.
|
|
16
|
+
|
|
17
|
+
## Install / Build
|
|
18
|
+
```bash
|
|
19
|
+
pip install seledamap
|
|
20
|
+
# or build wheel for PyPI:
|
|
21
|
+
python -m build
|
|
22
|
+
twine upload dist/*
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quickstart
|
|
26
|
+
```python
|
|
27
|
+
from seledamap import SeledaMapClient
|
|
28
|
+
|
|
29
|
+
client = SeledaMapClient(api_key="YOUR_FULL_API_KEY", base_url="http://localhost:8081")
|
|
30
|
+
print(client.validate_spatial_ml(lat=9.0108, lng=38.7578, res=8))
|
|
31
|
+
print(client.get_route({"lat": 9.0108, "lng": 38.7578}, {"lat": 8.9778, "lng": 38.7993}))
|
|
32
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
seledamap/__init__.py,sha256=TS3UWnWKDadFN26_4nwPER6vFspNGGM4AyORUamLNcA,129
|
|
2
|
+
seledamap/client.py,sha256=LdjgWm-Js7sDOhzC-AN09qH87uCNgX5hX-R792lYYk8,3155
|
|
3
|
+
seledamap-1.0.0.dist-info/METADATA,sha256=pMpquodvxSBOZsGChmKw_M5WVlqFeTKp5GuHEu-hDhs,1045
|
|
4
|
+
seledamap-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
seledamap-1.0.0.dist-info/top_level.txt,sha256=NnP9ZFcVV5YjQsRflbNz9aA-PdnF3nY9R7c6M56qsus,10
|
|
6
|
+
seledamap-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
seledamap
|