Skip to content

Commit

Permalink
feat: Kapture must take into account the current time (close #3)
Browse files Browse the repository at this point in the history
wip: When capturing from Kano canvas layers are not well handled #5
  • Loading branch information
cnouguier committed Dec 16, 2021
1 parent 2ccd3c5 commit 525598e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ function deleteTmpFile (file) {
queryParams.push(`time=${parameters.time}`)
}
_.forEach(parameters.layers, layer => {
const layerId = _.replace(_.replace(_.upperCase(layer), / /g, '_'), 'LAYERS_', 'Layers.')
let layerId = layer
if (_.startsWith(layer, 'layers-')) layerId = _.replace(_.replace(_.upperCase(layer), / /g, '_'), 'LAYERS_', 'Layers.')
queryParams.push(`layers=${layerId}`)
})
if (!_.isEmpty(queryParams)) url += `?${_.join(queryParams, '&')}`
Expand Down
8 changes: 4 additions & 4 deletions test/capture.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe(`suite:${suite}`, () => {

it('capture multiple zoomed layers', async () => {
const body = {
layers: ['layers-imagery', 'layers-mapillary', 'layers-adminexpress'],
layers: ['Layers.IMAGERY', 'Layers.MAPILLARY', 'Layers.ADMINEXPRESS'],
bbox: [ 1.6, 43.10, 1.65, 43.14 ]
}
const res = await capture(body, 'layers')
Expand All @@ -102,7 +102,7 @@ describe(`suite:${suite}`, () => {

it('capture gradient geoson file', async () => {
let body = JSON.parse(fs.readFileSync(path.join(dataDir, 'flight.geojson')))
body.layers = ['layers-osm-dark']
body.layers = ['Layers.OSM_DARK']
body.size = { width: 800, height: 600 }
const res = await capture(body, 'flight')
expect(res.status).to.equal(200)
Expand All @@ -111,7 +111,7 @@ describe(`suite:${suite}`, () => {

it('capture geojson with defined bbox', async () => {
let body = JSON.parse(fs.readFileSync(path.join(dataDir, 'flight.geojson')))
body.layers = ['layers-osm-dark']
body.layers = ['Layers.OSM_DARK']
body.size = { width: 800, height: 600 }
body.bbox = [ 3.5, 51, 5.5, 53 ]
const res = await capture(body, 'landing')
Expand All @@ -121,7 +121,7 @@ describe(`suite:${suite}`, () => {

it('capture mask geoson file', async () => {
let body = JSON.parse(fs.readFileSync(path.join(dataDir, 'occitanie.geojson')))
body.layers = ['layers-hybrid']
body.layers = ['Layers.HYBRID']
body.size = { width: 1200, height: 900 }
const res = await capture(body, 'mask')
expect(res.status).to.equal(200)
Expand Down

0 comments on commit 525598e

Please sign in to comment.