Spaces:
Sleeping
Sleeping
File size: 1,966 Bytes
0939b04 | 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 51 52 53 54 55 56 57 | """μ’ν β μ 체 λΆμ μ€μΌμ€νΈλ μ΄ν°."""
from api.models import (
AnalysisResult, TerrainInfo, ParcelInfo,
LandValueInfo, RegulatoryInfo, SubstationInfo,
)
from api.clients.vworld_data import fetch_parcel_at, fetch_regulatory_zones
from api.clients.vworld_ncp import fetch_land_price, fetch_land_characteristics, fetch_land_ownership
from api.clients.nasa_power import fetch_annual_ghi
from api.clients.opentopodata import fetch_elevation_slope
from api.clients.substation import find_nearest_substation
from api.scoring import calculate_score
def analyze(lat: float, lon: float) -> AnalysisResult:
"""μ’ν νλμ λν΄ λͺ¨λ λ°μ΄ν° μμ§ ν AnalysisResult λ°ν."""
result = AnalysisResult(lat=lat, lon=lon)
parcel_raw = fetch_parcel_at(lat, lon)
if parcel_raw:
result.parcel = ParcelInfo(
pnu=parcel_raw.get("pnu"),
jimok=parcel_raw.get("jimok"),
jimok_name=parcel_raw.get("jimok_name"),
area_m2=parcel_raw.get("area_m2"),
address=parcel_raw.get("address"),
)
pnu = parcel_raw.get("pnu")
else:
pnu = None
reg_raw = fetch_regulatory_zones(lat, lon)
result.regulatory = RegulatoryInfo(**reg_raw)
if pnu:
price = fetch_land_price(pnu)
chars = fetch_land_characteristics(pnu)
ownership = fetch_land_ownership(pnu)
result.land_value = LandValueInfo(
official_price_per_m2=price,
ownership_type=ownership,
slope_grade=chars.get("slope_grade_name") if chars else None,
)
terrain_raw = fetch_elevation_slope(lat, lon)
if terrain_raw:
result.terrain = TerrainInfo(**terrain_raw)
result.annual_ghi_kwh = fetch_annual_ghi(lat, lon)
sub_raw = find_nearest_substation(lat, lon)
if sub_raw:
result.substation = SubstationInfo(**sub_raw)
result.score = calculate_score(result)
return result
|