|
1 | 1 | from typing import Annotated |
2 | 2 |
|
3 | 3 | import morecantile |
4 | | -from fastapi import APIRouter, HTTPException |
5 | | -from fastapi import Depends |
| 4 | +from api.database import get_sync_database |
| 5 | +from fastapi import APIRouter, Depends, HTTPException |
6 | 6 | from morecantile import Tile |
7 | 7 | from shapely import GEOSException |
8 | 8 | from shapely.geometry import Polygon |
9 | 9 | from shapely.wkb import loads as load_wkb |
10 | 10 | from shapely.wkt import loads as load_wkt |
11 | 11 |
|
12 | | -from api.database import get_sync_database |
13 | | - |
14 | 12 | router = APIRouter(tags=["map"]) |
15 | 13 |
|
16 | 14 | tms = morecantile.tms.get("WebMercatorQuad") |
@@ -129,8 +127,9 @@ def get_map_legend( |
129 | 127 | detail="Only 'carto' compilation is currently supported.", |
130 | 128 | ) |
131 | 129 |
|
132 | | - res = db.run_query( |
133 | | - """ |
| 130 | + res = ( |
| 131 | + db.run_query( |
| 132 | + """ |
134 | 133 | WITH polygons AS ( |
135 | 134 | SELECT legend_id, source_id, scale |
136 | 135 | FROM carto.polygons p |
@@ -168,7 +167,10 @@ def get_map_legend( |
168 | 167 | JOIN maps.sources s USING (source_id) |
169 | 168 | JOIN polygons p USING (legend_id, source_id) |
170 | 169 | """, |
171 | | - params={"bounds": map_area.bounds.wkt, "scale": scale}, |
172 | | - ).mappings().all() |
| 170 | + params={"bounds": map_area.bounds.wkt, "scale": scale}, |
| 171 | + ) |
| 172 | + .mappings() |
| 173 | + .all() |
| 174 | + ) |
173 | 175 |
|
174 | 176 | return res |
0 commit comments