javascript - 使用谷歌地图绘制不规则同心圆

标签 javascript algorithm maps geometry

我有点问题。我正在尝试使用 Javascript 和 Google Maps API v2 执行以下操作:

myhurricane.net - Wind Radii Profile

我可以使用在 Internet 上找到的公式很好地绘制单个圆圈。我面临的问题是圈子必须:

一个。保持同心,并且 B. 每个“象限”必须有不同的半径,即 NE、NW、SE 和 SW

我几乎在 Internet 上搜索了所有我能想到的地方,但没有想出如何做到这一点。显然以前有人这样做过,因此我为什么要在程序员论坛上提问。 :)

谢谢!

更新:我已经使用以下代码绘制出我认为每个点的坐标。对于下图:

snapshot-1252125257.781397

这是使用以下 JS 获得的:

http://gist.github.com/181290

注意:此 javascript 来自(稍作修改)以下站点,该站点可能包含更多有关算法最终结果的答案:http://www.movable-type.co.uk/scripts/latlong.html

更新 2:我能够在 Google map 中找到它:

Concentric Circles Progress

使用以下代码创建:

var NEQ = [0, 90];
var SEQ = [90, 180];
var SWQ = [180, 270];
var NWQ = [270, 0];

// var centrePoint = new LatLon(25.0, -83.1);
// pointsForWindQuadrant(NEQ, centrePoint, 50);
function pointsForWindQuadrant(quadrantDegrees, centrePoint, radius){
  var points = [];

  // Points must be pushed into the array in order
  points.push(new google.maps.LatLng(centrePoint.lat, centrePoint.lon));

  for(i = quadrantDegrees[0]; i <= quadrantDegrees[1]; i++){
    var point = centrePoint.destPoint(i, radius * 1.85);
    points.push(new google.maps.LatLng(point.lat, point.lon)); // Radius should be in nautical miles from NHC
  }

  points.push(new google.maps.LatLng(centrePoint.lat, centrePoint.lon));

  return points;
}

更新 3: 我可能还应该指出,这是针对地理坐标系(因为这整件事都是针对热带气旋风半径),而不是笛卡尔坐标系坐标系。谢谢!

最佳答案

基本上,将圆计算为 x,y = (cos(a), sin(a)),然后将此(两项)乘以作为 Angular 适当函数的半径。我不太了解 Javascript 或 Google map ,所以我将使用 Python 来完成此操作,希望它足够清楚。

from pylab import *

def Rscale(a):
    if a>3*pi/2:  # lower right, and then work CW around the circle
        return 1.
    elif a>pi:  # lower left
        return .9
    elif a>pi/2:   # upper left
        return .8
    else:       # upper right
        return 1.

def step_circle(R):
    return array([(R*Rscale(a))*array([cos(a), sin(a)]) for a in arange(0, 2*pi, .001)])

for R in (.5, .7, .9):  # make three concentric circles
    c = step_circle(R)
    plot(c[:,0], c[:,1])

show()

哪个给 alt text

我无法真正理解您的草图,所以我只是猜测数字。此外,我将最右边的两个象限设为相同,因为这就是您的情节的样子,但这当然是可选的。

关于javascript - 使用谷歌地图绘制不规则同心圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1382394/

相关文章:

javascript - KendoUI 网格不会触发 saveChanges 事件

algorithm - 加权二分匹配

algorithm - 排序算法的时间复杂度

javascript - Mapbox开源并使用 key ?

api - GMaps API - 删除默认 POI

firebase - 从第二屏返回后 flutter 刷新 map

javascript - $.ajax 函数未按预期工作

javascript - 坚持逻辑试图定位一些动态的东西

javascript - 滚动 jquery 仅选择一个具有名称的类,而不是全部

c# - 文件去斑 - OCR