Skip to content

Instantly share code, notes, and snippets.

@frogcat
Last active September 14, 2021 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogcat/eebaa42931c42e0026954c2f775cf898 to your computer and use it in GitHub Desktop.
Save frogcat/eebaa42931c42e0026954c2f775cf898 to your computer and use it in GitHub Desktop.
proj4 平面直角座標系

About

proj4 平面直角座標系

  • epsg を指定することで proj4.js のスニペットを生成
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>epsg</title>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" />
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
<style>
#input {
width: 100%;
}
#result {
background: black;
color: white;
padding: 5px;
}
#container {
max-width: 1024px;
margin: auto;
}
</style>
</head>
<body>
<div id="container">
<form id="form">
<input type="text" value="2443-2461,6669-6687" id="input" />
</form>
<pre id="result"></pre>
</div>
<script>
$("#form").submit(function() {
const epsg = [];
$("#input").val().split(",").forEach(x => {
if (x.match(/^([0-9]+)$/)) {
epsg.push(x);
} else if (x.match(/^([0-9]+)-([0-9]+)$/)) {
const a = parseInt(RegExp.$1);
const b = parseInt(RegExp.$2);
for (let i = Math.min(a, b); i <= Math.max(a, b); i++)
epsg.push(i);
}
epsg.sort();
const promises = epsg.map(key => {
return fetch(`https://epsg.io/${key}.js`).then(a => a.ok ? a.text() : null);
});
promises.unshift(
fetch("https://raw.githubusercontent.com/maptiler/epsg.io/master/LICENSE")
.then(a => a.text())
.then(a => `/*!\n${a.split("\n").map(x=>` * ${x}`).join("\n")}\n */`)
);
Promise.all(promises).then(a => {
$("#result").text(a.filter(x => x !== null).join("\n"));
});
});
return false;
}).submit();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment