try {
instanceid = parseInt(req.query.instance_id, 10);
table = req.params.table;
zoom = req.params.z;
isPolygonRequest = (table === 'stormwater_polygonalmapfeature');
if (table === 'treemap_mapfeature' || isPolygonRequest) {
filterString = req.query[config.filterQueryArgumentName];
displayString = req.query[config.displayQueryArgumentName];
restrictFeatureString = req.query[config.restrictFeatureQueryArgumentName];
isUtfGridRequest = (req.params.format === 'grid.json');
req.params.sql = makeSql.makeSqlForMapFeatures(filterString,
displayString,
restrictFeatureString,
instanceid,
zoom,
isUtfGridRequest,
isPolygonRequest,
req.instanceConfig);
if (isPolygonRequest) {
req.params.style = styles.polygonalMapFeature;
} else if (isUtfGridRequest) {
req.params.style = styles.uncoloredMapFeature;
} else {
req.params.style = styles.mapFeature;
}
} else if (table === 'treemap_boundary' && instanceid) {
req.params.sql = makeSql.makeSqlForBoundaries(instanceid);
req.params.style = styles.boundary;
} else if (table === 'treemap_canopy_boundary' && instanceid) {
var canopyMin = parseFloat(req.query.canopyMin),
canopyMax = parseFloat(req.query.canopyMax),
category = parseBoundaryCategory(req.query.category);
if (!category) {
throw new Error('Invalid argument: category');
}
if (isNaN(canopyMin) || !isFinite(canopyMin)) {
throw new Error('Invalid argument: canopyMin');
}
if (isNaN(canopyMax) || !isFinite(canopyMax)) {
throw new Error('Invalid argument: canopyMax');
}
req.params.sql = makeSql.makeSqlForCanopyBoundaries(instanceid,
canopyMin, canopyMax, category);
req.params.style = styles.canopy;
}
} catch (err) {
if (rollbarAccessToken) {
rollbar.error(err, req);
}
callback(err, null);
}