Skip to content

Instantly share code, notes, and snippets.

@frogcat
Last active April 21, 2016 10:49
Show Gist options
  • Save frogcat/b267b3727268d5c35c8a516a8c52b467 to your computer and use it in GitHub Desktop.
Save frogcat/b267b3727268d5c35c8a516a8c52b467 to your computer and use it in GitHub Desktop.
2016熊本地震の国土地理院正射画像タイルの所在と各種比較UIへのリンクを収録したGeoJSON
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
id longitude latitude
20160414kumamoto_0415dol3 130.6586 32.6379
20160414kumamoto_0415dol1 130.8121 32.7905
20160414kumamoto_0415dol2 130.6914 32.7623
20160414kumamoto_0416dol2 130.6880 32.6893
20160414kumamoto_0416dol7 131.4627 33.3416
20160414kumamoto_0416dol5 130.99399 32.91508
20160414kumamoto_0416dol3 130.7511 32.8840
20160414kumamoto_0416dol6 131.0581 32.8251
20160414kumamoto_0416dol4 130.9268 32.8472
20160414kumamoto_0416dol1 130.7072 32.8055
20160414kumamoto_0419dol6 130.9892 33.1038
20160414kumamoto_0419dol2 131.0473 32.8224
20160414kumamoto_0420dol01 130.9210 32.8455
20160414kumamoto_0420dol03 131.0054 32.6713
"use strict";
var fs = require("fs");
var axios = require("axios");
var promises = [];
fs.readFileSync("data.csv", "UTF-8").split("\n").forEach(function(row) {
if (row.indexOf(",") == -1 || row.match(/^id.*/))
return;
var col = row.replace("\r", "").split(",");
var obj = {
id: col[0],
longitude: parseFloat(col[1]),
latitude: parseFloat(col[2])
};
promises.push(new Promise(function(resolve, reject) {
axios.get("http://frogcat.github.io/layers/" + obj.id + ".txt").then(function(a) {
obj.label = a.data.layers[0].title;
resolve(obj);
});
}));
});
Promise.all(promises).then(function(a) {
var features = [];
a.forEach(function(obj) {
var gsi = "http://maps.gsi.go.jp/cmp/?";
gsi += [
"rl=ort",
"ll=" + obj.id,
"ovl=experimental_anno",
"lat=" + obj.latitude,
"lng=" + obj.longitude,
"z=15",
"rattr=" + encodeURI("電子国土基本図(オルソ画像)"),
"lattr=" + encodeURI(obj.label)
].join("&");
gsi += ("#15/" + obj.latitude + "/" + obj.longitude);
var tmpl = "http://frogcat.github.io/leaflet-tilelayer-cmp/?";
tmpl += (obj.id + ",@");
tmpl += ("#15/" + obj.latitude + "/" + obj.longitude);
features.push({
"type": "Feature",
"properties": {
"title": obj.label,
"gsi": gsi,
"std": tmpl.replace("@", "std"),
"ort": tmpl.replace("@", "ort"),
"relief": tmpl.replace("@", "relief")
},
"geometry": {
"type": "Point",
"coordinates": [obj.longitude, obj.latitude]
}
});
});
console.log(JSON.stringify({
"type": "FeatureCollection",
"features": features
}, null, " "));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment