- DESIGN.md: full design incl. driving-trip requirements (R1-R4), stays model, focus mode, mobile, provenance rules - SURVEY.md: open-source landscape - mock/: interaction mock (Florence itinerary, focus mode, stays, region stops, mobile layout) - router/: Go module (stdlib-only) with Router interface (Valhalla + OSRM backends), stop_cost, optimize_stops, corridor, routectl CLI, bench (5 real NE-corridor tasks, 26 checks passing), integration tests, and setup-osrm.sh for the self-hosted router - osm/: NH+MA+CT+NY PBFs (gitignored) + setup artifacts
35 lines
1020 B
Go
35 lines
1020 B
Go
package geo
|
|
|
|
import "testing"
|
|
|
|
func TestMeters(t *testing.T) {
|
|
// NYC → Boston ≈ 305 km
|
|
d := Meters(Point{Lat: 40.7128, Lon: -74.006}, Point{Lat: 42.3601, Lon: -71.0589})
|
|
if d < 300_000 || d > 320_000 {
|
|
t.Errorf("NYC-Boston = %.0f m, want ~305km", d)
|
|
}
|
|
}
|
|
|
|
func TestDistToPolyline(t *testing.T) {
|
|
poly := []Point{{Lat: 0, Lon: 0}, {Lat: 10, Lon: 0}} // north-south at lon 0
|
|
// 1 deg lon at equator ≈ 111.3 km
|
|
d := DistToPolylineMeters(Point{Lat: 5, Lon: 1}, poly)
|
|
if d < 110_000 || d > 115_000 {
|
|
t.Errorf("distance = %.0f m, want ~111km", d)
|
|
}
|
|
// on the line
|
|
if d := DistToPolylineMeters(Point{Lat: 5, Lon: 0}, poly); d > 100 {
|
|
t.Errorf("on-line distance = %.0f m, want ~0", d)
|
|
}
|
|
// past the end: distance to endpoint
|
|
if d := DistToPolylineMeters(Point{Lat: 12, Lon: 0}, poly); d < 200_000 || d > 240_000 {
|
|
t.Errorf("past-end distance = %.0f m, want ~222km", d)
|
|
}
|
|
}
|
|
|
|
func TestMinAt(t *testing.T) {
|
|
if m := MinAt(4600, 4.6); m != 60 {
|
|
t.Errorf("MinAt(4600m, 4.6kmh) = %d, want 60", m)
|
|
}
|
|
}
|