Show routing demonstration on radar page.

This commit is contained in:
Eli Ribble 2026-02-18 04:48:12 +00:00
parent 18c7a5f84b
commit b4817546df
No known key found for this signature in database
9 changed files with 392 additions and 129 deletions

27
tomtom/geojson.go Normal file
View file

@ -0,0 +1,27 @@
package tomtom
import (
"fmt"
"strings"
)
// Convert a slice of points to GeoJSON
func PolylineToGeoJSON(polyline []Point) string {
var sb strings.Builder
sb.WriteString(`{"type":"LineString","coordinates":[`)
for i, point := range polyline {
// IMPORTANT: GeoJSON uses [longitude, latitude] order!
sb.WriteString(fmt.Sprintf("[%g,%g]", point.Longitude, point.Latitude))
// Add comma if not the last point
if i < len(polyline)-1 {
sb.WriteString(",")
}
}
sb.WriteString("]}")
return sb.String()
}