Documentation
¶
Overview ¶
Package geocoding wraps Open-Meteo's free geocoding endpoint (https://geocoding-api.open-meteo.com/v1/search) for forward- geocoding text input → lat/lon. Same provider we use for weather, so the privacy trade-off is consistent: city/place names leave the box during search, but no per-user identifiers are sent.
The endpoint resolves city- and town-level inputs (Dallas, Big Bend National Park). It does NOT do street addresses; for those, a future slice would need a self-hosted Nominatim (heavyweight) or a keyed commercial geocoder. The trip-planner use case in slice 2 is "where am I going at the city level," which this covers.
Index ¶
Constants ¶
const DefaultBaseURL = "https://geocoding-api.open-meteo.com"
DefaultBaseURL is Open-Meteo's geocoding endpoint. Override on the Client for tests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lodging ¶ added in v0.40.0
type Lodging struct {
Name string
Lat float64
Lon float64
// ID is the OpenStreetMap element, such as "osm:node:123456".
ID string
// Locality is the town, when Photon has one.
Locality string
}
Lodging is a hotel or motel from the OpenStreetMap data Photon serves.
type PhotonClient ¶
PhotonClient wraps a self-hosted Photon HTTP API. Photon's GeoJSON FeatureCollection is mapped onto the same Result shape Open-Meteo uses so the SPA contract stays unchanged. Empty BaseURL disables the client; the multiplexer falls through to Open-Meteo.
func NewPhotonClient ¶
func NewPhotonClient(baseURL string) *PhotonClient
NewPhotonClient returns a Photon client. BaseURL is the in-cluster Service URL (e.g. http://photon.photon.svc.cluster.local), no trailing slash. Empty disables.
func (*PhotonClient) Enabled ¶
func (c *PhotonClient) Enabled() bool
Enabled reports whether a base URL is configured.
func (*PhotonClient) Lodging ¶ added in v0.40.0
func (c *PhotonClient) Lodging(ctx context.Context, lat, lon, radiusKm float64, limit int) ([]Lodging, error)
Lodging lists hotels and motels within radiusKm of a point through Photon's /reverse endpoint with an osm_tag filter (the text search only biases by location, so it returns hotels nationwide). Nameless places are dropped. Best effort for the caller: an error means "none found". limit is capped at 20 and radiusKm at 50.
func (*PhotonClient) Search ¶
Search forward-geocodes name through Photon's /api endpoint. Maps Photon properties onto the Result shape: name combines housenumber + street when present, falls through to .name; admin1 = state; country_code = countrycode (Photon emits lowercased, we uppercase to match Open-Meteo). Population isn't published by Photon — left at zero so the SPA's "highest-population first" sort still works for Open-Meteo fallbacks.
type Result ¶
type Result struct {
Name string `json:"name"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Country string `json:"country,omitempty"`
CountryCode string `json:"country_code,omitempty"`
// Admin1 is state / province / region. Useful for disambiguating
// "Dallas, TX" from "Dallas, OR".
Admin1 string `json:"admin1,omitempty"`
// Population helps the SPA show the relevance order Open-Meteo
// already applies (top result is highest-population match).
Population int `json:"population,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
Result is one search match. Fields mirror Open-Meteo's response, renamed to Go conventions; the SPA gets these names verbatim via the API handler.