Add working ability to get stadia tiles directly

This commit is contained in:
Eli Ribble 2026-04-16 20:37:49 +00:00
parent 163b0f9edc
commit d03c12ffb6
No known key found for this signature in database
9 changed files with 149 additions and 11 deletions

View file

@ -0,0 +1,55 @@
package main
import (
"context"
"flag"
"log"
"os"
"github.com/Gleipnir-Technology/nidus-sync/stadia"
)
func main() {
// Define command-line flags
lat := flag.Float64("lat", 0, "The latitude of the tile")
lng := flag.Float64("lng", 0, "The longitude of the tile")
zoom := flag.Uint("zoom", 16, "The zoom level")
// Parse the flags
flag.Parse()
if *lat == 0 {
log.Println("Error: you must specify -lat")
flag.Usage()
os.Exit(1)
}
if *lng == 0 {
log.Println("Error: you must specify -lng")
flag.Usage()
os.Exit(1)
}
key := os.Getenv("STADIA_MAPS_API_KEY")
if key == "" {
log.Println("STADIA_MAPS_API_KEY is empty")
os.Exit(1)
}
client := stadia.NewStadiaMaps(key)
ctx := context.Background()
req := stadia.RequestTileRaster{
Latitude: *lat,
Longitude: *lng,
Zoom: *zoom,
}
data, err := client.TileRaster(ctx, req)
if err != nil {
log.Printf("err: %v\n", err)
os.Exit(2)
}
err = os.WriteFile("tile.raw", data, 0666)
if err != nil {
log.Printf("err: %v\n", err)
os.Exit(2)
}
log.Printf("wrote tile.raw")
}