feat(공용 지도): 주소 · 장소 찾기 길 GET /api/map/search · 선 이름 내보내기 이음 시험 (PLAN 594-2 · 594-4 · 요구 463)
- /api/map/search?q= — VWorld 주소(도로명 → 지번) 먼저 · 장소(POI) 뒤 · 같은 이름 · 주소 줄 하나 · 키는 서버 · 실패 = 빈 목록 - B01_Dashboard_Map.search_place 더함(있는 search_address 그대로) - 시험 594_4 새로(VWorld 가짜) · 563_2 붙인 선 이름 = 조각 이름표 · zip 폴더 · 좌표표 xlsx 「선」 칸 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,16 +2,19 @@
|
||||
|
||||
GET /api/map/kakao-key {key} — 공개용(도메인 등록으로 막힘) · .env KAKAO_JS_KEY · 없으면 null
|
||||
GET /api/map/address {address, region, source} — VWorld(B08 과 같은 길) · 지번 먼저 · 없음 null
|
||||
GET /api/map/search?q= {items: [{kind address|place, title, address, lon, lat}], source} — 594-4 ·
|
||||
등록(D01) · 예정노선 위치 칸이 같이 씀 · VWorld 주소 + 장소
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Query
|
||||
|
||||
from B01_Dashboard.B01_Dashboard_Map import reverse_place
|
||||
from B01_Dashboard.B01_Dashboard_Map import reverse_place, search_address, search_place
|
||||
|
||||
router = APIRouter(prefix="/api/map", tags=["map"])
|
||||
|
||||
@@ -31,3 +34,35 @@ async def map_address(
|
||||
) -> dict[str, Any]:
|
||||
"""좌표 → 주소 · 「시군구 읍면」(사업 지역 채움) · 출처."""
|
||||
return {**await reverse_place(lon, lat), "source": ADDRESS_SOURCE}
|
||||
|
||||
|
||||
@router.get("/search")
|
||||
async def map_search(
|
||||
q: str = Query(..., min_length=1, max_length=100), size: int = Query(10, ge=1, le=30)
|
||||
) -> dict[str, Any]:
|
||||
"""주소 · 장소 찾기(594-4) — 주소(도로명 → 지번) 먼저 · 장소 뒤 · 같은 줄 하나 · 키는 서버."""
|
||||
query = q.strip()
|
||||
if not query:
|
||||
return {"items": [], "source": ADDRESS_SOURCE}
|
||||
addresses, places = await asyncio.gather(search_address(query, size), search_place(query, size))
|
||||
items = [
|
||||
{
|
||||
"kind": "address",
|
||||
"title": hit[hit["category"]] or hit["road"] or hit["parcel"],
|
||||
"address": hit["parcel"] if hit["category"] == "road" else hit["road"],
|
||||
"lon": hit["lon"],
|
||||
"lat": hit["lat"],
|
||||
}
|
||||
for hit in addresses
|
||||
] + [
|
||||
{
|
||||
"kind": "place",
|
||||
"title": hit["title"],
|
||||
"address": hit["road"] or hit["parcel"],
|
||||
"lon": hit["lon"],
|
||||
"lat": hit["lat"],
|
||||
}
|
||||
for hit in places
|
||||
]
|
||||
unique = {(item["title"], item["address"]): item for item in items} # 같은 줄 하나(차례 그대로)
|
||||
return {"items": list(unique.values()), "source": ADDRESS_SOURCE}
|
||||
|
||||
Reference in New Issue
Block a user