本文介绍了要素周围的d3.geo缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在d3.js中的地理要素周围以固定距离单位(公里或英里)绘制缓冲区(另一个要素)?

Is it possible to draw a buffer (another feature) around a geographic feature in d3.js as a fixed distance unit (kilometers or miles)?

例如,我将如何围绕从该点向各个方向延伸25英里的点绘制路径.我试过使用d3.geo.circle并通过了一部分分数(25英里/每个纬度度约69英里或25/69),但是我意识到,尽管d3.geo.circle可以处理度数的重投影,但它无法容纳每个纵向度的不同长度.

For instance, how would I draw a path around a point that extends 25 miles from that point in every direction. I've tried using d3.geo.circle and passing a fraction of degree (25 miles / approximately 69 miles per latitudinal degree or 25 / 69) but realize that although d3.geo.circle handles the reprojection of degrees, it does not accommodate for the differing lengths of each longitudinal degrees.

buffer = d3.geo.circle().angle(25/69).origin(function(x, y) { return [x, y]; })

我是从这里借来的:

http://bl.ocks.org/mbostock/5628479

更新:

看起来我想做的是创建一个测地线缓冲区.

It looks like what I'd like to do is create a geodesic buffer.

更新:

我能够通过从一系列给定距离和起点的目标点绘制路径来创建缓冲区.

I was able to create the buffer by drawing a path from a series of destination points given a distance and bearing from a start point.

请参见 http://www.movable-type.co.uk/scripts/latlong.html 用于JavaScript实现

See http://www.movable-type.co.uk/scripts/latlong.html for JavaScript implementation

赞:

function drawBuffer(lat, long, distance){
    var intervals = 18;
    var intervalAngle = (360 / intervals);
    var pointsData = [];
    for(var i = 0; i < intervals; i++){
        pointsData.push(getDestinationPoint(lat, long, i * intervalAngle, distance));
    }
    // Draw path using pointsData;
}

推荐答案

我能够通过从一系列给定距离并距起点的目标点绘制路径来围绕点创建缓冲区.

I was able to create a buffer around a point by drawing a path from a series of destination points given a distance and bearing from a start point.

请参见 http://www.movable-type.co.uk/scripts/latlong.html 用于JavaScript实现

See http://www.movable-type.co.uk/scripts/latlong.html for JavaScript implementation

赞:

function drawBuffer(lat, long, distance){
    var intervals = 18;
    var intervalAngle = (360 / intervals);
    var pointsData = [];
    for(var i = 0; i < intervals; i++){
        pointsData.push(getDestinationPoint(lat, long, i * intervalAngle, distance)); // See link
    }
    // Draw path using pointsData;
}

这篇关于要素周围的d3.geo缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 15:26