feat(okw): typed coordinate accessor + structured lat/lon in API#226
Merged
Conversation
Groundwork for the dashboard geographic map (web-ui review #1): give OKW facilities a single, tested way to expose their location as numeric lat/lon. - Coordinates value object + parse_decimal_degrees() helper + Location. coordinates() accessor: the one place that parses the OKW spec's decimal-degrees gps_coordinates string. Returns None if absent, not a "lat, lon" pair, or out of range. - Location.to_dict() now emits a structured "coordinates": {lat, lon} alongside the raw spec string, so the OKW search/detail responses carry numeric coordinates the web map can consume without re-parsing. - Refactor to_spaceapi_json() (MoM bridge) to use the accessor — removes the duplicated ad-hoc split/try-except. - Fix the OKW route's dead coordinates branch that read a non-existent location.latitude/longitude (always None); it now uses the accessor. - Unit tests: parser (valid/whitespace/malformed/out-of-range/absent), to_dict emission, and the SpaceAPI path sharing the accessor. Note: gps_coordinates remains the spec-compliant stored form (OKW §6.3); this adds a derived typed view, no data migration. Location/Address field redundancy + from_dict/to_dict asymmetry are tracked as separate cleanups. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Groundwork for the dashboard geographic map (review note #1): give OKW facilities a single, tested way to surface their location as numeric lat/lon, so the web map can plot them without re-parsing strings.
Turns out the OKW route already tried to expose coordinates (
getattr(facility.location, "latitude"/"longitude", None)) — butLocationhas no such attributes, so it was alwaysNone. This makes that latent intent actually work.Changes
Coordinatesvalue object +parse_decimal_degrees()helper +Location.coordinates()accessor — the one place that parses the OKW spec's decimal-degreesgps_coordinatesstring. ReturnsNoneif absent, not a"lat, lon"pair, or out of latitude/longitude range.Location.to_dict()now emits a structured"coordinates": {lat, lon}alongside the raw spec string, so OKW search/detail responses carry numeric coordinates.to_spaceapi_json()(MoM bridge) to use the accessor — removes the duplicated ad-hocsplit/try-except.location.latitude/longitude); now uses the accessor.to_dictemission, and the SpaceAPI path sharing the accessor.Design notes
gps_coordinatesstays the spec-compliant stored form (OKW §6.3, Decimal Degrees) — this adds a derived typed view, no data migration (per the agreed approach).LocationvsAddresscity/region/country redundancy (non-spec, has match-filter blast radius), and thefrom_dict/to_dictround-trip asymmetry.Verification
make ready— all gates green (553 passed, parity 4/4, docs ✓).Next: the dashboard rework (map hero + network stats + getting-started) lands on
frontend-devand consumeslocation.coordinates.🤖 Generated with Claude Code