Discover Packages
github.com/SimonWaldherr/tinySQL
routing
package
Version:
v0.51.0
Opens a new window with list of versions in this module.
Published: Sep 5, 2026
License: AGPL-3.0
Opens a new window with license information.
Imports: 13
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Jump to ...
Documentation
Overview
Index
Constants
Variables
Functions
Types
type Data
type Geometry
type Member
type Node
type Options
type Point
type Profile
type Relation
type Request
type Result
type Router
Build(ctx, data, p, opts)
FromDB(ctx, db, tenant, table, profile, opts)
(r) Nearest(ctx, p, maxMeters)
(r) Route(ctx, req)
(r) Stats()
type Snap
type Stats
type Way
Source Files
Documentation
Documentation
¶
Package routing compiles tinySQL OSM tables into immutable, profile-specific
road graphs. Queries use edge snapping and restriction-aware A* without an
answer cache. Routers are safe for concurrent use.
Variables
func Handler(routers map[Profile]*Router) http.Handler
type Data
type Geometry
type Member
type Node
type Options
type Point
type Profile
type Relation
type Request
type Result
type Router
func Build(ctx context.Context, data Data, p Profile, opts Options) (*Router, error)
func FromDB(ctx context.Context, db *tinysql.DB, tenant, table string, profile Profile, ...) (*Router, error)
type Snap
type Stats
type Way
Handler exposes GET/POST /route, GET /nearest, /profiles and /healthz.
Its profile map is copied; replace the handler to publish a new snapshot.
ReadOSM reads an OSM XML snapshot. Definitions may appear in any order;
coordinate and topology validation happens during Build. PBF needs an
external conversion to OSM XML or a tinySQL OSM table first.
type Geometry struct {
Type string `json:"type"`
Coordinates [][2]float64 `json:"coordinates"`
}
type Member struct {
Type string `json:"type"`
Ref int64 `json:"ref"`
Role string `json:"role"`
}
type Options struct {
MaxStates int
MaxRestrictionPrefixes int
}
type Point struct {
Lon float64 `json:"lon"`
Lat float64 `json:"lat"`
}
type Request struct {
From Point `json:"from"`
To Point `json:"to"`
MaxSnapMeters float64 `json:"max_snap_meters,omitempty"`
}
type Result struct {
Profile Profile `json:"profile"`
DistanceMeters float64 `json:"distance_meters"`
DurationSeconds float64 `json:"duration_seconds"`
From Snap `json:"from"`
To Snap `json:"to"`
Geometry Geometry `json:"geometry"`
VisitedStates int `json:"visited_states"`
}
Build compiles one immutable routing profile. Unsupported conditional rules
return an error; no route is returned under silently discarded restrictions.
FromDB builds from the normalized table produced by importer.ImportOSM.
Execute takes a consistent snapshot; later DB writes do not mutate a Router.
Nearest returns the exact nearest eligible road segment within maxMeters.
The BVH uses conservative 3-D bounds, including at the poles/date line.
Route computes a fastest legal route, including partial first/last segments.
No prior answer, snapping result, or query scratch buffer is reused.
type Snap struct {
Point Point `json:"point"`
DistanceMeters float64 `json:"distance_meters"`
WayID int64 `json:"way_id"`
Fraction float64 `json:"fraction"`
}
type Stats struct {
Profile Profile `json:"profile"`
Nodes int `json:"nodes"`
DirectedEdges int `json:"directed_edges"`
Segments int `json:"segments"`
RestrictionPrefixes int `json:"restriction_prefixes"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.