photon

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package photon is the library behind the photon command line: the HTTP client, request shaping, and the typed data models for the Photon geocoding service by Komoot (photon.komoot.io).

Photon is based on OpenStreetMap data with 700M+ places, buildings, roads, and POIs. It supports full-text search and reverse geocoding with no API key required.

Index

Constants

View Source
const Host = "photon.komoot.io"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Photon geocoding service over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) NearbyPlaces

func (c *Client) NearbyPlaces(ctx context.Context, query string, lat, lon float64, limit int, lang string) ([]Place, error)

NearbyPlaces searches for places matching query near the given coordinates.

func (*Client) ReversePlaces

func (c *Client) ReversePlaces(ctx context.Context, lat, lon string, limit int, lang string) ([]Place, error)

ReversePlaces performs reverse geocoding: converts lat/lon into a list of matching places.

func (*Client) SearchPlaces

func (c *Client) SearchPlaces(ctx context.Context, query string, limit int, lang string) ([]Place, error)

SearchPlaces performs forward geocoding: converts a free-form query into a list of matching places.

type Config

type Config struct {
	BaseURL    string
	ReverseURL string
	UserAgent  string
	Rate       time.Duration
	Timeout    time.Duration
	Retries    int
	Lang       string
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the photon driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Place

type Place struct {
	Name        string  `json:"name"`
	Type        string  `json:"type"`     // osm_value: city, restaurant, etc.
	Category    string  `json:"category"` // osm_key: place, amenity, etc.
	Street      string  `json:"street"`
	HouseNumber string  `json:"house_number"`
	Postcode    string  `json:"postcode"`
	City        string  `json:"city"`
	State       string  `json:"state"`
	Country     string  `json:"country"`
	CountryCode string  `json:"country_code"`
	Lat         float64 `json:"lat"`
	Lon         float64 `json:"lon"`
	OsmID       int64   `json:"osm_id"`
	OsmType     string  `json:"osm_type"`
}

Place is a geocoding result from the Photon API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL