Skip to content

Commit

Permalink
adds logiclayer support for Place-Tract and MSA-Tract cuts
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Jan 15, 2019
1 parent 0de2287 commit b1776ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions api/crosswalks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
Expand Down
2 changes: 1 addition & 1 deletion canon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down

0 comments on commit b1776ed

Please sign in to comment.