Skip to content

Instantly share code, notes, and snippets.

@zmofei
Created April 11, 2019 03:19
Show Gist options
  • Save zmofei/5b940e83a13b08e3b42e1305f64f221d to your computer and use it in GitHub Desktop.
Save zmofei/5b940e83a13b08e3b42e1305f64f221d to your computer and use it in GitHub Desktop.
const fs = require('fs');
const _get = JSON.parse(fs.readFileSync('./china.geojson'));
const geo = _get.coordinates[0]
// console.log(geo)
const cache = new Set();
let newC = [];
geo.forEach(v => {
let name = `${v[0]},${v[1]}`;
if (cache.has(name)) {
// count++;
console.log(name);
} else {
newC.push(v);
cache.add(name, v);
}
})
_get.coordinates[0] = newC;
fs.writeFileSync('./china_after.geojson', JSON.stringify(_get));
// cache.forEach((k, v) => {
// console.log(v)
// })
// console.log(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment