提问人:Rolf W. 提问时间:8/19/2019 最后编辑:Rolf W. 更新时间:8/20/2019 访问量:521
将地图区域划分为给定半径的重叠圆
Divide map area into overlapping circles of given radius
问:
我正在尝试将给定半径的地图区域与给定坐标划分为另一个给定半径的较小重叠地图,确保整个原始地图被较小的地图覆盖,同时最大限度地减少重叠。
我需要找到覆盖整个原始区域的所有较小地图的中心纬度/经度。较小地图的总面积可能会稍加扩展,以确保覆盖整个表面。
我尝试了各种方法,直到我意识到这是一个复杂的问题,我的数学似乎是不够的。
代码示例
public class Main {
public static void main(String[] args) {
// ==== Parameters =====
/* These are just example values; Should work with any sensible input */
LatLng outerAreaCenter = new LatLng(40.689259, -74.044538);
double outerAreaRadiusInMeters = 1000;
double divisionsRadiusInMeters = 125;
// ==== Divide area =====
List<LatLng> divisionCenters;
divisionCenters = divideArea(outerAreaCenter, outerAreaRadiusInMeters, divisionsRadiusInMeters);
// ==== Draw large area =====
drawCircleOnMap(outerAreaCenter, outerAreaRadiusInMeters);
// ==== Draw division circles within large area =====
/* These circles should cover the entire surface of the outer area, and
* may extend a little bit outside of the outer circle if needed */
for (LatLng divisionCenter : divisionCenters) {
drawCircleOnMap(divisionCenter, divisionsRadiusInMeters);
}
}
/**
* Divides a large area into divisions/smaller areas that, together, cover the entire surface of the large area with minimal overlap.
*
* @param outerAreaCenter the center coordinates of the area that needs to be divided
* @param outerAreaRadiusInMeter the radius of the area that needs to be divided
* @param divisionsRadiusInMeter the maximum radius of each division/smaller area
*
* @return a list of center coordinates for each of the smaller areas that, which can be used with {@param divisionsRadiusInMeter} to make new areas that together cover the entire large area surface
*/
private static List<LatLng> divideArea(LatLng outerAreaCenter, double outerAreaRadiusInMeter, double divisionsRadiusInMeter) {
// ==== Check preconditions =====
if (divisionsRadiusInMeter > outerAreaRadiusInMeter) { throw new IllegalArgumentException("Divisions radius cannot be larger than radius of outer area."); }
// ==== Calculate center lat/lng for each division =====
/* This is what my question is about. */
}
private static void drawCircleOnMap(LatLng circleCenter, double radiusInMeters) {
/* Some code to draw this circle on a map (not relevant to the question) */
// To visualize points, add a new layer on https://mapmakerapp.com by pasting the console output
System.out.println(circleCenter.latitude + "," + circleCenter.longitude + ",,#FF0000");
}
private static class LatLng {
private final double latitude;
private final double longitude;
private LatLng(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
}
}
问题
如何计算每个分区区域的中心纬度/经度,确保整个外部区域覆盖最小重叠?我基本上是在上面的代码示例中寻找方法体。divideArea(LatLng outerAreaCenter, double outerAreaRadiusInMeter, double divisionsRadiusInMeter)
注意
为了使重叠最小化,划分区域的半径可能也应是输出。如果是这种情况,则参数应为 .divisionsRadiusInMeters
divisionsMaxRadiusInMeters
编辑
按照 Avi 的建议,我添加了一个代码示例并澄清了问题。
答: 暂无答案
下一个:该算法如何按预期工作?尽管溢出
评论
divisionsRadiusInMeters
divisionsMaxRadiusInMeters
r(n)