将 lat/long 投影到具有浮点精度而不是 int 精度的像素

Projecting lat/long to pixels with float accuracy instead of int

我正在使用 mapbox.js 创建 voronoi 地图。但是,我对从 latitude/longitude 到屏幕上像素的投影精度有疑问,因为精度仅为 int 而不是 float。这会导致点在缩放时略有变化in/out,从而导致整个 voronoi 地图发生变化!

编辑: 我更新了代码以包含生成 voronoi 的代码。您可以看到 voronoi 代码使用像素,因此存在问题,因为准确性可能存在问题。

var voronoi = d3.geom.voronoi()
    .x(function (d) {
        return d.x;
    })
    .y(function (d) {
        return d.y;
    });

filteredPoints.forEach(function (d) {
    var latlng = new L.LatLng(d.latitude, d.longitude);
    var point = map.latLngToLayerPoint(latlng);
    d.x = point.x;
    d.y = point.y;
}

voronoi(filteredPoints).forEach(function (d) {
            d.point.cell = d;
});

阅读 Leaflet 源代码并编写相同的内容,只是没有调用 round()