相关疑难解决方法(0)

找到不规则形状多边形的"视觉"中心的最快方法是什么?

我需要找到一个点,它是一个不规则形状的多边形的视觉中心.通过视觉中心,我的意思是在视觉上看起来位于多边形的大区域的中心的点.应用程序是在多边形内部放置一个标签.

这是一个使用内部缓冲的解决方案:

https://web.archive.org/web/20150708063910/http://proceedings.esri.com/library/userconf/proc01/professional/papers/pap388/p388.htm

如果要使用它,找到缓冲区的有效且快速的方法是什么?如果要使用任何其他方式,这是哪种方式?

真正坚韧的多边形的一个很好的例子是一个巨大的厚U(用Arial Black或Impact或一些这样的字体书写).

point polygon

48
推荐指数
6
解决办法
5万
查看次数

在JavaScript中查找多边形的中心点

我有一个来自谷歌地图的"地方"对象,它有一组坐标,代表一个给定位置的边界框,比如伦敦.每组坐标都有纬度和经度.

我写了下面的代码来找到中心点,但我不确定它是否确实产生了中心点.如果多边形有5个点而不是4个怎么办?此外,这可以通过更少的操作以更有效的方式完成吗?

function average(array) {
  // Add together and then divide by the length
  return _.reduce(array, function (sum, num) {
    return sum + num;
  }, 0) / array.length;
}

// I have a two-dimensional array that I want to get the average of

var coords = [
  [ -1.2, 5.1 ],
  [ -1.3, 5.2 ],
  [ -1.8, 5.9 ],
  [ -1.9, 5.8 ]
]

// So I get the first column

var lats = coords.map(function (coord) {
  return coord[0];
}) …
Run Code Online (Sandbox Code Playgroud)

javascript math geometry google-maps geolocation

10
推荐指数
4
解决办法
1万
查看次数

标签 统计

geolocation ×1

geometry ×1

google-maps ×1

javascript ×1

math ×1

point ×1

polygon ×1