Skip to content

Commit

Permalink
Merge pull request #680 from azavea/feature/kjh/remove-layer-filter
Browse files Browse the repository at this point in the history
Remove layer filter
  • Loading branch information
KlaasH authored Jan 29, 2019
2 parents 0614c74 + ca32634 commit a7daa2a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 535 deletions.
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

0 comments on commit a7daa2a

Please sign in to comment.