mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Slice 3c.1. Ingestion will persist a UPRN's coordinates and planning protections together as a write-through cache, so resolve them in a single partition read rather than two. `SpatialReference` bundles the coordinates (which drive the Solar fetch) and the `PlanningRestrictions` (which gate wall insulation per ADR-0019/ADR-0020); `GeospatialRepository.spatial_for(uprn)` returns it, and `coordinates_for`/`planning_restrictions_for` now delegate to the one lookup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Optional
|
|
|
|
from domain.geospatial.coordinates import Coordinates
|
|
from domain.geospatial.planning_restrictions import PlanningRestrictions
|
|
from domain.geospatial.spatial_reference import SpatialReference
|
|
|
|
|
|
class GeospatialRepository(ABC):
|
|
"""Resolves a Property's coordinates from hosted reference data by UPRN.
|
|
|
|
A Repo, not a Fetcher (ADR-0011): it reads stored Ordnance Survey Open-UPRN
|
|
data, with no live API call. Returns None when the UPRN is not covered.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def coordinates_for(self, uprn: int) -> Optional[Coordinates]: ...
|
|
|
|
def spatial_for(self, uprn: int) -> Optional[SpatialReference]:
|
|
"""The Property's coordinates and planning protections together, in one
|
|
reference lookup (ADR-0020) — Ingestion uses the coordinates to drive
|
|
the Solar fetch and persists the whole reference. Defaults to None so
|
|
reference sources that don't carry the flags need not implement it."""
|
|
return None
|
|
|
|
def planning_restrictions_for(self, uprn: int) -> Optional[PlanningRestrictions]:
|
|
"""The Property's planning protections (conservation/listed/heritage),
|
|
co-located with the coordinates in the reference data (ADR-0020).
|
|
Defaults to None (unknown → unrestricted) so reference sources that
|
|
don't carry the flags need not implement it."""
|
|
return None
|