Fall back to full tile
This commit is contained in:
@@ -30,9 +30,21 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "Fetching: %s\n", arg)
|
fmt.Fprintf(os.Stderr, "Fetching: %s\n", arg)
|
||||||
tileData, err = utils.FetchURL(arg)
|
tileData, err = utils.FetchURL(arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// If it's a 404 and the URL is for a partial tile, try the full tile
|
||||||
|
if err.Error() == "HTTP 404" && strings.Contains(arg, ".p/") {
|
||||||
|
fullTileURL := arg[:strings.Index(arg, ".p/")]
|
||||||
|
fmt.Fprintf(os.Stderr, "Partial tile not found, trying full tile: %s\n", fullTileURL)
|
||||||
|
tileData, err = utils.FetchURL(fullTileURL)
|
||||||
|
if err != nil {
|
||||||
|
fatal("failed to fetch full tile: %v", err)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(os.Stderr, "Fetched %d bytes from full tile\n", len(tileData))
|
||||||
|
} else {
|
||||||
fatal("failed to fetch URL: %v", err)
|
fatal("failed to fetch URL: %v", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, "Fetched %d bytes\n", len(tileData))
|
fmt.Fprintf(os.Stderr, "Fetched %d bytes\n", len(tileData))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Read from file
|
// Read from file
|
||||||
tileData, err = os.ReadFile(arg)
|
tileData, err = os.ReadFile(arg)
|
||||||
|
|||||||
Reference in New Issue
Block a user