gpt4 book ai didi

d3.js - D3js : How to get the real bounding box of features crossing the anti-meridian?

转载 作者:行者123 更新时间:2023-12-02 00:45:25 25 4
gpt4 key购买 nike

我正在使用

var bounds = d3.geo.path()
.projection(function(d) { return d; })
.bounds;

获取所有国家特征的边界。一切都很好,直到我遇到了跨越反子午线的斐济或俄罗斯。

Fiji.bb = [[-180,-18.294755298529864], [180.00000000000006,-16.037142847284727]];
// with [[West,South],[East,North]]

纬度反馈非常完美,对于这个问题我们忽略它们。然而,边界框的纵向宽度太大了,从 W:-180 到 E:+180。

从计算机或 GIS 的角度来看,这完全有道理,但作为人类,我完全错过了真实最西边和最东边的边界。

// current data back
Fiji.bb = [[-180,-18.294...],[180.00000000000006,-16.0371...]];
// wanted data back
Fiji.bb = [[177,-18.294...],[-179,-16.0371...]];

到目前为止,我还没有找到任何方法来获取这些岛屿的真实西边 (~177⁰) 和东边 (~ -179⁰) 值。

有没有一种方法可以通过 d3js 获取这些岛屿的真实边界框值?

我目前计划通过为自己提供一些基于前一个 D3.geo : Spherical arcs rather than straight lines for paralles? 的近似 WSEN 值来绕过此问题。 。虽然有点难看,但还是可以用的。


编辑:有趣的是,面积计算正确:

var area = d3.geo.path()
.projection(function(d) { return d; })
.area;
// area = 1.639711598252461;

这让我认为 D3js 有一种内部方法来管理穿越反经络的功能,而不必总是做全局性的戏剧。

最佳答案

您应该使用d3.geo.bounds来实现此目的,因为您需要球坐标中的边界框。

(使用带有恒等函数的 d3.geo.path 作为投影不起作用,因为 d3.geo.path 只能计算笛卡尔坐标中的边界框。)

参见 Jason Davies 的 Geographic Bounding Boxes页面了解详细信息。

关于d3.js - D3js : How to get the real bounding box of features crossing the anti-meridian?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28182386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com