geo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package geo turns addresses into coordinates and coordinates into bounding boxes.

Geocoding goes through the Base Adresse Nationale, the French government's open address database: no API key, no quota worth worrying about, and house-number precision. It only covers France, which matches the tool — titres-restaurant are a French scheme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(a, b Point) float64

Distance returns the great-circle distance between two points, in metres.

Types

type BBox

type BBox struct {
	NE Point
	SW Point
}

BBox is a rectangle, expressed the way the Swile API wants it.

func Box

func Box(centre Point, radiusM float64) BBox

Box builds the bounding box that circumscribes a circle of radius metres around centre.

type Place

type Place struct {
	Label    string  `json:"label"`
	City     string  `json:"city"`
	Postcode string  `json:"postcode"`
	Point    Point   `json:"point"`
	Score    float64 `json:"score"`
}

Place is a geocoded address.

func Geocode

func Geocode(ctx context.Context, query string) (*Place, error)

Geocode resolves a free-form French address to a single best match.

type Point

type Point struct {
	Lat float64 `json:"latitude"`
	Lng float64 `json:"longitude"`
}

Point is a WGS84 coordinate.

Jump to

Keyboard shortcuts

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