hyperion.ports.geocoder¶
hyperion.ports.geocoder
¶
Port: geocoder abstraction.
Geocoder is the dependency-inversion seam between callers that need
address <-> coordinate resolution and a concrete backend (Google Maps, or a
static offline lookup for tests). It is a runtime_checkable
:class:typing.Protocol -- adapters satisfy it structurally, no forced
inheritance (see docs/ddd-refactor-plan.md F4 / Step 7).
The port references only the pure-domain :class:~hyperion.domain.geo.Location
and :class:~hyperion.domain.geo.NamedLocation value objects, so importing it
stays lite (no googlemaps, no boto3).
Contract:
geocoderaises :class:ValueErrorwhen the address cannot be resolved.reverse_geocoderaises :class:ValueErrorwhen the location has no address.get_altituderaises :class:ValueErrorwhen no elevation data exists.
Geocoder
¶
Bases: Protocol
Abstraction over geocoding backends.
geocode
¶
Resolve address to a :class:Location.
Raises:
| Type | Description |
|---|---|
ValueError
|
if the address cannot be geocoded. |
reverse_geocode
¶
Resolve location coordinates to a named address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location
|
The coordinates to reverse-geocode. |
required |
language
|
str | None
|
Optional language for the returned components. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the location cannot be reverse-geocoded. |
Source code in hyperion/ports/geocoder.py
get_altitude
¶
Return the altitude of location in meters above sea level.
Raises:
| Type | Description |
|---|---|
ValueError
|
if no elevation data is available. |