Built with blockbuilder.org
sunburst of leaflet.extras
in preparation for CRAN release
license: mit |
Built with blockbuilder.org
sunburst of leaflet.extras
in preparation for CRAN release
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="data:application/x-javascript;base64,KGZ1bmN0aW9uKCkgewogIC8vIElmIHdpbmRvdy5IVE1MV2lkZ2V0cyBpcyBhbHJlYWR5IGRlZmluZWQsIHRoZW4gdXNlIGl0OyBvdGhlcndpc2UgY3JlYXRlIGEKICAvLyBuZXcgb2JqZWN0LiBUaGlzIGFsbG93cyBwcmVjZWRpbmcgY29kZSB0byBzZXQgb3B0aW9ucyB0aGF0IGFmZmVjdCB0aGUKICAvLyBpbml0aWFsaXphdGlvbiBwcm9jZXNzICh0aG91Z2ggbm9uZSBjdXJyZW50bHkgZXhpc3QpLgogIHdpbmRvdy5IVE1MV2lkZ2V0cyA9IHdpbmRvdy5IVE1MV2lkZ2V0cyB8fCB7fTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gYSB2aWV3ZXIgcGFuZS4gSWYgbm90LCB3ZSdyZSBpbiBhIHdlYiBicm93c2VyLgogIHZhciB2aWV3ZXJNb2RlID0gd2luZG93LkhUTUxXaWRnZXRzLnZpZXdlck1vZGUgPQogICAgICAvXGJ2aWV3ZXJfcGFuZT0xXGIvLnRlc3Qod2luZG93LmxvY2F0aW9uKTsKCiAgLy8gU2VlIGlmIHdlJ3JlIHJ1bm5pbmcgaW4gU2hpbnkgbW9kZS4gSWYgbm90LCBpdCdzIGEgc3RhdGljIGRvY3VtZW50LgogIC8vIE5vdGUgdGhhdCBzdGF0aWMgd2lkZ2V0cyBjYW4gYXBwZWFyIGluIGJvdGggU2hpbnkgYW5kIHN0YXRpYyBtb2RlcywgYnV0CiAgLy8gb2J2aW91c2x5LCBTaGlueSB3aWRnZXRzIGNhbiBvbmx5IGFwcGVhciBpbiBTaGlueSBhcHBzL2RvY3VtZW50cy4KICB2YXIgc2hpbnl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W9mKHRhc2tGdW5jKSAhPT0gImZ1bmN0aW9uIikgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUYXNrIG11c3QgYmUgYSBmdW5jdGlvbiEgU291cmNlOlxuIiArIHRhc2spOwogICAgICAgIH0KICAgICAgICB0YXNrRnVuYy5hcHBseSh0YXJnZXQsIHRoZXNlQXJncyk7CiAgICAgIH0pOwogICAgfQogIH0KCiAgZnVuY3Rpb24gaW5pdFNpemluZyhlbCkgewogICAgdmFyIHNpemluZyA9IHNpemluZ1BvbGljeShlbCk7CiAgICBpZiAoIXNpemluZykKICAgICAgcmV0dXJuOwoKICAgIHZhciBjZWwgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiaHRtbHdpZGdldF9jb250YWluZXIiKTsKICAgIGlmICghY2VsKQogICAgICByZXR1cm47CgogICAgaWYgKHR5cGVvZihzaXppbmcucGFkZGluZykgIT09ICJ1bmRlZmluZWQiKSB7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUubWFyZ2luID0gIjAiOwogICAgICBkb2N1bWVudC5ib2R5LnN0eWxlLnBhZGRpbmcgPSBwYWRkaW5nVG9Dc3ModW5wYWNrUGFkZGluZyhzaXppbmcucGFkZGluZykpOwogICAgfQoKICAgIGlmIChzaXppbmcuZmlsbCkgewogICAgICBkb2N1bWVudC5ib2R5LnN0eWxlLm92ZXJmbG93ID0gImhpZGRlbiI7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUud2lkdGggPSAiMTAwJSI7CiAgICAgIGRvY3VtZW50LmJvZHkuc3R5bGUuaGVpZ2h0ID0gIjEwMCUiOwogICAgICBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuc3R5bGUud2lkdGggPSAiMTAwJSI7CiAgICAgIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5zdHlsZS5oZWlnaHQgPSAiMTAwJSI7CiAgICAgIGlmIChjZWwpIHsKICAgICAgICBjZWwuc3R5bGUucG9zaXRpb24gPSAiY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gICAgICAgLmNzcygibWF4V2lkdGgiLCBlbC5vZmZzZXRXaWR0aCkKICAgICAgICAgICAgLmNzcygiaGVpZ2h0IiwgZWwub2Zmc2V0SGVpZ2h0KTsKICAgICAgICAgIGVycm9yRGl2LnRleHQoZXJyLm1lc3NhZ2UpOwogICAgICAgICAgJGVsLmFmdGVyKGVycm9yRGl2KTsKCiAgICAgICAgICAvLyBSZWFsbHkgZHVtYiB3YXkgdG8ga2VlcCB0aGUgc2l6ZS9wb3NpdGlvbiBvZiB0aGUgZXJyb3IgaW4gc3luYyB3aXRoCiAgICAgICAgICAvLyB0aGUgcGFyZW50IGVsZW1lbnQgYXMgdGhlIHdpbmRvdyBpcyByZXNpemVkIG9yIHdoYXRldmVyLgogICAgICAgICAgdmFyIGludElkID0gc2V0SW50ZXJ2YWwoZnVuY3Rpb24oKSB7CiAgICAgICAgICAgIGlmICghZXJyb3JEaXZbMF0ucGFyZW50RWxlbWVudCkgewogICAgICAgICAgICAgIGNsZWFySW50ZXJ2YWwoaW50SWQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBlcnJvckRpdgogICAgICAgICAgICAgIC5jc3MoInRvcCIsIGVsLm9mZnNldFRvcCkKICAgICAgICAgICAgICAuY3NzKCJsZWZ0IiwgZWwub2Zmc2V0TGVmdCkKICAgICAgICAgICAgICAuY3NzKCJtYXhXaWR0aCIsIGVsLm9mZnNldFdpZHRoKQogICAgICAgICAgICAgIC5jc3MoImhlaWdodCIsIGVsLm9mZnNldEhlaWdodCk7CiAgICAgICAgICB9LCA1MDApOwogICAgICAgIH0KICAgICAgfQogICAgfSwKICAgIGNsZWFyRXJyb3I6IGZ1bmN0aW9uKGVsKSB7CiAgICAgIHZhciAkZWwgPSAkKGVsKTsKICAgICAgdmFyIGRpc3BsYXkgPSAkZWwuZGF0YSgicmVzdG9yZS1kaXNwbGF5LW1vZGUiKTsKICAgICAgJGVsLmRhdGEoInJlc3RvcmUtZGlzcGxhe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IGkrKykgewogICAgICAgICAgd2luZG93LkhUTUxXaWRnZXRzLmV2YWx1YXRlU3RyaW5nTWVtYmVyKGRhdGEueCwgZGF0YS5ldmFsc1tpXSk7CiAgICAgICAgfQogICAgICAgIGlmICghYmluZGluZ0RlZi5yZW5kZXJPbk51bGxWYWx1ZSkgewogICAgICAgICAgaWYgKGRhdGEueCA9PT0gbnVsbCkgewogICAgICAgICAgICBlbC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGVsLnN0eWxlLnZpc2liaWxpdHkgPSAiaW5oZXJpdCI7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghZWxlbWVudERhdGEoZWwsICJpbml0aWFsaXplZCIpKSB7CiAgICAgICAgICBpbml0U2l6aW5nKGVsKTsKCiAgICAgICAgICBlbGVtZW50RGF0YShlbCwgImluaXRpYWxpemVkIiwgdHJ1ZSk7CiAgICAgICAgICBpZiAoYmluZGluZ0RlZi5pbml0aWFsaXplKSB7CiAgICAgICAgICAgIHZhciByZXN1bHQgPSBiaW5kaW5nRGVmLmluaXRpYWxpemUoZWwsIGVsLm9mZnNldFdpZHRoLAogICAgICAgICAgICAgIGVsLm9mZnNldEhlaWdodCk7CiAgICAgICAgICAgIGVsZW1lbnREYXRhKGVsLCAiaW5pdF9yZXN1bHQiLCByZXN1bHQpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBTaGlueS5yZW5kZXJEZXBlbmRlbmNpZXMoZGF0YS5kZXBzKTsKICAgICAgICBiaW5kaW5nRGVmLnJlbmRlclZhbHVlKGVsLCBkYXRhLngsIGVsZW1lbnREYXRhKGVsLCAiaW5pdF9yZXN1bHQiKSk7CiAgICAgICAgZXZhbEFuZFJ1bihkYXRhLmpzSG9va3MucmVuZGVyLCBlbGVtZW50RGF0YShlbCwgImluaXRfcmVzdWx0IiksIFtlbCwgZGF0YS54X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IGluaXRSZXN1bHQpOwogICAgICAgIH0KCiAgICAgICAgaWYgKGJpbmRpbmcucmVzaXplKSB7CiAgICAgICAgICB2YXIgbGFzdFNpemUgPSB7fTsKICAgICAgICAgIHZhciByZXNpemVIYW5kbGVyID0gZnVuY3Rpb24oZSkgewogICAgICAgICAgICB2YXIgc2l6ZSA9IHsKICAgICAgICAgICAgICB3OiBzaXplT2JqID8gc2l6ZU9iai5nZXRXaWR0aCgpIDogZWwub2Zmc2V0V2lkdGgsCiAgICAgICAgICAgICAgaDogc2l6ZU9iaiA/IHNpemVPYmouZ2V0SGVpZ2h0KCkgOiBlbC5vZmZzZXRIZWlnaHQKICAgICAgICAgICAgfTsKICAgICAgICAgICAgaWYgKHNpemUudyA9PT0gMCAmJiBzaXplLmggPT09IDApCiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICBpZiAoc2l6ZS53ID09PSBsYXN0U2l6ZS53ICYmIHNpemUuaCA9PT0gbGFzdFNpemUuaCkKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIGxhc3RTaXplID0gc2l6ZTsKICAgICAgICAgICAgYmluZGluZy5yZXNpemUoZWwsIHNpemUudywgc2l6ZS5oLCBpbml0UmVzdWx0KTsKICAgICAgICAgIH07CgogICAgICAgICAgb24od2luZG93LCAicmVzaXplIiwgcmVzaXplSGFuZGxlcik7CgogICAgICAgICAgLy8gVGhpcyBpcyBuZWVkZWQgZm9yIGNhc2VzIHdoZXJlIHdlJ3JlIHJ1bm5pbmcgaW4gYSBTaGlueQogICAgICAgICAgLy8gYXBwLCBidXQgdGhlIHdpZGdldCBpdHNlbGYgaXMgbm90IGEgU2hpbnkgb3V0cHV0LCBidXQKICAgICAgICAgIC8vIHJhdGhlciBhIHNpbXBsZSBzdGF0aWMgd2lkZ2V0LiBPbmUgZXhhbXBsZSBvZiB0aGlzIGlzCiAgICAgICAgICAvLyBhbiBybWFya2Rvd24gZG9jdW1lbnQgdGhhdCBoYXMgcnVudGltZTpz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0b3J5KGVsLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgfSwKICAgICAgcmVuZGVyVmFsdWU6IGZ1bmN0aW9uKGVsLCB4LCBpbnN0YW5jZSkgewogICAgICAgIHJldHVybiBpbnN0YW5jZS5yZW5kZXJWYWx1ZSh4KTsKICAgICAgfSwKICAgICAgcmVzaXplOiBmdW5jdGlvbihlbCwgd2lkdGgsIGhlaWdodCwgaW5zdGFuY2UpIHsKICAgICAgICByZXR1cm4gaW5zdGFuY2UucmVzaXplKHdpZHRoLCBoZWlnaHQpOwogICAgICB9CiAgICB9OwoKICAgIGlmIChkZWZuLmZpbmQpCiAgICAgIHJlc3VsdC5maW5kID0gZGVmbi5maW5kOwogICAgaWYgKGRlZm4ucmVuZGVyRXJyb3IpCiAgICAgIHJlc3VsdC5yZW5kZXJFcnJvciA9IGRlZm4ucmVuZGVyRXJyb3I7CiAgICBpZiAoZGVmbi5jbGVhckVycm9yKQogICAgICByZXN1bHQuY2xlYXJFcnJvciA9IGRlZm4uY2xlYXJFcnJvcjsKCiAgICByZXR1cm4gcmVzdWx0OwogIH0KfSkoKTsKCg=="></script> | |
<link href="data:text/css;charset=utf-8,%2Esunburst%2Dmain%20%7B%0Awidth%3A%2090%25%3B%0Aheight%3A%20100%25%3B%0A%7D%0A%2Esunburst%2Dsidebar%20%7B%0Aposition%3A%20absolute%3B%0Aright%3A%2010px%3B%0Atop%3A%2010px%3B%0A%7D%0A%2Esunburst%2Dsequence%20%7B%0Awidth%3A%20100%25%3B%0Aposition%3A%20absolute%3B%0Atop%3A%200px%3B%0Aleft%3A%200px%3B%0Apointer%2Devents%3A%20none%3B%0A%7D%0A%2Esunburst%2Dlegend%20%7B%0Apadding%3A%2010px%200%200%203px%3B%0A%7D%0A%2Esunburst%2Dchart%20%7B%0Awidth%3A%20100%25%3B%0Aheight%3A%20100%25%3B%0Aposition%3A%20absolute%3B%0Atop%3A%2070px%3B%0A%7D%0A%2Esunburst%2Dchart%20path%20%7B%0Astroke%3A%20%23fff%3B%0A%7D%0A%2Esunburst%2Dexplanation%20%7B%0Aposition%3A%20absolute%3B%0Atext%2Dalign%3A%20center%3B%0Acolor%3A%20%23666%3B%0Az%2Dindex%3A%20999%3B%0Afont%2Dsize%3A%202em%3B%0Apointer%2Devents%3A%20none%3B%0A%7D%0A" rel="stylesheet" /> | |
<script src="data:application/x-javascript;base64,KGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT0iZnVuY3Rpb24iJiZyZXF1aXJlO2lmKCF1JiZhKXJldHVybiBhKG8sITApO2lmKGkpcmV0dXJuIGkobywhMCk7dmFyIGY9bmV3IEVycm9yKCJDYW5ub3QgZmluZCBtb2R1bGUgJyIrbysiJyIpO3Rocm93IGYuY29kZT0iTU9EVUxFX05PVF9GT1VORCIsZn12YXIgbD1uW29dPXtleHBvcnRzOnt9fTt0W29dWzBdLmNhbGwobC5leHBvcnRzLGZ1bmN0aW9uKGUpe3ZhciBuPXRbb11bMV1bZV07cmV0dXJuIHMobj9uOmUpfSxsLGwuZXhwb3J0cyxlLHQsbixyKX1yZXR1cm4gbltvXS5leHBvcnRzfXZhciBpPXR5cGVvZiByZXF1aXJlPT0iZnVuY3Rpb24iJiZyZXF1aXJlO2Zvcih2YXIgbz0wO288ci5sZW5ndGg7bysrKXMocltvXSk7cmV0dXJuIHN9KSh7MTpbZnVuY3Rpb24ocmVxdWlyZSxtb2R1bGUsZXhwb3J0cyl7DQooZnVuY3Rpb24gKGdsb2JhbCwgZmFjdG9yeSkgew0KCXR5cGVvZiBleHBvcnRzID09PSAnb2JqZWN0JyAmJiB0eXBlb2YgbW9kdWxlICE9PSAndW5kZWZpbmVkJyA/IGZhY3RvcnkocmVxdWlyZSgnZDMtZGlzcGF0Y2gnKSwgcmVxdWlyZSgnZDMtYXJyYXknKSwgcmVxdWlyZSgnZDMtZm9ybWF0JyksIHJlcXV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XN0YXJ0IGNvdW50ZXINCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGJlbmQuZGF0dW0oew0KICAgICAgICAgICAgICAiYnJlYWRjcnVtYl94IjogY3Vycl9icmVhZGNydW1iX3gsDQogICAgICAgICAgICAgICJicmVhZGNydW1iX2giOiBjdXJyX2JyZWFkY3J1bWJfaA0KICAgICAgICAgICAgfSk7DQogICAgICAgICAgICByZXR1cm4gY3Vycl9icmVhZGNydW1iX3g7DQogICAgICAgICAgfSkNCiAgICAgICAgICAuYXR0cigieSIsIGZ1bmN0aW9uKGQpe3JldHVybiBkLmJyZWFkY3J1bWJfaH0pDQogICAgICAgICAgLmF0dHIoImR5IiwgIjAuMzVlbSIpDQogICAgICAgICAgLmF0dHIoInRleHQtYW5jaG9yIiwgInN0YXJ0IikNCiAgICAgICAgICAudGV4dChwZXJjZW50YWdlU3RyaW5nKTsNCg0KDQogICAgfSBlbHNlIHsNCiAgICAgIGVudGVyaW5nLmFwcGVuZCgicG9seWdvbiIpDQogICAgICAgICAgLmF0dHIoInBvaW50cyIsIGJyZWFkY3J1bWJQb2ludHMpDQogICAgICAgICAgLnN0eWxlKCJmaWxsIiwgZnVuY3Rpb24oZCkgeyByZXR1cm4gY29sb3JzLmNhbGwodGhpcywgZC5kYXRhLm5hbWUpOyB9KTsNCg0KICAgICAgZW50ZXJpbmcuYXBwZW5kKCJ0ZXh0IikNCiAgICAgICAgICAuYXR0cigieCIsIChiLncgKyBiLnQpIC8gMikNCiAgICAgICAgICAuYXR0cigieSIsIGIuaCAvIDIpDQogICAgICAgICAgLmF0dHIoImR5IiwgIjAuMzVlbSIpDQogICAgICAgICAgLmF0dHIoInRleHQtYW5jaG9yIiwgIm1pZGRsZSIpDQogICAgICAgICAgLnRleHQoZnVuY3Rpb24oZCkgeyByZXR1cm4gZC5kYXRhLm5hbWU7IH0pOw0KDQogICAgICAvLyBTZXQgcG9zaXRpb24gZm9yIGVudGVyaW5nIGFuZCB1cGRhdGluZyBub2Rl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vb3Q7DQoNCiAgICB9DQoNCiAgICByZXR1cm4gew0KDQogICAgICByZW5kZXJWYWx1ZTogZnVuY3Rpb24oeCkgew0KDQogICAgICAgIGluc3RhbmNlLnggPSB4Ow0KDQogICAgICAgIC8vIHguZGF0YSBzaG91bGQgYmUgYSBkYXRhLmZyYW1lIGluIFIgc28gYW4gSmF2YXNjcmlwdCBPYmplY3Qgb2YgT2JqZWN0cw0KICAgICAgICAvLyAgICAgYnV0IGJ1aWxkSGllcmFyY2h5IGV4cGVjdHMgYW4gQXJyYXkgb2YgQXJyYXlzDQogICAgICAgIC8vICAgICBzbyB1c2UgZDMuemlwIGFuZCBhcHBseSB0byBkbyB0aGlzDQogICAgICAgIHZhciBqc29uID0gW107DQogICAgICAgIGlmKHR5cGVvZih4LmNzdmRhdGEpICE9PSAidW5kZWZpbmVkIil7DQogICAgICAgICAganNvbiA9IGJ1aWxkSGllcmFyY2h5KA0KICAgICAgICAgICAgZDNBcnJheS56aXAuYXBwbHkoDQogICAgICAgICAgICAgIG51bGwsDQogICAgICAgICAgICAgIE9iamVjdC5rZXlzKHguY3N2ZGF0YSkubWFwKGZ1bmN0aW9uKGt5KXtyZXR1cm4geC5jc3ZkYXRhW2t5XX0pDQogICAgICAgICAgICApDQogICAgICAgICAgKTsNCiAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICBqc29uID0geC5kYXRhOw0KICAgICAgICB9DQogICAgICAgIGluc3RhbmNlLmpzb24gPSBqc29uOw0KDQogICAgICAgIGRyYXcoZWwsIGluc3RhbmNlLCBkaXNwYXRjaF8pOw0KDQogICAgICB9LA0KDQogICAgICByZXNpemU6IGZ1bmN0aW9uKHdpZHRoLCBoZWlnaHQpIHsNCg0KICAgICAgICBkcmF3KGVsLCBpbnN0YW5jZSwgZGlzcGF0Y2hfKTsNCg0KICAgICAgfSwNCg0KICAgICAgaW5zdGFuY2U6IGluc3RhbmNlDQoNCiAgICB9Ow0KICB9DQp9KTsNCg0KfSkpKTsNCg0KfSx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IGksDQogICAgICAgIG4gPSBkYXRhLmxlbmd0aCwNCiAgICAgICAgeCwNCiAgICAgICAgdmFsdWVzID0gbmV3IEFycmF5KG4pOw0KDQogICAgZm9yIChpID0gMDsgaSA8IG47ICsraSkgew0KICAgICAgdmFsdWVzW2ldID0gdmFsdWUoZGF0YVtpXSwgaSwgZGF0YSk7DQogICAgfQ0KDQogICAgdmFyIHh6ID0gZG9tYWluKHZhbHVlcyksDQogICAgICAgIHgwID0geHpbMF0sDQogICAgICAgIHgxID0geHpbMV0sDQogICAgICAgIHR6ID0gdGhyZXNob2xkKHZhbHVlcywgeDAsIHgxKTsNCg0KICAgIC8vIENvbnZlcnQgbnVtYmVyIG9mIHRocmVzaG9sZHMgaW50byB1bmlmb3JtIHRocmVzaG9sZHMuDQogICAgaWYgKCFBcnJheS5pc0FycmF5KHR6KSkgew0KICAgICAgdHogPSB0aWNrU3RlcCh4MCwgeDEsIHR6KTsNCiAgICAgIHR6ID0gcmFuZ2UoTWF0aC5jZWlsKHgwIC8gdHopICogdHosIE1hdGguZmxvb3IoeDEgLyB0eikgKiB0eiwgdHopOyAvLyBleGNsdXNpdmUNCiAgICB9DQoNCiAgICAvLyBSZW1vdmUgYW55IHRocmVzaG9sZHMgb3V0c2lkZSB0aGUgZG9tYWluLg0KICAgIHZhciBtID0gdHoubGVuZ3RoOw0KICAgIHdoaWxlICh0elswXSA8PSB4MCkgdHouc2hpZnQoKSwgLS1tOw0KICAgIHdoaWxlICh0elttIC0gMV0gPiB4MSkgdHoucG9wKCksIC0tbTsNCg0KICAgIHZhciBiaW5zID0gbmV3IEFycmF5KG0gKyAxKSwNCiAgICAgICAgYmluOw0KDQogICAgLy8gSW5pdGlhbGl6ZSBiaW5zLg0KICAgIGZvciAoaSA9IDA7IGkgPD0gbTsgKytpKSB7DQogICAgICBiaW4gPSBiaW5zW2ldID0gW107DQogICAgICBiaW4ueDAgPSBpID4gMCA/IHR6W2kgLSAxXSA6IHgwOw0KICAgICAgYmluLngxID0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geDIgPSBiLngsIHkyID0gYi55LCByMiA9IGIuciwNCiAgICAgIHgyMSA9IHgyIC0geDEsIHkyMSA9IHkyIC0geTEsIHIyMSA9IHIyIC0gcjEsDQogICAgICBsID0gTWF0aC5zcXJ0KHgyMSAqIHgyMSArIHkyMSAqIHkyMSk7DQogIHJldHVybiB7DQogICAgeDogKHgxICsgeDIgKyB4MjEgLyBsICogcjIxKSAvIDIsDQogICAgeTogKHkxICsgeTIgKyB5MjEgLyBsICogcjIxKSAvIDIsDQogICAgcjogKGwgKyByMSArIHIyKSAvIDINCiAgfTsNCn0NCg0KZnVuY3Rpb24gZW5jbG9zZUJhc2lzMyhhLCBiLCBjKSB7DQogIHZhciB4MSA9IGEueCwgeTEgPSBhLnksIHIxID0gYS5yLA0KICAgICAgeDIgPSBiLngsIHkyID0gYi55LCByMiA9IGIuciwNCiAgICAgIHgzID0gYy54LCB5MyA9IGMueSwgcjMgPSBjLnIsDQogICAgICBhMiA9IHgxIC0geDIsDQogICAgICBhMyA9IHgxIC0geDMsDQogICAgICBiMiA9IHkxIC0geTIsDQogICAgICBiMyA9IHkxIC0geTMsDQogICAgICBjMiA9IHIyIC0gcjEsDQogICAgICBjMyA9IHIzIC0gcjEsDQogICAgICBkMSA9IHgxICogeDEgKyB5MSAqIHkxIC0gcjEgKiByMSwNCiAgICAgIGQyID0gZDEgLSB4MiAqIHgyIC0geTIgKiB5MiArIHIyICogcjIsDQogICAgICBkMyA9IGQxIC0geDMgKiB4MyAtIHkzICogeTMgKyByMyAqIHIzLA0KICAgICAgYWIgPSBhMyAqIGIyIC0gYTIgKiBiMywNCiAgICAgIHhhID0gKGIyICogZDMgLSBiMyAqIGQyKSAvIChhYiAqIDIpIC0geDEsDQogICAgICB4YiA9IChiMyAqIGMyIC0gYjIgKiBjMykgLyBhYiwNCiAgICAgIHlhID0gKGEzICogZDIgLSBhMiAqIGQzKSAvIChhYiAqIDIpIC0geTEsDQogICAgICB5YiA9IChhMiAqIGMzIC0gYTMgKiBjMikgLyBhYiwNCiAgICAgIEEgPSB4YiAqIHhiICsgeWIgKiB5YiAtIDEsDQogICAgICBCID0gMiAqIChyMSArIHhhICogeGIgKyB5YSAqIHliKSwNCiAgICAgIEMgPSB4YSAqIHhhICsgeWEgKiB5YSAtIHIxICogcjEsDQogICAgICByID0gLShBID8gKEIgKyBNYXRoLnNxcnQoQiAqIEIgLSA0ICogQSAqIEMpKSAvICgyICogQSkgOiBDIC8gQik7DQogIHJldHVybiB7DQogICAgeDogeDEgKyB4YSArIHhiICogciwNCiAgICB5OiB5MSArIHlhICsgeWIgKiByLA0KICAgIHI6IHINCiAgfTsNCn0NCg0KZnVuY3Rpb24gcGxhY2UoYSwgYiwgYykgew0KICB2YXIgYXggPSBhLngsDQogICAgICBheSA9IGEueSwNCiAgICAgIGRhID0gYi5yICsgYy5yLA0KICAgICAgZGIgPSBhLnIgKyBjLnIsDQogICAgICBkeCA9IGIueCAtIGF4LA0KICAgICAgZHkgPSBiLnkgLSBheSwNCiAgICAgIGRjID0gZHggKiBkeCArIGR5ICogZHk7DQogIGlmIChkYykgew0KICAgIHZhciB4ID0gMC41ICsgKChkYiAqPSBkYikgLSAoZGEgKj0gZGEpKSAvICgyICogZGMpLA0KICAgICAgICB5ID0gTWF0aC5zcXJ0KE1hdGgubWF4KDAsIDIgKiBkYSAqIChkYiArIGRjKSAtIChkYiAtPSBkYykgKiBkYiAtIGRhICogZGEpKSAvICgyICogZGMpOw0KICAgIGMueCA9IGF4ICsgeCAqIGR4ICsgeSAqIGR5Ow0KICAgIGMueSA9IGF5ICsgeCAqIGR5IC0geSAqIGR4Ow0KICB9IGVsc2Ugew0KICAgIGMueCA9IGF4ICsgZGI7DQogICAgYy55ID0gYXk7DQogIH0NCn0NCg0KZnVuY3Rpb24gaW50ZXJzZWN0cyhhLCBiKSB7DQogIHZhciBkeCA9IGIueCAtIGEueCwNCiAgICAgIGR5ID0gYi55IC0gYS55LA0KICAgICAgZHIgPSBhLnIgKyBiLnI7DQog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5vZGUsDQogICAgICBpID0gLTEsDQogICAgICBuID0gbm9kZXMubGVuZ3RoLA0KICAgICAgayA9IHBhcmVudC52YWx1ZSAmJiAoeDEgLSB4MCkgLyBwYXJlbnQudmFsdWU7DQoNCiAgd2hpbGUgKCsraSA8IG4pIHsNCiAgICBub2RlID0gbm9kZXNbaV0sIG5vZGUueTAgPSB5MCwgbm9kZS55MSA9IHkxOw0KICAgIG5vZGUueDAgPSB4MCwgbm9kZS54MSA9IHgwICs9IG5vZGUudmFsdWUgKiBrOw0KICB9DQp9Ow0KDQp2YXIgcGFydGl0aW9uID0gZnVuY3Rpb24oKSB7DQogIHZhciBkeCA9IDEsDQogICAgICBkeSA9IDEsDQogICAgICBwYWRkaW5nID0gMCwNCiAgICAgIHJvdW5kID0gZmFsc2U7DQoNCiAgZnVuY3Rpb24gcGFydGl0aW9uKHJvb3QpIHsNCiAgICB2YXIgbiA9IHJvb3QuaGVpZ2h0ICsgMTsNCiAgICByb290LngwID0NCiAgICByb290LnkwID0gcGFkZGluZzsNCiAgICByb290LngxID0gZHg7DQogICAgcm9vdC55MSA9IGR5IC8gbjsNCiAgICByb290LmVhY2hCZWZvcmUocG9zaXRpb25Ob2RlKGR5LCBuKSk7DQogICAgaWYgKHJvdW5kKSByb290LmVhY2hCZWZvcmUocm91bmROb2RlKTsNCiAgICByZXR1cm4gcm9vdDsNCiAgfQ0KDQogIGZ1bmN0aW9uIHBvc2l0aW9uTm9kZShkeSwgbikgew0KICAgIHJldHVybiBmdW5jdGlvbihub2RlKSB7DQogICAgICBpZiAobm9kZS5jaGlsZHJlbikgew0KICAgICAgICB0cmVlbWFwRGljZShub2RlLCBub2RlLngwLCBkeSAqIChub2RlLmRlcHRoICsgMSkgLyBuLCBub2RlLngxLCBkeSAqIChub2RlLmRlcHRoICsgMikgLyBuKTsNCiAgICAgIH0NCiAgICAgIHZhciB4MCA9IG5vZGUueDAsDQogICAgICAgICAgeTAgPSBub2RlLnkwLA0KICAgICAgICAgIHgxID0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YXIgaWQgPSBkZWZhdWx0SWQsDQogICAgICBwYXJlbnRJZCA9IGRlZmF1bHRQYXJlbnRJZDsNCg0KICBmdW5jdGlvbiBzdHJhdGlmeShkYXRhKSB7DQogICAgdmFyIGQsDQogICAgICAgIGksDQogICAgICAgIG4gPSBkYXRhLmxlbmd0aCwNCiAgICAgICAgcm9vdCwNCiAgICAgICAgcGFyZW50LA0KICAgICAgICBub2RlLA0KICAgICAgICBub2RlcyA9IG5ldyBBcnJheShuKSwNCiAgICAgICAgbm9kZUlkLA0KICAgICAgICBub2RlS2V5LA0KICAgICAgICBub2RlQnlLZXkgPSB7fTsNCg0KICAgIGZvciAoaSA9IDA7IGkgPCBuOyArK2kpIHsNCiAgICAgIGQgPSBkYXRhW2ldLCBub2RlID0gbm9kZXNbaV0gPSBuZXcgTm9kZShkKTsNCiAgICAgIGlmICgobm9kZUlkID0gaWQoZCwgaSwgZGF0YSkpICE9IG51bGwgJiYgKG5vZGVJZCArPSAiIikpIHsNCiAgICAgICAgbm9kZUtleSA9IGtleVByZWZpeCArIChub2RlLmlkID0gbm9kZUlkKTsNCiAgICAgICAgbm9kZUJ5S2V5W25vZGVLZXldID0gbm9kZUtleSBpbiBub2RlQnlLZXkgPyBhbWJpZ3VvdXMgOiBub2RlOw0KICAgICAgfQ0KICAgIH0NCg0KICAgIGZvciAoaSA9IDA7IGkgPCBuOyArK2kpIHsNCiAgICAgIG5vZGUgPSBub2Rlc1tpXSwgbm9kZUlkID0gcGFyZW50SWQoZGF0YVtpXSwgaSwgZGF0YSk7DQogICAgICBpZiAobm9kZUlkID09IG51bGwgfHwgIShub2RlSWQgKz0gIiIpKSB7DQogICAgICAgIGlmIChyb290KSB0aHJvdyBuZXcgRXJyb3IoIm11bHRpcGxlIHJvb3RzIik7DQogICAgICAgIHJvb3QgPSBub2RlOw0KICAgICAgfSBlbHNlIHsNCiAgICAgICAgcGFyZW50ID0gbm9kZUJ5S2V5W2tleVByZWZpeCArIG5vZGVJZF07DQogICAg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ZXMuDQogIC8vIEZpbmFsbHksIHdlIGFkZCBhIG5ldyB0aHJlYWQgKGlmIG5lY2Vzc2FyeSkuDQogIGZ1bmN0aW9uIGFwcG9ydGlvbih2LCB3LCBhbmNlc3Rvcikgew0KICAgIGlmICh3KSB7DQogICAgICB2YXIgdmlwID0gdiwNCiAgICAgICAgICB2b3AgPSB2LA0KICAgICAgICAgIHZpbSA9IHcsDQogICAgICAgICAgdm9tID0gdmlwLnBhcmVudC5jaGlsZHJlblswXSwNCiAgICAgICAgICBzaXAgPSB2aXAubSwNCiAgICAgICAgICBzb3AgPSB2b3AubSwNCiAgICAgICAgICBzaW0gPSB2aW0ubSwNCiAgICAgICAgICBzb20gPSB2b20ubSwNCiAgICAgICAgICBzaGlmdDsNCiAgICAgIHdoaWxlICh2aW0gPSBuZXh0UmlnaHQodmltKSwgdmlwID0gbmV4dExlZnQodmlwKSwgdmltICYmIHZpcCkgew0KICAgICAgICB2b20gPSBuZXh0TGVmdCh2b20pOw0KICAgICAgICB2b3AgPSBuZXh0UmlnaHQodm9wKTsNCiAgICAgICAgdm9wLmEgPSB2Ow0KICAgICAgICBzaGlmdCA9IHZpbS56ICsgc2ltIC0gdmlwLnogLSBzaXAgKyBzZXBhcmF0aW9uKHZpbS5fLCB2aXAuXyk7DQogICAgICAgIGlmIChzaGlmdCA+IDApIHsNCiAgICAgICAgICBtb3ZlU3VidHJlZShuZXh0QW5jZXN0b3IodmltLCB2LCBhbmNlc3RvciksIHYsIHNoaWZ0KTsNCiAgICAgICAgICBzaXAgKz0gc2hpZnQ7DQogICAgICAgICAgc29wICs9IHNoaWZ0Ow0KICAgICAgICB9DQogICAgICAgIHNpbSArPSB2aW0ubTsNCiAgICAgICAgc2lwICs9IHZpcC5tOw0KICAgICAgICBzb20gKz0gdm9tLm07DQogICAgICAgIHNvcCArPSB2b3AubTsNCiAgICAgIH0NCiAgICAgIGlmICh2aW0gJiYgIW5leHRSaWdodCh2b3ApKSB7DQogICAgICAgIHZvcC50ID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CiAgICBpID0gZnVuY3Rpb24odCkgew0KICAgICAgcmV0dXJuIFsNCiAgICAgICAgdXgwICsgdCAqIGR4LA0KICAgICAgICB1eTAgKyB0ICogZHksDQogICAgICAgIHcwICogTWF0aC5leHAocmhvICogdCAqIFMpDQogICAgICBdOw0KICAgIH07DQogIH0NCg0KICAvLyBHZW5lcmFsIGNhc2UuDQogIGVsc2Ugew0KICAgIHZhciBkMSA9IE1hdGguc3FydChkMiksDQogICAgICAgIGIwID0gKHcxICogdzEgLSB3MCAqIHcwICsgcmhvNCAqIGQyKSAvICgyICogdzAgKiByaG8yICogZDEpLA0KICAgICAgICBiMSA9ICh3MSAqIHcxIC0gdzAgKiB3MCAtIHJobzQgKiBkMikgLyAoMiAqIHcxICogcmhvMiAqIGQxKSwNCiAgICAgICAgcjAgPSBNYXRoLmxvZyhNYXRoLnNxcnQoYjAgKiBiMCArIDEpIC0gYjApLA0KICAgICAgICByMSA9IE1hdGgubG9nKE1hdGguc3FydChiMSAqIGIxICsgMSkgLSBiMSk7DQogICAgUyA9IChyMSAtIHIwKSAvIHJobzsNCiAgICBpID0gZnVuY3Rpb24odCkgew0KICAgICAgdmFyIHMgPSB0ICogUywNCiAgICAgICAgICBjb3NocjAgPSBjb3NoKHIwKSwNCiAgICAgICAgICB1ID0gdzAgLyAocmhvMiAqIGQxKSAqIChjb3NocjAgKiB0YW5oKHJobyAqIHMgKyByMCkgLSBzaW5oKHIwKSk7DQogICAgICByZXR1cm4gWw0KICAgICAgICB1eDAgKyB1ICogZHgsDQogICAgICAgIHV5MCArIHUgKiBkeSwNCiAgICAgICAgdzAgKiBjb3NocjAgLyBjb3NoKHJobyAqIHMgKyByMCkNCiAgICAgIF07DQogICAgfTsNCiAgfQ0KDQogIGkuZHVyYXRpb24gPSBTICogMTAwMDsNCg0KICByZXR1cm4gaTsNCn07DQoNCmZ1bmN0aW9uIGhzbCQxKGh1ZSQkMSkgew0KICByZXR1cm4gZnVuY3Rpb24oc3RhcnQsIGVuZC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AgICBsMjFfMiA9IHgyMSAqIHgyMSArIHkyMSAqIHkyMSwNCiAgICAgICAgICBsMjBfMiA9IHgyMCAqIHgyMCArIHkyMCAqIHkyMCwNCiAgICAgICAgICBsMjEgPSBNYXRoLnNxcnQobDIxXzIpLA0KICAgICAgICAgIGwwMSA9IE1hdGguc3FydChsMDFfMiksDQogICAgICAgICAgbCA9IHIgKiBNYXRoLnRhbigocGkgLSBNYXRoLmFjb3MoKGwyMV8yICsgbDAxXzIgLSBsMjBfMikgLyAoMiAqIGwyMSAqIGwwMSkpKSAvIDIpLA0KICAgICAgICAgIHQwMSA9IGwgLyBsMDEsDQogICAgICAgICAgdDIxID0gbCAvIGwyMTsNCg0KICAgICAgLy8gSWYgdGhlIHN0YXJ0IHRhbmdlbnQgaXMgbm90IGNvaW5jaWRlbnQgd2l0aCAoeDAseTApLCBsaW5lIHRvLg0KICAgICAgaWYgKE1hdGguYWJzKHQwMSAtIDEpID4gZXBzaWxvbikgew0KICAgICAgICB0aGlzLl8gKz0gIkwiICsgKHgxICsgdDAxICogeDAxKSArICIsIiArICh5MSArIHQwMSAqIHkwMSk7DQogICAgICB9DQoNCiAgICAgIHRoaXMuXyArPSAiQSIgKyByICsgIiwiICsgciArICIsMCwwLCIgKyAoKyh5MDEgKiB4MjAgPiB4MDEgKiB5MjApKSArICIsIiArICh0aGlzLl94MSA9IHgxICsgdDIxICogeDIxKSArICIsIiArICh0aGlzLl95MSA9IHkxICsgdDIxICogeTIxKTsNCiAgICB9DQogIH0sDQogIGFyYzogZnVuY3Rpb24oeCwgeSwgciwgYTAsIGExLCBjY3cpIHsNCiAgICB4ID0gK3gsIHkgPSAreSwgciA9ICtyOw0KICAgIHZhciBkeCA9IHIgKiBNYXRoLmNvcyhhMCksDQogICAgICAgIGR5ID0gciAqIE1hdGguc2luKGEwKSwNCiAgICAgICAgeDAgPSB4ICsgZHgsDQogICAgICAgIHkwID0geSArIGR5LA0KICAgICAgICBjdyA9IDEgXiBjY3csDQogICAgIC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KFsxLCAxMF0pLA0KICAgICAgZG9tYWluID0gc2NhbGUuZG9tYWluLA0KICAgICAgYmFzZSA9IDEwLA0KICAgICAgbG9ncyA9IGxvZ3AoMTApLA0KICAgICAgcG93cyA9IHBvd3AoMTApOw0KDQogIGZ1bmN0aW9uIHJlc2NhbGUoKSB7DQogICAgbG9ncyA9IGxvZ3AoYmFzZSksIHBvd3MgPSBwb3dwKGJhc2UpOw0KICAgIGlmIChkb21haW4oKVswXSA8IDApIGxvZ3MgPSByZWZsZWN0KGxvZ3MpLCBwb3dzID0gcmVmbGVjdChwb3dzKTsNCiAgICByZXR1cm4gc2NhbGU7DQogIH0NCg0KICBzY2FsZS5iYXNlID0gZnVuY3Rpb24oXykgew0KICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKGJhc2UgPSArXywgcmVzY2FsZSgpKSA6IGJhc2U7DQogIH07DQoNCiAgc2NhbGUuZG9tYWluID0gZnVuY3Rpb24oXykgew0KICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKGRvbWFpbihfKSwgcmVzY2FsZSgpKSA6IGRvbWFpbigpOw0KICB9Ow0KDQogIHNjYWxlLnRpY2tzID0gZnVuY3Rpb24oY291bnQpIHsNCiAgICB2YXIgZCA9IGRvbWFpbigpLA0KICAgICAgICB1ID0gZFswXSwNCiAgICAgICAgdiA9IGRbZC5sZW5ndGggLSAxXSwNCiAgICAgICAgcjsNCg0KICAgIGlmIChyID0gdiA8IHUpIGkgPSB1LCB1ID0gdiwgdiA9IGk7DQoNCiAgICB2YXIgaSA9IGxvZ3ModSksDQogICAgICAgIGogPSBsb2dzKHYpLA0KICAgICAgICBwLA0KICAgICAgICBrLA0KICAgICAgICB0LA0KICAgICAgICBuID0gY291bnQgPT0gbnVsbCA/IDEwIDogK2NvdW50LA0KICAgICAgICB6ID0gW107DQoNCiAgICBpZiAoIShiYXNlICUgMSkgJiYgaiAtIGkgPCBuKSB7DQogICAgICBpID0gTWF0aC5yb3VuZChpKSAtIDEsIGogPSBNYXRoLnJvdW5kKGopICsgMTsNCiAgICAgIGlmICh1ID4gMCkgZm9yICg7IGkgPCBqOyArK2kpIHsNCiAgICAgICAgZm9yIChrID0gMSwgcCA9IHBvd3MoaSk7IGsgPCBiYXNlOyArK2spIHsNCiAgICAgICAgICB0ID0gcCAqIGs7DQogICAgICAgICAgaWYgKHQgPCB1KSBjb250aW51ZTsNCiAgICAgICAgICBpZiAodCA+IHYpIGJyZWFrOw0KICAgICAgICAgIHoucHVzaCh0KTsNCiAgICAgICAgfQ0KICAgICAgfSBlbHNlIGZvciAoOyBpIDwgajsgKytpKSB7DQogICAgICAgIGZvciAoayA9IGJhc2UgLSAxLCBwID0gcG93cyhpKTsgayA+PSAxOyAtLWspIHsNCiAgICAgICAgICB0ID0gcCAqIGs7DQogICAgICAgICAgaWYgKHQgPCB1KSBjb250aW51ZTsNCiAgICAgICAgICBpZiAodCA+IHYpIGJyZWFrOw0KICAgICAgICAgIHoucHVzaCh0KTsNCiAgICAgICAgfQ0KICAgICAgfQ0KICAgIH0gZWxzZSB7DQogICAgICB6ID0gZDNBcnJheS50aWNrcyhpLCBqLCBNYXRoLm1pbihqIC0gaSwgbikpLm1hcChwb3dzKTsNCiAgICB9DQoNCiAgICByZXR1cm4gciA/IHoucmV2ZXJzZSgpIDogejsNCiAgfTsNCg0KICBzY2FsZS50aWNrRm9ybWF0ID0gZnVuY3Rpb24oY291bnQsIHNwZWNpZmllcikgew0KICAgIGlmIChzcGVjaWZpZXIgPT0gbnVsbCkgc3BlY2lmaWVyID0gYmFzZSA9PT0gMTAgPyAiLjBlIiA6ICIsIjsNCiAgICBpZiAodHlwZW9mIHNwZWNpZmllciAhPT0gImZ1bmN0aW9uIikgc3BlY2lmaWVyID0gZDNGb3JtYXQuZm9ybWF0KHNwZWNpZmllcik7DQogICAgaWYgKGNvdW50ID09PSBJbmZpbml0eSkgcmV0dXJuIHNwZWNpZmllcjsNCiAgICBpZiAoY291bnQgPT0gbnVsbCkgY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BhMSwNCiAgICAgICAgICBkYTAgPSBkYSwNCiAgICAgICAgICBkYTEgPSBkYSwNCiAgICAgICAgICBhcCA9IHBhZEFuZ2xlLmFwcGx5KHRoaXMsIGFyZ3VtZW50cykgLyAyLA0KICAgICAgICAgIHJwID0gKGFwID4gZXBzaWxvbikgJiYgKHBhZFJhZGl1cyA/ICtwYWRSYWRpdXMuYXBwbHkodGhpcywgYXJndW1lbnRzKSA6IHNxcnQocjAgKiByMCArIHIxICogcjEpKSwNCiAgICAgICAgICByYyA9IG1pbihhYnMocjEgLSByMCkgLyAyLCArY29ybmVyUmFkaXVzLmFwcGx5KHRoaXMsIGFyZ3VtZW50cykpLA0KICAgICAgICAgIHJjMCA9IHJjLA0KICAgICAgICAgIHJjMSA9IHJjLA0KICAgICAgICAgIHQwLA0KICAgICAgICAgIHQxOw0KDQogICAgICAvLyBBcHBseSBwYWRkaW5nPyBOb3RlIHRoYXQgc2luY2UgcjEg4omlIHIwLCBkYTEg4omlIGRhMC4NCiAgICAgIGlmIChycCA+IGVwc2lsb24pIHsNCiAgICAgICAgdmFyIHAwID0gYXNpbihycCAvIHIwICogc2luKGFwKSksDQogICAgICAgICAgICBwMSA9IGFzaW4ocnAgLyByMSAqIHNpbihhcCkpOw0KICAgICAgICBpZiAoKGRhMCAtPSBwMCAqIDIpID4gZXBzaWxvbikgcDAgKj0gKGN3ID8gMSA6IC0xKSwgYTAwICs9IHAwLCBhMTAgLT0gcDA7DQogICAgICAgIGVsc2UgZGEwID0gMCwgYTAwID0gYTEwID0gKGEwICsgYTEpIC8gMjsNCiAgICAgICAgaWYgKChkYTEgLT0gcDEgKiAyKSA+IGVwc2lsb24pIHAxICo9IChjdyA/IDEgOiAtMSksIGEwMSArPSBwMSwgYTExIC09IHAxOw0KICAgICAgICBlbHNlIGRhMSA9IDAsIGEwMSA9IGExMSA9IChhMCArIGExKSAvIDI7DQogICAgICB9DQoNCiAgICAgIHZhciB4MDEgPSByMSAqIGNvcyhhMDEpLA0KICAgICAgICAgIHkwMSA9IHIxICogc2luKGEwMSksDQogICAgICAgICAgeDEwID0gcjAgKiBjb3MoYTEwKSwNCiAgICAgICAgICB5MTAgPSByMCAqIHNpbihhMTApOw0KDQogICAgICAvLyBBcHBseSByb3VuZGVkIGNvcm5lcnM/DQogICAgICBpZiAocmMgPiBlcHNpbG9uKSB7DQogICAgICAgIHZhciB4MTEgPSByMSAqIGNvcyhhMTEpLA0KICAgICAgICAgICAgeTExID0gcjEgKiBzaW4oYTExKSwNCiAgICAgICAgICAgIHgwMCA9IHIwICogY29zKGEwMCksDQogICAgICAgICAgICB5MDAgPSByMCAqIHNpbihhMDApOw0KDQogICAgICAgIC8vIFJlc3RyaWN0IHRoZSBjb3JuZXIgcmFkaXVzIGFjY29yZGluZyB0byB0aGUgc2VjdG9yIGFuZ2xlLg0KICAgICAgICBpZiAoZGEgPCBwaSkgew0KICAgICAgICAgIHZhciBvYyA9IGRhMCA+IGVwc2lsb24gPyBpbnRlcnNlY3QoeDAxLCB5MDEsIHgwMCwgeTAwLCB4MTEsIHkxMSwgeDEwLCB5MTApIDogW3gxMCwgeTEwXSwNCiAgICAgICAgICAgICAgYXggPSB4MDEgLSBvY1swXSwNCiAgICAgICAgICAgICAgYXkgPSB5MDEgLSBvY1sxXSwNCiAgICAgICAgICAgICAgYnggPSB4MTEgLSBvY1swXSwNCiAgICAgICAgICAgICAgYnkgPSB5MTEgLSBvY1sxXSwNCiAgICAgICAgICAgICAga2MgPSAxIC8gc2luKGFjb3MoKGF4ICogYnggKyBheSAqIGJ5KSAvIChzcXJ0KGF4ICogYXggKyBheSAqIGF5KSAqIHNxcnQoYnggKiBieCArIGJ5ICogYnkpKSkgLyAyKSwNCiAgICAgICAgICAgICAgbGMgPSBzcXJ0KG9jWzBdICogb2NbMF0gKyBvY1sxXSAqIG9jWzFdKTsNCiAgICAgICAgICByYzAgPSBtaW4ocmMsIChyMCAtIGxjKSAvIChrYyAtIDEpKTsNCiAgICAgICAgICByYzEgPSBta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ICAgaWYgKCEoaSA8IG4gJiYgZGVmaW5lZChkID0gZGF0YVtpXSwgaSwgZGF0YSkpID09PSBkZWZpbmVkMCkgew0KICAgICAgICBpZiAoZGVmaW5lZDAgPSAhZGVmaW5lZDApIHsNCiAgICAgICAgICBqID0gaTsNCiAgICAgICAgICBvdXRwdXQuYXJlYVN0YXJ0KCk7DQogICAgICAgICAgb3V0cHV0LmxpbmVTdGFydCgpOw0KICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgIG91dHB1dC5saW5lRW5kKCk7DQogICAgICAgICAgb3V0cHV0LmxpbmVTdGFydCgpOw0KICAgICAgICAgIGZvciAoayA9IGkgLSAxOyBrID49IGo7IC0taykgew0KICAgICAgICAgICAgb3V0cHV0LnBvaW50KHgweltrXSwgeTB6W2tdKTsNCiAgICAgICAgICB9DQogICAgICAgICAgb3V0cHV0LmxpbmVFbmQoKTsNCiAgICAgICAgICBvdXRwdXQuYXJlYUVuZCgpOw0KICAgICAgICB9DQogICAgICB9DQogICAgICBpZiAoZGVmaW5lZDApIHsNCiAgICAgICAgeDB6W2ldID0gK3gwKGQsIGksIGRhdGEpLCB5MHpbaV0gPSAreTAoZCwgaSwgZGF0YSk7DQogICAgICAgIG91dHB1dC5wb2ludCh4MSA/ICt4MShkLCBpLCBkYXRhKSA6IHgweltpXSwgeTEgPyAreTEoZCwgaSwgZGF0YSkgOiB5MHpbaV0pOw0KICAgICAgfQ0KICAgIH0NCg0KICAgIGlmIChidWZmZXIpIHJldHVybiBvdXRwdXQgPSBudWxsLCBidWZmZXIgKyAiIiB8fCBudWxsOw0KICB9DQoNCiAgZnVuY3Rpb24gYXJlYWxpbmUoKSB7DQogICAgcmV0dXJuIGxpbmUoKS5kZWZpbmVkKGRlZmluZWQpLmN1cnZlKGN1cnZlKS5jb250ZXh0KGNvbnRleHQpOw0KICB9DQoNCiAgYXJlYS54ID0gZnVuY3Rpb24oXykgew0KICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKHgwID0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ow0KDQp2YXIgYyA9IC0wLjU7DQp2YXIgcyA9IE1hdGguc3FydCgzKSAvIDI7DQp2YXIgayA9IDEgLyBNYXRoLnNxcnQoMTIpOw0KdmFyIGEgPSAoayAvIDIgKyAxKSAqIDM7DQoNCnZhciB3eWUgPSB7DQogIGRyYXc6IGZ1bmN0aW9uKGNvbnRleHQsIHNpemUpIHsNCiAgICB2YXIgciA9IE1hdGguc3FydChzaXplIC8gYSksDQogICAgICAgIHgwID0gciAvIDIsDQogICAgICAgIHkwID0gciAqIGssDQogICAgICAgIHgxID0geDAsDQogICAgICAgIHkxID0gciAqIGsgKyByLA0KICAgICAgICB4MiA9IC14MSwNCiAgICAgICAgeTIgPSB5MTsNCiAgICBjb250ZXh0Lm1vdmVUbyh4MCwgeTApOw0KICAgIGNvbnRleHQubGluZVRvKHgxLCB5MSk7DQogICAgY29udGV4dC5saW5lVG8oeDIsIHkyKTsNCiAgICBjb250ZXh0LmxpbmVUbyhjICogeDAgLSBzICogeTAsIHMgKiB4MCArIGMgKiB5MCk7DQogICAgY29udGV4dC5saW5lVG8oYyAqIHgxIC0gcyAqIHkxLCBzICogeDEgKyBjICogeTEpOw0KICAgIGNvbnRleHQubGluZVRvKGMgKiB4MiAtIHMgKiB5MiwgcyAqIHgyICsgYyAqIHkyKTsNCiAgICBjb250ZXh0LmxpbmVUbyhjICogeDAgKyBzICogeTAsIGMgKiB5MCAtIHMgKiB4MCk7DQogICAgY29udGV4dC5saW5lVG8oYyAqIHgxICsgcyAqIHkxLCBjICogeTEgLSBzICogeDEpOw0KICAgIGNvbnRleHQubGluZVRvKGMgKiB4MiArIHMgKiB5MiwgYyAqIHkyIC0gcyAqIHgyKTsNCiAgICBjb250ZXh0LmNsb3NlUGF0aCgpOw0KICB9DQp9Ow0KDQp2YXIgc3ltYm9scyA9IFsNCiAgY2lyY2xlLA0KICBjcm9zcywNCiAgZGlhbW9uZCwNCiAgc3F1YXJlLA0KICBzdGFyLA0KICB0cmlhbmdsZSwNCiA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tkYXlzKSwNCiAgICAgIHNob3J0V2Vla2RheUxvb2t1cCA9IGZvcm1hdExvb2t1cChsb2NhbGVfc2hvcnRXZWVrZGF5cyksDQogICAgICBtb250aFJlID0gZm9ybWF0UmUobG9jYWxlX21vbnRocyksDQogICAgICBtb250aExvb2t1cCA9IGZvcm1hdExvb2t1cChsb2NhbGVfbW9udGhzKSwNCiAgICAgIHNob3J0TW9udGhSZSA9IGZvcm1hdFJlKGxvY2FsZV9zaG9ydE1vbnRocyksDQogICAgICBzaG9ydE1vbnRoTG9va3VwID0gZm9ybWF0TG9va3VwKGxvY2FsZV9zaG9ydE1vbnRocyk7DQoNCiAgdmFyIGZvcm1hdHMgPSB7DQogICAgImEiOiBmb3JtYXRTaG9ydFdlZWtkYXksDQogICAgIkEiOiBmb3JtYXRXZWVrZGF5LA0KICAgICJiIjogZm9ybWF0U2hvcnRNb250aCwNCiAgICAiQiI6IGZvcm1hdE1vbnRoLA0KICAgICJjIjogbnVsbCwNCiAgICAiZCI6IGZvcm1hdERheU9mTW9udGgsDQogICAgImUiOiBmb3JtYXREYXlPZk1vbnRoLA0KICAgICJIIjogZm9ybWF0SG91cjI0LA0KICAgICJJIjogZm9ybWF0SG91cjEyLA0KICAgICJqIjogZm9ybWF0RGF5T2ZZZWFyLA0KICAgICJMIjogZm9ybWF0TWlsbGlzZWNvbmRzLA0KICAgICJtIjogZm9ybWF0TW9udGhOdW1iZXIsDQogICAgIk0iOiBmb3JtYXRNaW51dGVzLA0KICAgICJwIjogZm9ybWF0UGVyaW9kLA0KICAgICJTIjogZm9ybWF0U2Vjb25kcywNCiAgICAiVSI6IGZvcm1hdFdlZWtOdW1iZXJTdW5kYXksDQogICAgInciOiBmb3JtYXRXZWVrZGF5TnVtYmVyLA0KICAgICJXIjogZm9ybWF0V2Vla051bWJlck1vbmRheSwNCiAgICAieCI6IG51bGwsDQogICAgIlgiOiBudWxsLA0KICAgICJ5IjogZm9ybWF0WWVhciwNCiAgICAiWSI6IGZvcm1h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BhY3RpdmUgPSBmdW5jdGlvbihub2RlLCBuYW1lKSB7DQogIHZhciBzY2hlZHVsZXMgPSBub2RlLl9fdHJhbnNpdGlvbiwNCiAgICAgIHNjaGVkdWxlLA0KICAgICAgaTsNCg0KICBpZiAoc2NoZWR1bGVzKSB7DQogICAgbmFtZSA9IG5hbWUgPT0gbnVsbCA/IG51bGwgOiBuYW1lICsgIiI7DQogICAgZm9yIChpIGluIHNjaGVkdWxlcykgew0KICAgICAgaWYgKChzY2hlZHVsZSA9IHNjaGVkdWxlc1tpXSkuc3RhdGUgPiBTQ0hFRFVMRUQgJiYgc2NoZWR1bGUubmFtZSA9PT0gbmFtZSkgew0KICAgICAgICByZXR1cm4gbmV3IFRyYW5zaXRpb24oW1tub2RlXV0sIHJvb3QsIG5hbWUsICtpKTsNCiAgICAgIH0NCiAgICB9DQogIH0NCg0KICByZXR1cm4gbnVsbDsNCn07DQoNCmV4cG9ydHMudHJhbnNpdGlvbiA9IHRyYW5zaXRpb247DQpleHBvcnRzLmFjdGl2ZSA9IGFjdGl2ZTsNCmV4cG9ydHMuaW50ZXJydXB0ID0gaW50ZXJydXB0Ow0KDQpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgJ19fZXNNb2R1bGUnLCB7IHZhbHVlOiB0cnVlIH0pOw0KDQp9KSkpOw0KDQp9LHsiZDMtY29sb3IiOjQsImQzLWRpc3BhdGNoIjo1LCJkMy1lYXNlIjo2LCJkMy1pbnRlcnBvbGF0ZSI6OSwiZDMtc2VsZWN0aW9uIjoxMiwiZDMtdGltZXIiOjE2fV19LHt9LFsxXSk7DQo="></script> | |
</head> | |
<body style="background-color:white;"> | |
<div id="htmlwidget_container"> | |
<div id="htmlwidget-c9c7495687611e24fd85" class="sunburst html-widget" style="width:960px;height:500px; position:relative;"> | |
<div> | |
<div class="sunburst-main"> | |
<div class="sunburst-sequence"></div> | |
<div class="sunburst-chart"> | |
<div class="sunburst-explanation" style="visibility:hidden;"></div> | |
</div> | |
</div> | |
<div class="sunburst-sidebar"> | |
<input type="checkbox" class="sunburst-togglelegend">Legend</input> | |
<div class="sunburst-legend" style="visibility:hidden;"></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script type="application/json" data-for="htmlwidget-c9c7495687611e24fd85">{"x":{"data":{"name":"leaflet.extras","children":[{"name":"CONDUCT.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1412},{"name":"DESCRIPTION","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:09:47","size":1171},{"name":"docs","children":[{"name":"authors.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3466},{"name":"index.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":9245},{"name":"jquery.sticky-kit.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2807},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":35815},{"name":"link.svg","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":822},{"name":"news","children":[{"name":"index.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":13191}]},{"name":"pkgdown.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1990},{"name":"pkgdown.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":148},{"name":"reference","children":[{"name":"addAwesomeMarkersDependencies.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3992},{"name":"addBootstrapDependency.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3814},{"name":"addGeodesicPolylines.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":10185},{"name":"draw-options.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":11932},{"name":"draw.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6982},{"name":"fullscreen.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4663},{"name":"gps.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5379},{"name":"heatmap.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":11859},{"name":"index.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":11369},{"name":"leaflet.extras.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3415},{"name":"leafletExtrasDependencies.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3853},{"name":"leaflethash.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4305},{"name":"measure-path.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5363},{"name":"omnivore.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":26383},{"name":"pulseMarkers.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":8897},{"name":"search-options.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":10742},{"name":"search.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4892},{"name":"sleep.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5068},{"name":"style-editor.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4856},{"name":"TileCaching.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4891},{"name":"utils.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5192},{"name":"weatherMarkers.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":9032},{"name":"webglheatmap.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":11160},{"name":"wms-legend.html","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4218}]}]},{"name":"inst","children":[{"name":"examples","children":[{"name":"CSV.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":853},{"name":"data","children":[{"name":"csv","children":[{"name":"us_airports.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5929},{"name":"world_airports.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":74957}]},{"name":"gpx","children":[{"name":"md-airports.gpx.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5414},{"name":"md-towns.gpx.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":10837},{"name":"St_Louis_Zoo_sample.gpx.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1299}]},{"name":"kml","children":[{"name":"cb_2015_us_state_20m.kml.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":148025},{"name":"crimes.kml.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":268476}]},{"name":"London-Crimes","children":[{"name":"2016-01","children":[{"name":"2016-01-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":22298}]},{"name":"2016-02","children":[{"name":"2016-02-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":24268}]},{"name":"2016-03","children":[{"name":"2016-03-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":25277}]},{"name":"2016-04","children":[{"name":"2016-04-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":25092}]},{"name":"2016-05","children":[{"name":"2016-05-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":24061}]},{"name":"2016-06","children":[{"name":"2016-06-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":24817}]},{"name":"2016-07","children":[{"name":"2016-07-city-of-london-street.csv.zip","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":25450}]}]}]},{"name":"draw.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3212},{"name":"geodesic.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3204},{"name":"geojsonv2.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":11522},{"name":"GPX.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1180},{"name":"heatmaps.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2478},{"name":"KML.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1900},{"name":"measurePath.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2975},{"name":"pulseIcon.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1698},{"name":"search.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2147},{"name":"shiny","children":[{"name":"draw-events","children":[{"name":"app.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1302}]},{"name":"search","children":[{"name":"app.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":346}]}]},{"name":"sleep.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":392},{"name":"TileLayer-Caching.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1109},{"name":"TopoJSON.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2791},{"name":"virginia.rds","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":22727557},{"name":"weatherIcons.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2134},{"name":"webglHeatmaps.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2743},{"name":"wmsLegend.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":871}]},{"name":"htmlwidgets","children":[{"name":"lib","children":[{"name":"draw","children":[{"name":"draw-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7579},{"name":"images","children":[{"name":"layers-2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1259},{"name":"layers.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":696},{"name":"marker-icon-2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2586},{"name":"marker-icon.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1466},{"name":"marker-shadow.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":618},{"name":"spritesheet-2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2078},{"name":"spritesheet.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1056},{"name":"spritesheet.svg","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1834}]},{"name":"leaflet.draw-src.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7630},{"name":"leaflet.draw-src.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":119007},{"name":"leaflet.draw-src.map","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":148818},{"name":"leaflet.draw.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5087},{"name":"Leaflet.draw.drag-src.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":26263},{"name":"Leaflet.draw.drag.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":13644},{"name":"leaflet.draw.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":62042},{"name":"MIT-LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1087},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2127}]},{"name":"fullscreen","children":[{"name":"fullscreen.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":299},{"name":"fullscreen@2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":420},{"name":"leaflet.fullscreen.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1034},{"name":"Leaflet.fullscreen.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5225},{"name":"Leaflet.fullscreen.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3677},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":730},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":638}]},{"name":"geodesic","children":[{"name":"geodesic-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2267},{"name":"Leaflet.Geodesic.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":18015},{"name":"Leaflet.Geodesic.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7157},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":35793},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":550}]},{"name":"geojson-choropleth","children":[{"name":"choropleth-src.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":10977},{"name":"choropleth.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":43779},{"name":"choropleth.js.map","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":137020},{"name":"LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1102},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":933}]},{"name":"gps","children":[{"name":"gps-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1616},{"name":"images","children":[{"name":"gps-icon.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2081}]},{"name":"leaflet-gps.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1182},{"name":"leaflet-gps.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5633},{"name":"leaflet-gps.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1300},{"name":"leaflet-gps.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3332},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":967}]},{"name":"hash","children":[{"name":"leaflet-hash.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3624},{"name":"LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1073},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":496}]},{"name":"heat","children":[{"name":"heat-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":5980},{"name":"leaflet-heat.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4951},{"name":"leaflet-heat2.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4918},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1343},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1250}]},{"name":"icon-pulse","children":[{"name":"L.Icon.Pulse.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":797},{"name":"L.Icon.Pulse.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2192},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1124},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":874},{"name":"plugin-pulseIcon-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1603}]},{"name":"mapshaper","children":[{"name":"mapshaper.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":637515}]},{"name":"measure-path","children":[{"name":"leaflet-measure-path.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":559},{"name":"leaflet-measure-path.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":14175},{"name":"LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2416},{"name":"measure-path-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1169},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":621}]},{"name":"omnivore","children":[{"name":"csv2geojson.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":14021},{"name":"omnivore-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":17727},{"name":"polyline.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4971},{"name":"toGeoJSON.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":22649},{"name":"topojson.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":16697},{"name":"wellknown.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7078}]},{"name":"search","children":[{"name":"images","children":[{"name":"back.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":117578},{"name":"leaflet-search.jpg","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":148555},{"name":"loader.gif","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1849},{"name":"search-icon-mobile.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3959},{"name":"search-icon.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3838}]},{"name":"leaflet-search-binding.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3630},{"name":"leaflet-search.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2627},{"name":"leaflet-search.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":15725},{"name":"leaflet-search.mobile.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1726},{"name":"leaflet-search.mobile.src.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2001},{"name":"leaflet-search.src.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3107},{"name":"leaflet-search.src.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":30248}]},{"name":"sleep","children":[{"name":"Leaflet.Sleep.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6714},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1089},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":609}]},{"name":"style-editor","children":[{"name":"img","children":[{"name":"icon.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4546}]},{"name":"Leaflet.StyleEditor.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3828},{"name":"Leaflet.StyleEditor.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":16064},{"name":"LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1067},{"name":"package.json","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":726},{"name":"styleEditor-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":613}]},{"name":"TileLayer.PouchDBCached","children":[{"name":"COPYING","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1096},{"name":"L.TileLayer.PouchDBCached.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6697},{"name":"pouchdb-6.0.7.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":922643}]},{"name":"turf","children":[{"name":"turf.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":532896}]},{"name":"utils","children":[{"name":"leaflet_extras-utils.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":269}]},{"name":"weather-markers","children":[{"name":"font","children":[{"name":"weathericons-regular-webfont.eot","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":99774},{"name":"weathericons-regular-webfont.svg","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":185225},{"name":"weathericons-regular-webfont.ttf","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":99564},{"name":"weathericons-regular-webfont.woff","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":56468}]},{"name":"images","children":[{"name":"markers-matte.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":14323},{"name":"markers-matte@2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":31113},{"name":"markers-plain.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7946},{"name":"markers-shadow.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":535},{"name":"markers-shadow@2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1469},{"name":"markers-soft.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":41226},{"name":"markers-soft@2x.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":66408}]},{"name":"leaflet.weather-markers.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2379},{"name":"leaflet.weather-markers.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3771},{"name":"leaflet.weather-markers.min.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1735},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1060},{"name":"plugin-weatherMarkers-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1822},{"name":"weather-icons-wind.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":150459},{"name":"weather-icons-wind.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":126750},{"name":"weather-icons.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":32494},{"name":"weather-icons.min.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":26654}]},{"name":"webgl-heatmap","children":[{"name":"deep-sea-gradient.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3403},{"name":"LICENSE.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1095},{"name":"skyline-gradient.png","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3452},{"name":"webgl-heatmap-bindings.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7163},{"name":"webgl-heatmap-leaflet.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4754},{"name":"webgl-heatmap.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":41022}]},{"name":"wms-legend","children":[{"name":"leaflet.wmslegend.css","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":362},{"name":"leaflet.wmslegend.js","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2241},{"name":"LICENSE.txt","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1098}]}]}]}]},{"name":"leaflet.extras.Rproj","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":426},{"name":"LICENSE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":35815},{"name":"man","children":[{"name":"addAwesomeMarkersDependencies.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":463},{"name":"addBootstrapDependency.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":346},{"name":"addGeodesicPolylines.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2968},{"name":"draw-options.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4313},{"name":"draw.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2171},{"name":"fullscreen.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":623},{"name":"gps.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1212},{"name":"heatmap.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3964},{"name":"leaflet.extras.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":263},{"name":"leafletExtrasDependencies.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":464},{"name":"leaflethash.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":445},{"name":"measure-path.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1253},{"name":"omnivore.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":8485},{"name":"pulseMarkers.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3661},{"name":"search-options.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3747},{"name":"search.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":801},{"name":"sleep.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":917},{"name":"style-editor.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":863},{"name":"TileCaching.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":796},{"name":"utils.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1030},{"name":"weatherMarkers.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3768},{"name":"webglheatmap.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3689},{"name":"wms-legend.Rd","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":487}]},{"name":"NAMESPACE","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1897},{"name":"NEWS.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3218},{"name":"R","children":[{"name":"draw.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3835},{"name":"drawOptions.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6000},{"name":"fullscreen.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1120},{"name":"geodesic.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":4429},{"name":"gps.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2259},{"name":"hash.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":781},{"name":"heatmap.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7506},{"name":"jsFunctions.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3934},{"name":"leaflet.extras-package.r","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":125},{"name":"leafletDependencies.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1414},{"name":"mapUtils.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":632},{"name":"measure-path.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":2764},{"name":"omnivore.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":16315},{"name":"pulseIcon.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6820},{"name":"search.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":6721},{"name":"sleep.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1523},{"name":"styleEditor.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1521},{"name":"TileLayer.PouchDBCached.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1144},{"name":"weatherMarkers.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":8063},{"name":"webGLHeatmap.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":7307},{"name":"wms-legend.R","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":1525}]},{"name":"README.md","atime":"2017-06-20 06:08:26","ctime":"2017-06-20 06:08:26","exe":"no","isdir":false,"mode":{},"mtime":"2017-06-20 06:08:26","size":3876}]},"options":{"legendOrder":null,"colors":null,"valueField":"size","percent":true,"count":true,"explanation":null,"breadcrumb":[],"legend":[],"sortFunction":null}},"evals":[],"jsHooks":[]}</script> | |
<script type="application/htmlwidget-sizing" data-for="htmlwidget-c9c7495687611e24fd85">{"viewer":{"width":450,"height":350,"padding":15,"fill":true},"browser":{"width":960,"height":500,"padding":40,"fill":true}}</script> | |
</body> | |
</html> |