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

Update Tilegarden node to 12.x #810

Closed
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
2 changes: 1 addition & 1 deletion src/tilegarden/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.15-stretch-slim
FROM node:12.19-stretch-slim

ENV BASE_DIR /opt/pfb/tilegarden

Expand Down
29 changes: 15 additions & 14 deletions src/tilegarden/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tilegarden-pfb",
"version": "1.0.0",
"version": "1.0.1",
"description": "AWS Lambda mapnik renderer",
"contributors": [
{
Expand Down Expand Up @@ -34,23 +34,24 @@
"compile": "rsync -a src/*.js src/util src/config --exclude '*.mml' --exclude '*.mss' dist/"
},
"devDependencies": {
"bunyan": "^1.8.12",
"claudia": "^5.0.1",
"bunyan": "^1.8.14",
"claudia": "^5.12.0",
"claudia-local-api": "https://github.com/azavea/claudia-local-api.git",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.12.0",
"jest": "^23.2.0",
"nodemon": "^1.17.5",
"rewire": "^4.0.1"
"eslint": "^7.11.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.5.3",
"nodemon": "^2.0.5",
"rewire": "^5.0.0"
},
"dependencies": {
"claudia-api-builder": "^4.1.0",
"lambda-warmer": "^1.1.0",
"mapnik": "^3.7.2",
"claudia-api-builder": "^4.1.2",
"lambda-warmer": "^1.2.1",
"mapnik": "^4.5.2",
"pg": "^8.4.1",
"sql-escape-string": "^1.1.0",
"winston": "^3.2.1",
"xml2js": "^0.4.19"
"winston": "^3.3.3",
"xml2js": "^0.4.23"
},
"optionalDependencies": {
"aws-sdk": "^2.290.0"
Expand Down
10 changes: 5 additions & 5 deletions src/tilegarden/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getPositionalFilters = (req) => {
}

// Parses out the configuration specifications
const processConfig = req => ({
const processConfig = (req) => ({
s3bucket: req.queryStringParameters ? req.queryStringParameters.s3bucket : null,
config: req.pathParameters.config,
})
Expand Down Expand Up @@ -100,7 +100,7 @@ const writeToS3 = (tile, req) => {
return tile
})
}
return new Promise(resolve => resolve(tile))
return new Promise((resolve) => resolve(tile))
}

// Get tile for some zxy bounds
Expand All @@ -114,8 +114,8 @@ api.get(

logger.debug('api.get: creating imageTile')
return imageTile(createMap(z, x, y, filters, configOptions))
.then(tile => writeToS3(tile, req))
.then(img => new APIBuilder.ApiResponse(img, IMAGE_HEADERS, 200))
.then((tile) => writeToS3(tile, req))
.then((img) => new APIBuilder.ApiResponse(img, IMAGE_HEADERS, 200))
.catch(handleError)
} catch (e) {
return handleError(e)
Expand Down Expand Up @@ -175,7 +175,7 @@ api.proxyRouter = (event, context, callback) => {
} else {
origProxyRouter(event, context, callback)
}
}).catch(err => logger.error('Error: ', err))
}).catch((err) => logger.error('Error: ', err))
}

// not es6-ic, but necessary for claudia to find the index
Expand Down
8 changes: 4 additions & 4 deletions src/tilegarden/src/tiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ module.exports.createMap = (z, x, y, filters, configOptions) => {
return fetchMapFile(configOptions)
.then(fillVars)
.then(parseXml)
.then(xmlJsObj => addParamFilters(xmlJsObj, filters))
.then((xmlJsObj) => addParamFilters(xmlJsObj, filters))
.then(buildXml)
.then(xml => new Promise((resolve, reject) => {
.then((xml) => new Promise((resolve, reject) => {
logger.debug('createMap: calling map.FromString')
map.fromString(xml, (err, result) => {
if (err) {
Expand Down Expand Up @@ -136,14 +136,14 @@ module.exports.imageTile = (map) => {
// render map to image
// return asynchronous rendering method as a promise
return map
.then(m => new Promise((resolve, reject) => {
.then((m) => new Promise((resolve, reject) => {
logger.debug('imageTile: rendering')
m.render(img, {}, (err, result) => {
if (err) reject(err)
else resolve(result)
})
}))
.then(renderedTile => new Promise((resolve, reject) => {
.then((renderedTile) => new Promise((resolve, reject) => {
logger.debug('imageTile: encoding')
renderedTile.encode('png', {}, (err, result) => {
if (err) reject(err)
Expand Down
6 changes: 3 additions & 3 deletions src/tilegarden/src/util/param-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
const sqlString = require('sql-escape-string')

// Helper function to escape col but replace outer '-s with "-s to make a delimited identifier
const processCol = col => `"${sqlString(col).slice(1, -1)}"`
const processCol = (col) => `"${sqlString(col).slice(1, -1)}"`

// Combine parameters and values into a series of SQL conditions, ANDed
function composeFilterQuery(filters) {
return Object.entries(filters)
.map(entry => `${processCol(entry[0])} = ${sqlString(entry[1])}`)
.map((entry) => `${processCol(entry[0])} = ${sqlString(entry[1])}`)
.join(' AND ')
}

Expand All @@ -20,7 +20,7 @@ function composeFilterQuery(filters) {
function applyFilterQuery(xmlJson, filterQuery) {
xmlJson.Map.Layer.forEach((layer) => {
// Get the <Datasource><Parameter name="table"> element, which contains the default query
const queryObj = layer.Datasource[0].Parameter.filter(p => p.$.name === 'table')[0]
const queryObj = layer.Datasource[0].Parameter.filter((p) => p.$.name === 'table')[0]

// Add the filters onto it
const query = `SELECT * FROM ${queryObj._} WHERE ${filterQuery}`
Expand Down
Loading