-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Read crs
information from metadata
#114
Changes from all commits
1b2762a
870475b
e8af016
6868c9f
405ea05
79e5366
7a3823c
6842eb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { point, rhumbBearing, rhumbDestination } from '@turf/turf' | ||
import { select } from 'd3-selection' | ||
|
||
const d2r = Math.PI / 180 | ||
|
||
|
@@ -41,7 +40,7 @@ export const pointToTile = (lon, lat, z, projection, order) => { | |
y = Math.max(Math.min(y, z2), 0) | ||
tile = [x, y, z] | ||
default: | ||
break | ||
return | ||
} | ||
tile[0] = Math.floor(tile[0]) | ||
tile[1] = Math.min(Math.floor(tile[1]), z2 - 1) | ||
|
@@ -349,13 +348,21 @@ export const getPyramidMetadata = (multiscales) => { | |
const levels = datasets.map((dataset) => Number(dataset.path)) | ||
const maxZoom = Math.max(...levels) | ||
const tileSize = datasets[0].pixels_per_tile | ||
let crs = datasets[0].crs | ||
|
||
if (!tileSize) { | ||
throw new Error( | ||
'Missing required `pixels_per_tile` value in `multiscales` metadata. Please check your pyramid generation code.' | ||
) | ||
} | ||
return { levels, maxZoom, tileSize } | ||
|
||
if (!crs) { | ||
console.warn( | ||
'Missing `crs` value in `multiscales` metadata. Please check your pyramid generation code. Falling back to `crs=EPSG:3857` (Web Mercator)' | ||
) | ||
crs = 'EPSG:3857' | ||
} | ||
return { levels, maxZoom, tileSize, crs } | ||
Comment on lines
+359
to
+365
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be worth adding a check to see if the provided crs is one of our two valid options and to report out those options if not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a consolidated check in |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we default to mercator in the shader in the case of a -1 index, but is there any other reason to handle an invalid index early here? Seems like
updateCamera
and maybe the region picker stuff might be sad ifthis.projection
ends up undefined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Decided to add a check here to handle either an unexpected
crs
andprojection
value. Want to take another look.