map = function*() {
const wrapper = d3.create("div")
.style("height", `${height}px`);
const canvas = wrapper.append("canvas")
.style("position", "absolute")
.attr("width", width)
.attr("height", height);
path.context(null)
const svg = wrapper.append("svg")
.style("position", "absolute")
.attr("width", width)
.attr("height", height);
const mask = svg.append("mask")
.attr("id", "hole");
mask.append("rect")
.attr("width", width)
.attr("height", height)
.attr("opacity", 1)
.attr("fill", "white");
mask.append("path")
.datum(conusOuter)
.attr("d", path)
.attr("fill", "black")
.attr("stroke-linejoin", "round");
svg.append("rect")
.attr("mask", "url(#hole)")
.attr("fill", "white")
.attr("width", width)
.attr("height", height);
const context = canvas.node().getContext("2d");
path.context(context);
let i = 0;
for (let row = 0; row < rasters.height; row++) {
for (let col = 0; col < rasters.width; col++) {
const lon = originX + col * pixelWidth;
const lat = originY + row * pixelHeight;
const value = values[row * rasters.width + col];
if (value === null_value) continue;
const w = lon - pixelWidth;
const e = lon + pixelWidth;
const n = lat - pixelHeight;
const s = lat + pixelHeight;
context.beginPath();
path({
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [
[[w, n], [e, n], [e, s], [w, s], [w, n]]
]
}
});
const c = color(value);
context.fillStyle = c;
context.fill();
context.strokeStyle = c;
context.stroke();
if (i++ % 1e4 === 0) {
yield wrapper.node();
}
}
}
context.fillStyle = "none";
context.lineWidth = 1;
context.beginPath();
path(conusInner);
context.strokeStyle = "#494949"
context.stroke();
context.beginPath();
path(conusOuter);
context.strokeStyle = "#2a2a2a"
context.stroke();
return wrapper.node();
}