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

Remove layer filter #680

Merged
merged 1 commit into from
Jan 29, 2019
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
18 changes: 1 addition & 17 deletions src/tilegarden/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,8 @@ const getPositionalFilters = (req) => {
return remainder
}

// Returns a properly formatted list of layers
// or an empty list if there are none
const processLayers = (req) => {
if (req.queryStringParameters.layers) return JSON.parse(req.queryStringParameters.layers)
else if (req.queryStringParameters.layer ||
req.queryStringParameters.filter ||
req.queryStringParameters.filters) {
/* eslint-disable-next-line quotes */
throw HTTPError("Invalid argument, did you mean '&layers='?", 400)
}

return []
}

// Parses out the configuration specifications
const processConfig = req => ({
s3bucket: req.queryStringParameters.s3bucket,
config: req.pathParameters.config,
})

Expand Down Expand Up @@ -114,10 +99,9 @@ api.get(
try {
const { z, x, y } = processCoords(req)
const filters = getPositionalFilters(req)
const layers = processLayers(req)
const configOptions = processConfig(req)

return imageTile(createMap(z, x, y, filters, layers, configOptions))
return imageTile(createMap(z, x, y, filters, configOptions))
.then(tile => writeToS3(tile, req))
.then(img => new APIBuilder.ApiResponse(img, IMAGE_HEADERS, 200))
.catch(handleError)
Expand Down
4 changes: 1 addition & 3 deletions src/tilegarden/src/tiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const readFile = promisify(require('fs').readFile)

const addParamFilters = require('./util/param-filter')
const bbox = require('./util/bounding-box')
const filterVisibleLayers = require('./util/layer-filter')
const HTTPError = require('./util/error-builder')
const { parseXml, buildXml } = require('./util/xml-tools')

Expand Down Expand Up @@ -78,15 +77,14 @@ const fetchMapFile = (options) => {
* @param y
* @returns {Promise<mapnik.Map>}
*/
module.exports.createMap = (z, x, y, filters, layers, configOptions) => {
module.exports.createMap = (z, x, y, filters, configOptions) => {
// Create a webmercator map with specified bounds
const map = new mapnik.Map(TILE_WIDTH, TILE_HEIGHT)
map.bufferSize = 64

// Load map specification from xml string
return fetchMapFile(configOptions)
.then(parseXml)
.then(xmlJsObj => filterVisibleLayers(xmlJsObj, layers))
.then(xmlJsObj => addParamFilters(xmlJsObj, filters))
.then(buildXml)
.then(xml => new Promise((resolve, reject) => {
Expand Down
119 changes: 0 additions & 119 deletions src/tilegarden/src/util/layer-filter.js

This file was deleted.

38 changes: 1 addition & 37 deletions src/tilegarden/tests/api.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const rewire = require('rewire')
const api = rewire('../src/api'),
processCoords = api.__get__('processCoords'),
processLayers = api.__get__('processLayers')
processCoords = api.__get__('processCoords')

describe('processCoords', () => {
test('properly parses properly formatted coords', () => {
Expand Down Expand Up @@ -73,38 +72,3 @@ describe('processCoords', () => {
})
})

describe('processLayers', () => {
test('properly parses list of layer', () => {
const req = {
queryStringParameters: {
layers: '["layer1","layer2","layer3","layer4"]'
}
}
expect(processLayers(req)).toEqual(['layer1','layer2','layer3','layer4'])
})

test('properly parses just one layer', () => {
const req = {
queryStringParameters: {
layers: '["layer"]'
}
}
expect(processLayers(req)).toEqual(['layer'])
})

test('properly parses no fields', () => {
const req = {
queryStringParameters: {}
}
expect(processLayers(req)).toEqual([])
})

test('properly parses a blank field', () => {
const req = {
queryStringParameters: {
layers: ''
}
}
expect(processLayers(req)).toEqual([])
})
})
Loading