Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tms support merged #1

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/tile/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';
import { WebpMachine, loadBinaryData } from 'webp-hero';
import { lngLatToGoogle,lngLatToTile } from 'global-mercator';
import { lngLatToGoogle, lngLatToTile } from 'global-mercator';

import PNG from '../png';

/**
Expand All @@ -17,20 +18,24 @@ abstract class BaseTile {

protected maxzoom: number;

protected tms: boolean;

/**
* Constructor
* @param url URL for terrain RGB raster tilesets
* @param tileSize size of tile. 256 or 512
* @param tms whether it is Tile Map Service
* @param minzoom minzoom for terrain RGB raster tilesets
* @param maxzoom maxzoom for terrain RGB raster tilesets
* @param tms whether it is Tile Map Service
*/
constructor(url: string, tileSize: number, tms: boolean, minzoom: number, maxzoom: number) {
constructor(url: string, tileSize: number, minzoom: number, maxzoom: number, tms: boolean) {
this.url = url;
this.tileSize = tileSize;
this.tms = tms;
this.minzoom = minzoom;
this.maxzoom = maxzoom;
this.tms = tms;
}

/**
Expand All @@ -50,7 +55,7 @@ abstract class BaseTile {
} else if (z < this.minzoom) {
zoom = this.minzoom;
}
const tile = this.tms?lngLatToTile([lng, lat], zoom):lngLatToGoogle([lng, lat], zoom);
const tile = this.tms ? lngLatToTile([lng, lat], zoom) : lngLatToGoogle([lng, lat], zoom);
const url: string = this.url
.replace(/{x}/g, tile[0].toString())
.replace(/{y}/g, tile[1].toString())
Expand Down
4 changes: 2 additions & 2 deletions src/tile/terrainrgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class TerrainRGB extends BaseTile {
* @param minzoom minzoom for terrain RGB raster tilesets. default is 5
* @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
*/
constructor(url: string, tileSize: number, tms:boolean = false, minzoom = 5, maxzoom = 15) {
super(url, tileSize, tms, minzoom, maxzoom);
constructor(url: string, tileSize: number, minzoom = 5, maxzoom = 15, tms = false) {
super(url, tileSize, minzoom, maxzoom, tms);
}

/**
Expand Down