[ Launch: stratifier ] 6504735 by neshmi
-
-
Save neshmi/6504735 to your computer and use it in GitHub Desktop.
stratifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"stratifier","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"stratifier.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/6Ollx6F.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"0f1027ccb30fd81af25fe81d250001cc","key":"11","value":["60.11:007","Over","Earth layer","60.11:010"]}, | |
{"id":"0f1027ccb30fd81af25fe81d250001cc","key":"11","value":["60.11:007","Seals against","Wall","60.11:003"]}, | |
{"id":"0f1027ccb30fd81af25fe81d250001cc","key":"11","value":["60.11:007","Seals against","Wall","60.11:008"]}, | |
{"id":"0f1027ccb30fd81af25fe81d250001cc","key":"11","value":["60.11:007","Under","Earth layer","60.11:006"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25000546","key":"11","value":["60.11:008","Abuts","Wall","60.11:003"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25000546","key":"11","value":["60.11:008","Sealed agnst by","Surface","60.11:007"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25000546","key":"11","value":["60.11:008","Sealed agnst by","Surface","60.11:009"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25000546","key":"11","value":["60.11:008","Under","Earth layer","60.11:006"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25001081","key":"11","value":["60.11:009","Seals against","Wall","60.11:008"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25001081","key":"11","value":["60.11:009","Under","Earth layer","60.11:006"]}, | |
{"id":"0f1027ccb30fd81af25fe81d25001d2a","key":"11","value":["60.11:010","Under","Surface","60.11:007"]}, | |
{"id":"f77ce35c0247cb300d51076ad80007cd","key":"11","value":["60.11:001","Over","Earth layer","60.11:002"]}, | |
{"id":"f77ce35c0247cb300d51076ad80007cd","key":"11","value":["60.11:001","Seals against","Wall","60.11:003"]}, | |
{"id":"f77ce35c0247cb300d51076ad8000f16","key":"11","value":["60.11:002","Over","Earth layer","60.11:004"]}, | |
{"id":"f77ce35c0247cb300d51076ad8000f16","key":"11","value":["60.11:002","Seals against","Wall","60.11:003"]}, | |
{"id":"f77ce35c0247cb300d51076ad8000f16","key":"11","value":["60.11:002","Under","Earth layer","60.11:001"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Abutted by","Wall","60.11:008"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Earth layer","60.11:001"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Earth layer","60.11:002"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Earth layer","60.11:004"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Earth layer","60.11:005"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Earth layer","60.11:006"]}, | |
{"id":"f77ce35c0247cb300d51076ad8001ce2","key":"11","value":["60.11:003","Sealed agnst by","Surface","60.11:007"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a55","key":"11","value":["60.11:004","Over","Earth layer","60.11:005"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a55","key":"11","value":["60.11:004","Seals against","Wall","60.11:003"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a55","key":"11","value":["60.11:004","Under","Earth layer","60.11:002"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a98","key":"11","value":["60.11:005","Over","Earth layer","60.11:006"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a98","key":"11","value":["60.11:005","Over","Wall","60.11:008"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a98","key":"11","value":["60.11:005","Seals against","Wall","60.11:003"]}, | |
{"id":"f77ce35c0247cb300d51076ad8002a98","key":"11","value":["60.11:005","Under","Earth layer","60.11:004"]}, | |
{"id":"f77ce35c0247cb300d51076ad8003699","key":"11","value":["60.11:006","Over","Earth layer","60.11:007"]}, | |
{"id":"f77ce35c0247cb300d51076ad8003699","key":"11","value":["60.11:006","Over","Surface","60.11:009"]}, | |
{"id":"f77ce35c0247cb300d51076ad8003699","key":"11","value":["60.11:006","Seals against","Wall","60.11:003"]}, | |
{"id":"f77ce35c0247cb300d51076ad8003699","key":"11","value":["60.11:006","Under","Earth layer","60.11:005"]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stratifier = new Stratifier() | |
stratigraphy_data = undefined | |
stratigraphy_data = stratifier.condense_relations(tributary.data) | |
loci = [] | |
for locus, locus_type of stratigraphy_data.loci | |
loci.push locus | |
display = d3.select("#display") | |
svg = display.append("svg") | |
tree = d3.layout.tree() | |
.size([400,400]) | |
for locus, index in loci | |
text = svg.append("text") | |
.attr("x",10) | |
.attr("y",10 * index * 5) | |
.attr("dy","1em") | |
.attr("text-anchor","left") | |
.style("font", "300 30px Helvetica Neue") | |
.text(locus) | |
bbox = text.node().getBBox() | |
rect = svg.append("rect") | |
.attr("x",bbox.x) | |
.attr("y",bbox.y) | |
.attr("width",bbox.width) | |
.attr("height",bbox.height) | |
.style("fill","#ccc") | |
.style("fill-opacity",".3") | |
.style("stroke", "#666") | |
.style("stroke-width", "1.5px") | |
svg.selectAll("rect").data(stratigraphy_data.loci, (d) -> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Stratifier = class Stratifier | |
# @RELATED_HOW: ["Abuts", "Abutted by", "Bonded to", "Contiguous to", "Cut by", "Cuts", "Equals", "Fill Loci", "FT", "Over", "Sealed agnst by", "Seals against", "Under"] | |
# related_type = ["Bedrock", "Cistern", "Earth layer", "FT", "Other", "Pit", "Surface", "Wall", "Installation"] | |
OPPOSITES: {"Abuts": "Abutted by", "Abutted by": "Abuts", "Bonded to": "Bonded to", "Cut by": "Cuts", "Cuts": "Cut by", "Equals": "Equals", "Over": "Under", "Under": "Over", "Sealed agnst by": "Seals against", "Seals against": "Sealed agnst by", "Contiguous to": "Contiguous to"} | |
onlyUnique = (value, index, self) -> | |
self.indexOf(value) is index | |
condense_relations: (data) -> | |
restructured_hash = { } | |
stratigraphy_type_hash = { } | |
temp_loci = [ ] | |
loci = { } | |
sorted_data = data.sort (a, b) -> | |
(if (a.value[0] > b.value[0]) then 1 else ((if (b.value[0] > a.value[0]) then -1 else 0))) | |
for row in sorted_data | |
temp_loci.push row.value[0] | |
temp_loci.push row.value[3] | |
related_hash = {"related_how": row.value[1], "related_type": row.value[2]} | |
stratigraphy_type_hash[row.value[3]] = row.value[2] | |
unless restructured_hash[row.value[3]]?.related_loci[row.value[0]]?.related_how == @OPPOSITES[row.value[1]] | |
if restructured_hash[row.value[0]] | |
restructured_hash[row.value[0]].related_loci[row.value[3]] = related_hash | |
else | |
restructured_hash[row.value[0]] = {} | |
restructured_hash[row.value[0]].related_loci = {} | |
restructured_hash[row.value[0]].related_loci[row.value[3]] = related_hash | |
for locus in temp_loci.filter( onlyUnique ).sort() | |
loci[locus] = stratigraphy_type_hash[locus] | |
return {"stratigraphy": restructured_hash, "loci": loci} | |
sanitize: (locus_id) -> | |
locus_id.replace(/\D/g,"-") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment