From b1776edb00ceb7cf0705e6d4eccf876f4f2aee7d Mon Sep 17 00:00:00 2001 From: Dave Landry Date: Tue, 15 Jan 2019 09:40:11 -0500 Subject: [PATCH] adds logiclayer support for Place-Tract and MSA-Tract cuts --- api/crosswalks.js | 24 ++++++++++++++++++------ canon.js | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/api/crosswalks.js b/api/crosswalks.js index 6c7589d60..bca2907e8 100644 --- a/api/crosswalks.js +++ b/api/crosswalks.js @@ -37,14 +37,26 @@ module.exports = function(app) { drilldown = level || "Tract"; } else if (prefix === "310") { // MSA - cut = await axios.get(`${CANON_LOGICLAYER_CUBE}/geoservice-api/relations/intersects/${id}?targetLevels=state&overlapSize=true`) - .then(resp => resp.data) - .then(arr => arr.sort((a, b) => b.overlap_size - a.overlap_size)[0].geoid); - drilldown = level || "County"; + if (level === "Tract") { + cut = id; + drilldown = "MSA-Tract"; + } + else { + cut = await axios.get(`${CANON_LOGICLAYER_CUBE}/geoservice-api/relations/intersects/${id}?targetLevels=state&overlapSize=true`) + .then(resp => resp.data) + .then(arr => arr.sort((a, b) => b.overlap_size - a.overlap_size)[0].geoid); + drilldown = level || "County"; + } } else if (prefix === "160") { // Place - cut = `040${id.slice(3, 9)}`; - drilldown = level || "Place"; + if (level === "Tract") { + cut = id; + drilldown = "Place-Tract"; + } + else { + cut = `040${id.slice(3, 9)}`; + drilldown = level || "Place"; + } } else if (prefix === "795") { // Puma cut = `040${id.slice(3, 9)}`; diff --git a/canon.js b/canon.js index 3954e454a..06d8318e7 100644 --- a/canon.js +++ b/canon.js @@ -21,7 +21,7 @@ module.exports = { .filter(d => d.dimension === "Geography") .map(d => d.id instanceof Array ? d.id : [d.id])); const bigGeos = ids.every(g => pops[g] && pops[g] >= 250000); - const tracts = query.dimensions.filter(d => d.relation === "Tract").length; + const tracts = query.dimensions.filter(d => d.relation.includes("Tract")).length; return cubes.filter(cube => cube.name.match(bigGeos && !tracts ? /_1$/g : /_5$/g)); }, key: cube => cube.name.replace(/_[0-9]$/g, "")