function wgs84resample(precision = 0.01) {
var x0, y0, point, lpoint;
const radians = Math.PI / 180;
function linepoint(x,y) {
if (true) if (x0 !== undefined) {
const diff =
Math.sin(Math.abs(x - x0) * radians)
* Math.sin(Math.max(Math.abs(y), Math.abs(y0)) * radians);
if (diff > precision) {
const step = precision / diff,
D = (x - x0 + 10 * 360 + 180) % 360 - 180,
E = (y - y0);
for (var q = step; q < 1; q += step)
if (true) lpoint(x0 + q * D, y0 + q * E);
}
}
lpoint(x,y);
x0 = x, y0 = y;
}
const t = d3.geoTransform({
lineStart: function() {
point = this.stream.point;
this.stream.lineStart();
lpoint = this.stream.point;
x0 = undefined;
this.stream.point = linepoint;
},
lineEnd: function() {
this.stream.lineEnd();
this.stream.point = point;
},
});
return function(obj) {
return d3.geoProject(obj, t);
}
}