-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: adds checks for missing properties #1104
base: master
Are you sure you want to change the base?
Changes from all commits
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 | ||||
---|---|---|---|---|---|---|
|
@@ -10,7 +10,7 @@ import OlTileGrid from 'ol/tilegrid/TileGrid'; | |||||
import OlLayer from 'ol/layer/Base'; | ||||||
import OlLayerGroup from 'ol/layer/Group'; | ||||||
import {get as getProjection, transformExtent, transform} from 'ol/proj'; | ||||||
import { getWidth } from 'ol/extent'; | ||||||
import { getTopLeft, getWidth } from 'ol/extent'; | ||||||
|
||||||
import * as moment from 'moment'; | ||||||
|
||||||
|
@@ -186,23 +186,60 @@ class Shogun2AppContextUtil extends BaseAppContextUtil implements AppContextUtil | |||||
legendUrl | ||||||
} = layer.appearance; | ||||||
|
||||||
const wmtsTileGrid = new OlTileGridWMTS({ | ||||||
origin: layer.source.tileGrid.origin, | ||||||
resolutions: layer.source.tileGrid.resolutions, | ||||||
matrixIds: layer.source.tileGrid.matrixIds | ||||||
}); | ||||||
let projection; | ||||||
let wmtsTileGrid; | ||||||
let style; | ||||||
|
||||||
if (layer.source.projection) { | ||||||
projection = layer.source.projection; | ||||||
} else { | ||||||
projection = getProjection('EPSG:3857'); | ||||||
}; | ||||||
|
||||||
if (layer.source.tileGrid.origin && | ||||||
layer.source.tileGrid.resolutions && | ||||||
layer.source.tileGrid.matrixIds) { | ||||||
wmtsTileGrid = new OlTileGridWMTS({ | ||||||
origin: layer.source.tileGrid.origin, | ||||||
resolutions: layer.source.tileGrid.resolutions, | ||||||
matrixIds: layer.source.tileGrid.matrixIds | ||||||
}); | ||||||
} else { | ||||||
|
||||||
const projectionExtent = projection.getExtent(); | ||||||
const size = getWidth(projectionExtent) / 256; | ||||||
const resolutions = new Array(19); | ||||||
const matrixIds = new Array(19); | ||||||
for (let z = 0; z < 19; ++z) { | ||||||
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.
Suggested change
You need to increment after the statements in the loop are made, don't you? 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. I think in that particular case it does not really matter, both variants seem to work. |
||||||
resolutions[z] = size / Math.pow(2, z); | ||||||
matrixIds[z] = z; | ||||||
} | ||||||
|
||||||
wmtsTileGrid = new OlTileGridWMTS({ | ||||||
origin: getTopLeft(projectionExtent), | ||||||
resolutions: resolutions, | ||||||
matrixIds: matrixIds, | ||||||
}); | ||||||
}; | ||||||
|
||||||
if (layer.source.style) { | ||||||
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. Minor: You could also write
instead of the 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. Yes that looks way more clean thank you! |
||||||
style = layer.source.style; | ||||||
} else { | ||||||
style = 'default'; | ||||||
} | ||||||
|
||||||
const wmtsSource = new OlSourceWMTS({ | ||||||
projection: layer.source.projection, | ||||||
urls: [ | ||||||
layer.source.url | ||||||
], | ||||||
layer: layer.source.layerNames, | ||||||
format: layer.source.format, | ||||||
matrixSet: layer.source.tileMatrixSet, | ||||||
attributions: [attribution], | ||||||
matrixSet: layer.source.matrixSet, | ||||||
projection: projection, | ||||||
tileGrid: wmtsTileGrid, | ||||||
style: layer.source.style, | ||||||
style: style, | ||||||
wrapX: true, | ||||||
requestEncoding: layer.source.requestEncoding | ||||||
}); | ||||||
|
||||||
|
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.
You assume that always 19 Matrix levels are available in tile grid definition?
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.
I got this part from the OpenLayers Examples but you are right, the array could always be different!