Skip to content

Commit

Permalink
fix: change center
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Calcutt <[email protected]>
  • Loading branch information
acalcutt committed Oct 12, 2023
1 parent 68168ce commit 5f1b281
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/pmtiles_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,27 @@ export const GetPMtilesInfo = async (pmtiles) => {
metadata['minzoom'] = header.minZoom;
metadata['maxzoom'] = header.maxZoom;

if(header.minLon && header.minLat && header.maxLon && header.maxLat) {
metadata['bounds'] = [header.minLon, header.minLat, header.maxLon, header.maxLat];
if (header.minLon && header.minLat && header.maxLon && header.maxLat) {
metadata['bounds'] = [
header.minLon,
header.minLat,
header.maxLon,
header.maxLat,
];
} else {
metadata['bounds'] = [-180, -85.05112877980659, 180, 85.0511287798066];
}

if(header.centerLon && header.centerLat && header.centerZoom) {
metadata['center'] = [header.centerLon, header.centerLat, header.centerZoom];
if (header.centerZoom) {
metadata['center'] = [
header.centerLon,
header.centerLat,
header.centerZoom,
];
} else {
metadata['center'] = [
(parseInt(metadata['bounds'][0]) + parseInt(metadata['bounds'][2])) / 2,
(parseInt(metadata['bounds'][1]) + parseInt(metadata['bounds'][3])) / 2,
header.centerLon,
header.centerLat,
parseInt(metadata['maxzoom']) / 2,
];
}
Expand Down

0 comments on commit 5f1b281

Please sign in to comment.