-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
124 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
test.sh | ||
node_modules | ||
coverage/ | ||
tilepack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
*.lockb | ||
.husky/ | ||
src/ | ||
test.sh | ||
tests/ | ||
*.sh | ||
.github/ | ||
node_modules/ | ||
*.gif | ||
eslint.config.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { setupDatabase } from "./db"; | ||
import { processZoomLevel } from "./tile"; | ||
import { parseBoundingBox, BoundingBox } from "./utils"; | ||
import { Args } from "./types"; | ||
|
||
export type TilePackOptions = Omit<Args, "help" | "version">; | ||
|
||
export class TilePack { | ||
private readonly options: TilePackOptions; | ||
private readonly bbox: BoundingBox; | ||
private readonly headers: Record<string, string>; | ||
|
||
constructor(options: TilePackOptions) { | ||
this.options = options; | ||
this.bbox = parseBoundingBox(this.options.bbox); | ||
this.headers = Object.fromEntries( | ||
this.options.header.map((h) => h.split(":")), | ||
); | ||
} | ||
|
||
public async run() { | ||
const db = setupDatabase(this.options.output, this.options, this.bbox); | ||
|
||
for ( | ||
let zoom = this.options.minzoom; | ||
zoom <= this.options.maxzoom; | ||
zoom++ | ||
) { | ||
await processZoomLevel(db, zoom, this.bbox, this.options, this.headers); | ||
} | ||
|
||
console.log("Finished processing all zoom levels"); | ||
db.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export interface Args { | ||
// Show the version number | ||
version: boolean; | ||
|
||
// Show this help message | ||
help: boolean; | ||
|
||
// The path where the MBTiles file will be saved (default: output.mbtiles) | ||
output: string; | ||
|
||
// The base URL for the XYZ tiles (required) | ||
input: string; | ||
|
||
// The minimum zoom level to fetch tiles | ||
minzoom: number; | ||
|
||
// The maximum zoom level to fetch tiles | ||
maxzoom: number; | ||
|
||
// The bounding box for the tile fetching in the format minLon,minLat,maxLon,maxLat | ||
bbox: string; | ||
|
||
// HTTP headers to include in tile requests | ||
header: string[]; | ||
|
||
// An API token for authenticated requests. Used in input URL | ||
token: string; | ||
|
||
// The number of retry attempts for failed requests (default: 0) | ||
retry: number; | ||
|
||
// The format of the tiles (e.g., png, jpeg) (default: png) | ||
format: string; | ||
|
||
// The number of concurrent requests to fetch tiles (default: 15) | ||
concurrency: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters