mapnetwork-mcp 1.0.0__tar.gz → 1.2.0__tar.gz
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.
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/PKG-INFO +1 -1
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/RELEASING.md +60 -61
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/manifest.json +1 -1
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/mapnetwork_mcp/server.py +101 -64
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/pyproject.toml +1 -1
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/.gitignore +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/.mcpbignore +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/LICENSE +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/README.md +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-beige.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-black.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-brawn.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-darkBlue.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-lightGreen.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-popArt.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/images/Kanazawa21Museum-white.png +0 -0
- {mapnetwork_mcp-1.0.0 → mapnetwork_mcp-1.2.0}/mapnetwork_mcp/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapnetwork-mcp
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: MCP server — generate styled map images via mapnetwork.app
|
|
5
5
|
Project-URL: Homepage, https://mapnetwork.app
|
|
6
6
|
Project-URL: Repository, https://github.com/toruproject/mapnetwork-mcp
|
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
# Releasing a new version
|
|
2
|
-
|
|
3
|
-
This project's version number is declared in **three places** that must stay in sync:
|
|
4
|
-
|
|
5
|
-
| File | Field(s) |
|
|
6
|
-
|---|---|
|
|
7
|
-
| `pyproject.toml` | `[project] version` |
|
|
8
|
-
| `server.json` | `version`, `packages[0].version` |
|
|
9
|
-
| `manifest.json` | `version` |
|
|
10
|
-
|
|
11
|
-
## Steps
|
|
12
|
-
|
|
13
|
-
1. **Bump the version** in all three files above (same value).
|
|
14
|
-
|
|
15
|
-
2. **Build the PyPI package**
|
|
16
|
-
```bash
|
|
17
|
-
rm -f dist/*.whl dist/*.tar.gz
|
|
18
|
-
.venv/Scripts/python -m build
|
|
19
|
-
.venv/Scripts/python -m twine check dist/*
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
3. **Upload to PyPI**
|
|
23
|
-
```bash
|
|
24
|
-
.venv/Scripts/python -m twine upload dist/mapnetwork_mcp-<version>*
|
|
25
|
-
```
|
|
26
|
-
Requires a PyPI API token (via `~/.pypirc` or `TWINE_USERNAME=__token__` / `TWINE_PASSWORD=...`).
|
|
27
|
-
|
|
28
|
-
4. **Publish to the MCP registry**
|
|
29
|
-
```bash
|
|
30
|
-
./mcp-publisher.exe validate server.json
|
|
31
|
-
./mcp-publisher.exe login github # only needed if the session expired
|
|
32
|
-
./mcp-publisher.exe publish
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
npx --yes @anthropic-ai/mcpb
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
git
|
|
48
|
-
git
|
|
49
|
-
git
|
|
50
|
-
git
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- `.mcpregistry_github_token` / `.mcpregistry_registry_token` hold the `mcp-publisher` login session — they are git-ignored and must never be committed.
|
|
1
|
+
# Releasing a new version
|
|
2
|
+
|
|
3
|
+
This project's version number is declared in **three places** that must stay in sync:
|
|
4
|
+
|
|
5
|
+
| File | Field(s) |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `pyproject.toml` | `[project] version` |
|
|
8
|
+
| `server.json` | `version`, `packages[0].version` |
|
|
9
|
+
| `manifest.json` | `version` |
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. **Bump the version** in all three files above (same value).
|
|
14
|
+
|
|
15
|
+
2. **Build the PyPI package**
|
|
16
|
+
```bash
|
|
17
|
+
rm -f dist/*.whl dist/*.tar.gz
|
|
18
|
+
.venv/Scripts/python -m build
|
|
19
|
+
.venv/Scripts/python -m twine check dist/*
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. **Upload to PyPI**
|
|
23
|
+
```bash
|
|
24
|
+
.venv/Scripts/python -m twine upload dist/mapnetwork_mcp-<version>*
|
|
25
|
+
```
|
|
26
|
+
Requires a PyPI API token (via `~/.pypirc` or `TWINE_USERNAME=__token__` / `TWINE_PASSWORD=...`).
|
|
27
|
+
|
|
28
|
+
4. **Publish to the MCP registry**
|
|
29
|
+
```bash
|
|
30
|
+
./mcp-publisher.exe validate server.json
|
|
31
|
+
./mcp-publisher.exe login github # only needed if the session expired
|
|
32
|
+
./mcp-publisher.exe publish server.json
|
|
33
|
+
```
|
|
34
|
+
The registry entry's `packages[0].version` must match the version actually live on PyPI (the registry does not host the code itself).
|
|
35
|
+
|
|
36
|
+
⚠️ `login github` requires manually entering a device confirmation code in the browser — it cannot be automated.
|
|
37
|
+
|
|
38
|
+
5. **Rebuild the MCPB bundle**
|
|
39
|
+
```bash
|
|
40
|
+
npx --yes @anthropic-ai/mcpb validate manifest.json
|
|
41
|
+
npx --yes @anthropic-ai/mcpb pack . dist/mapnetwork-mcp.mcpb
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
6. **Commit, tag, and push**
|
|
45
|
+
```bash
|
|
46
|
+
git add pyproject.toml server.json manifest.json
|
|
47
|
+
git commit -m "Bump version to <version>"
|
|
48
|
+
git push origin main
|
|
49
|
+
git tag -a v<version> -m "v<version>"
|
|
50
|
+
git push origin v<version>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
7. **Create the GitHub Release** with the `.mcpb` bundle attached
|
|
54
|
+
```bash
|
|
55
|
+
gh release create v<version> dist/mapnetwork-mcp.mcpb --title "v<version>" --notes "..."
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Notes
|
|
59
|
+
|
|
60
|
+
- `.mcpregistry_github_token` / `.mcpregistry_registry_token` hold the `mcp-publisher` login session — they are git-ignored and must never be committed.
|
|
62
61
|
- `dist/` is git-ignored; build artifacts and the `.mcpb` bundle are distributed only via PyPI / the GitHub Release, not via the repository.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": "0.4",
|
|
3
3
|
"name": "mapnetwork-mcp",
|
|
4
4
|
"display_name": "MapNetwork",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"description": "Generate styled PNG/SVG map images of any location with 11 customizable color themes.",
|
|
7
7
|
"long_description": "MCP server for MapNetwork — generate styled map images (PNG / SVG) for any location on Earth, directly from Claude.\n\n- Generate maps from a place name, coordinates, or a list of markers\n- 11 color themes (white, darkBlue, darkGreen, popArt, lightBlue, lightGreen, beige, magenta, gray, black, brawn)\n- Overlay walking / driving routes on the map\n- PNG or SVG output, saved to your Downloads folder\n- Re-download a previously generated map in a different theme or format without regenerating\n- Open any generated map in the MapNetwork web editor for manual customization",
|
|
8
8
|
"author": {
|
|
@@ -5,15 +5,71 @@ import os
|
|
|
5
5
|
import re
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Annotated
|
|
8
|
+
from typing import Annotated, Literal
|
|
9
9
|
|
|
10
10
|
import httpx
|
|
11
11
|
from mcp.server.fastmcp import FastMCP, Image
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
12
13
|
|
|
13
14
|
BASE_URL = os.environ.get("MAPNETWORK_BASE_URL", "https://mapnetwork.app")
|
|
14
15
|
POLL_INTERVAL_SEC = 10.0
|
|
15
16
|
MAX_WAIT_SEC = 600
|
|
16
17
|
|
|
18
|
+
# layersは自由な多値配列にすると、モデルが「roadはhighway/driving/walkingの上位互換」
|
|
19
|
+
# といった内部の組み合わせルールを知らないまま組み合わせを選んでしまう。
|
|
20
|
+
# 人間側で意味のある4パターンだけに絞り込み、モデルにはこのプリセット名だけを選ばせる。
|
|
21
|
+
_LAYER_PRESETS: dict[str, list[str]] = {
|
|
22
|
+
"default": ["road", "poi"],
|
|
23
|
+
"road_and_railway": ["road", "railway", "poi"],
|
|
24
|
+
"only_driving_road": ["driving"],
|
|
25
|
+
"fully_detailed": ["road", "railway", "poi", "waterline", "greenarea"],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Location(BaseModel):
|
|
30
|
+
lat: float
|
|
31
|
+
lng: float
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Marker(BaseModel):
|
|
35
|
+
label: str | None = Field(default=None, description="Place name for geocoding and/or display.")
|
|
36
|
+
location: Location | None = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="Explicit coordinates. If provided, geocoding of 'label' is skipped.",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RouteEndpoint(BaseModel):
|
|
43
|
+
label: str | None = Field(default=None, description="Place name for geocoding and/or display.")
|
|
44
|
+
location: Location | None = Field(default=None, description="Explicit coordinates.")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class RouteInput(BaseModel):
|
|
48
|
+
"""generate_mapのrouteパラメータ。compute_routeの戻り値をそのまま渡せる形にする。"""
|
|
49
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
50
|
+
|
|
51
|
+
coords: list[list[float]] | None = Field(
|
|
52
|
+
default=None, description="Ordered list of [lat, lng] pairs along the route."
|
|
53
|
+
)
|
|
54
|
+
mode: Literal["walking", "driving"] | None = None
|
|
55
|
+
from_: RouteEndpoint | None = Field(default=None, alias="from", description="Route start point.")
|
|
56
|
+
to: RouteEndpoint | None = Field(default=None, description="Route end point.")
|
|
57
|
+
color: str | None = Field(default=None, description="Optional line color as a CSS hex color (e.g. '#FF4500').")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class MapConfig(BaseModel):
|
|
61
|
+
patchworked: bool | None = Field(
|
|
62
|
+
default=None, description="Auto-color closed areas and building shapes on the drawing. Default true."
|
|
63
|
+
)
|
|
64
|
+
withBuilding: bool | None = Field(
|
|
65
|
+
default=None, description="Draw building shapes. Default true when building data is available."
|
|
66
|
+
)
|
|
67
|
+
withSeaRibbon: bool | None = Field(
|
|
68
|
+
default=None,
|
|
69
|
+
description="Draw a band representing the sea along the coastline. Default true when coastline data is available.",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
17
73
|
mcp = FastMCP(
|
|
18
74
|
"MapNetwork",
|
|
19
75
|
instructions=(
|
|
@@ -29,10 +85,10 @@ mcp = FastMCP(
|
|
|
29
85
|
"- **Circular area**: specify `radius` in meters (default 500, max 2500) around the center\n"
|
|
30
86
|
"- **Rectangular area**: specify `size_ew` (east-west) and `size_ns` (north-south) in meters "
|
|
31
87
|
"instead of radius — useful when the area of interest is not square\n"
|
|
32
|
-
"- **Layers**: choose
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
88
|
+
"- **Layers**: choose a preset via `layers` — 'default' (roads + POI), "
|
|
89
|
+
"'only_driving_road' (car-accessible roads only), 'road_and_railway' (roads + railway, no POI), "
|
|
90
|
+
"or 'fully_detailed' (roads + railway + waterline + greenarea + POI; waterline/greenarea only "
|
|
91
|
+
"apply within Japan). Omit for 'default'.\n"
|
|
36
92
|
"- **Color themes** via `color_set`: "
|
|
37
93
|
"white (clean, default), darkBlue (navy bg), darkGreen (dark teal bg), "
|
|
38
94
|
"popArt (blue bg, bold contrast), lightBlue (pale blue bg), lightGreen (pale green bg), "
|
|
@@ -105,14 +161,13 @@ async def _download(client: httpx.AsyncClient, data_key: str, format: str,
|
|
|
105
161
|
@mcp.tool()
|
|
106
162
|
async def compute_route(
|
|
107
163
|
from_location: Annotated[
|
|
108
|
-
|
|
109
|
-
"Start point of the route. "
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"Example: {\"label\": \"赤坂駅\"}",
|
|
164
|
+
RouteEndpoint,
|
|
165
|
+
"Start point of the route. Provide 'location' for explicit coordinates (no geocoding), "
|
|
166
|
+
"or only 'label' to geocode server-side. Both may be provided — 'location' takes precedence, "
|
|
167
|
+
"'label' is used for display. Example: {\"label\": \"赤坂駅\"}",
|
|
113
168
|
],
|
|
114
169
|
to_location: Annotated[
|
|
115
|
-
|
|
170
|
+
RouteEndpoint,
|
|
116
171
|
"End point of the route. Same format as from_location. "
|
|
117
172
|
"Example: {\"label\": \"赤坂氷川神社\"}",
|
|
118
173
|
],
|
|
@@ -134,7 +189,11 @@ async def compute_route(
|
|
|
134
189
|
if mode not in ("walking", "driving"):
|
|
135
190
|
raise ValueError("mode must be 'walking' or 'driving'")
|
|
136
191
|
|
|
137
|
-
body = {
|
|
192
|
+
body = {
|
|
193
|
+
"from": from_location.model_dump(exclude_none=True),
|
|
194
|
+
"to": to_location.model_dump(exclude_none=True),
|
|
195
|
+
"mode": mode,
|
|
196
|
+
}
|
|
138
197
|
async with httpx.AsyncClient() as client:
|
|
139
198
|
resp = await client.post(f"{BASE_URL}/route", json=body, timeout=180)
|
|
140
199
|
if resp.status_code == 404:
|
|
@@ -177,25 +236,13 @@ async def generate_map(
|
|
|
177
236
|
"Omit when using markers-only mode.",
|
|
178
237
|
] = None,
|
|
179
238
|
markers: Annotated[
|
|
180
|
-
list[
|
|
239
|
+
list[Marker] | None,
|
|
181
240
|
"List of locations to pin on the map as blue markers. "
|
|
182
|
-
"Each item
|
|
183
|
-
"Optionally include explicit coordinates: {\"label\": \"...\", \"location\": {\"lat\": ..., \"lng\": ...}}. "
|
|
184
|
-
"Each marker may also include an optional \"icon\" field to override its appearance: "
|
|
185
|
-
"{\"label\": \"...\", \"icon\": {\"color\": \"#ff0000\"}}. "
|
|
186
|
-
"All icon sub-fields (code/size/color) are optional — omit any to keep the default. "
|
|
241
|
+
"Each item needs only a 'label' (geocoded automatically); explicit 'location' {lat, lng} is optional. "
|
|
187
242
|
"When markers are provided without place/lat/lng, the server derives the map center from their centroid "
|
|
188
243
|
"and sets radius automatically. "
|
|
189
244
|
"Example for two stations: [{\"label\": \"東京駅\"}, {\"label\": \"新宿駅\"}]",
|
|
190
245
|
] = None,
|
|
191
|
-
place_icon: Annotated[
|
|
192
|
-
dict | None,
|
|
193
|
-
"Custom icon for the `place` pin (or center pin if no `place`). "
|
|
194
|
-
"All fields are optional — specify only what you want to override. "
|
|
195
|
-
"Fields: code (FontAwesome \\uXXXX), size (pixels), color (CSS hex). "
|
|
196
|
-
"Example (red icon, larger): {\"color\": \"#ff0000\", \"size\": 50}. "
|
|
197
|
-
"Omit entirely to use the default icon.",
|
|
198
|
-
] = None,
|
|
199
246
|
name: Annotated[
|
|
200
247
|
str | None,
|
|
201
248
|
"Map name stored in the data file. Used as the default download filename. "
|
|
@@ -222,32 +269,26 @@ async def generate_map(
|
|
|
222
269
|
"ONLY set this when the user has explicitly requested a rectangular area of specific dimensions.",
|
|
223
270
|
] = None,
|
|
224
271
|
layers: Annotated[
|
|
225
|
-
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
"'
|
|
229
|
-
"'
|
|
230
|
-
"
|
|
231
|
-
"'
|
|
232
|
-
"'railway' — train and subway lines\n"
|
|
233
|
-
"'waterline' — rivers, lakes, and coastlines\n"
|
|
234
|
-
"'greenarea' — forests and woods\n"
|
|
235
|
-
"'poi' — point-of-interest icons (filterable with poi_types)\n"
|
|
236
|
-
"Example for road + railway + POI: ['road', 'railway', 'poi']",
|
|
237
|
-
] = None,
|
|
238
|
-
poi_types: Annotated[
|
|
239
|
-
list[str] | None,
|
|
240
|
-
"Filter POI categories when 'poi' is in layers. Omit to include all. "
|
|
241
|
-
"Valid values: museum, library, theatre, convenience, supermarket, "
|
|
242
|
-
"school, religion, station, park, hospital, cityhall, cafe, restaurant.",
|
|
272
|
+
Literal["default", "road_and_railway", "only_driving_road", "fully_detailed"] | None,
|
|
273
|
+
"Preset combination of map layers. 'default': roads + POI icons. "
|
|
274
|
+
"'only_driving_road': car-accessible roads only, nothing else. "
|
|
275
|
+
"'road_and_railway': roads + railway lines, no POI. "
|
|
276
|
+
"'fully_detailed': roads + railway + waterline + greenarea + POI "
|
|
277
|
+
"(waterline/greenarea only apply within Japan; ignored elsewhere). "
|
|
278
|
+
"Omit for 'default'.",
|
|
243
279
|
] = None,
|
|
244
280
|
route: Annotated[
|
|
245
|
-
|
|
281
|
+
RouteInput | None,
|
|
246
282
|
"Route to overlay on the map. Pass the full response from compute_route() directly — "
|
|
247
283
|
"the server uses coords and (optionally) color from it. "
|
|
248
|
-
"To customise the line color,
|
|
284
|
+
"To customise the line color, set/override the 'color' field (e.g. '#FF4500'). "
|
|
249
285
|
"Omit to generate a map without a route overlay.",
|
|
250
286
|
] = None,
|
|
287
|
+
config: Annotated[
|
|
288
|
+
MapConfig | None,
|
|
289
|
+
"Overrides for automatic layer-visibility defaults. Omit any field to keep the default. "
|
|
290
|
+
"Example to turn off buildings: {\"withBuilding\": false}.",
|
|
291
|
+
] = None,
|
|
251
292
|
color_set: Annotated[
|
|
252
293
|
str | None,
|
|
253
294
|
"Color theme for the map. Only set when the user explicitly requests one. "
|
|
@@ -260,12 +301,7 @@ async def generate_map(
|
|
|
260
301
|
"Output file format: 'png' (default, raster image) or 'svg' (vector, scalable to any size).",
|
|
261
302
|
] = "png",
|
|
262
303
|
canvas_width: Annotated[int | None, "Canvas width in pixels. Omit to use server default (1000)."] = None,
|
|
263
|
-
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (
|
|
264
|
-
edge_weight: Annotated[
|
|
265
|
-
int | None,
|
|
266
|
-
"Road and line width adjustment. Positive values thicken lines, negative values thin them. "
|
|
267
|
-
"Default 0 (no adjustment). Example: 2 to make roads slightly thicker, -1 to make them thinner.",
|
|
268
|
-
] = None,
|
|
304
|
+
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (600)."] = None,
|
|
269
305
|
) -> list:
|
|
270
306
|
"""Generate a styled map image for a given location and save it to Downloads.
|
|
271
307
|
|
|
@@ -279,8 +315,9 @@ async def generate_map(
|
|
|
279
315
|
without waiting for regeneration.
|
|
280
316
|
"""
|
|
281
317
|
has_center = place or (lat is not None and lng is not None)
|
|
282
|
-
|
|
283
|
-
|
|
318
|
+
has_route_coords = route is not None and route.coords is not None and len(route.coords) >= 2
|
|
319
|
+
if not has_center and not markers and not has_route_coords:
|
|
320
|
+
raise ValueError("Specify 'place', both 'lat'+'lng', 'markers', or a 'route' with coords.")
|
|
284
321
|
if radius is not None and (size_ew is not None or size_ns is not None):
|
|
285
322
|
raise ValueError("Specify either 'radius' or 'size_ew'+'size_ns', not both.")
|
|
286
323
|
if (size_ew is None) != (size_ns is None):
|
|
@@ -288,15 +325,13 @@ async def generate_map(
|
|
|
288
325
|
|
|
289
326
|
body: dict = {}
|
|
290
327
|
if layers is not None:
|
|
291
|
-
body["layers"] = layers
|
|
328
|
+
body["layers"] = _LAYER_PRESETS[layers]
|
|
292
329
|
if place:
|
|
293
330
|
body["place"] = place
|
|
294
331
|
elif lat is not None and lng is not None:
|
|
295
332
|
body["center"] = {"lat": lat, "lng": lng}
|
|
296
333
|
if markers is not None:
|
|
297
|
-
body["markers"] = markers
|
|
298
|
-
if place_icon is not None:
|
|
299
|
-
body["icon"] = place_icon
|
|
334
|
+
body["markers"] = [m.model_dump(exclude_none=True) for m in markers]
|
|
300
335
|
if name is not None:
|
|
301
336
|
body["name"] = name
|
|
302
337
|
if color_set is not None:
|
|
@@ -305,10 +340,10 @@ async def generate_map(
|
|
|
305
340
|
body["radius"] = radius
|
|
306
341
|
elif size_ew is not None:
|
|
307
342
|
body["size"] = {"ew": size_ew, "ns": size_ns}
|
|
308
|
-
if poi_types:
|
|
309
|
-
body["poiTypes"] = poi_types
|
|
310
343
|
if route is not None:
|
|
311
|
-
body["route"] = route
|
|
344
|
+
body["route"] = route.model_dump(by_alias=True, exclude_none=True)
|
|
345
|
+
if config is not None:
|
|
346
|
+
body["config"] = config.model_dump(exclude_none=True)
|
|
312
347
|
|
|
313
348
|
async with httpx.AsyncClient() as client:
|
|
314
349
|
# 1. Enqueue
|
|
@@ -342,14 +377,16 @@ async def generate_map(
|
|
|
342
377
|
|
|
343
378
|
# 3. Download
|
|
344
379
|
image_bytes = await _download(client, data_key, format, color_set,
|
|
345
|
-
canvas_width, canvas_height
|
|
380
|
+
canvas_width, canvas_height)
|
|
346
381
|
|
|
347
382
|
if place:
|
|
348
383
|
label = place
|
|
349
384
|
elif lat is not None and lng is not None:
|
|
350
385
|
label = f"{lat}_{lng}"
|
|
386
|
+
elif markers:
|
|
387
|
+
label = "_".join(m.label or "" for m in markers)[:40]
|
|
351
388
|
else:
|
|
352
|
-
label = "
|
|
389
|
+
label = "route"
|
|
353
390
|
out_path = _make_filename(label, format)
|
|
354
391
|
out_path.write_bytes(image_bytes)
|
|
355
392
|
|
|
@@ -386,7 +423,7 @@ async def redownload_map(
|
|
|
386
423
|
"'png' (raster) or 'svg' (vector, infinitely scalable).",
|
|
387
424
|
] = "png",
|
|
388
425
|
canvas_width: Annotated[int | None, "Canvas width in pixels. Omit to use server default (1000)."] = None,
|
|
389
|
-
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (
|
|
426
|
+
canvas_height: Annotated[int | None, "Canvas height in pixels. Omit to use server default (600)."] = None,
|
|
390
427
|
edge_weight: Annotated[
|
|
391
428
|
int | None,
|
|
392
429
|
"Road and line width adjustment. Positive values thicken lines, negative values thin them. "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|