本文介绍了将经度和纬度值转换为自定义大小的网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个Java程序,该程序将一组经/纬度坐标分类为具有自定义大小的特定矩形,因此实际上,将地球表面映射到自定义网格中并能够识别出哪个矩形/多边形关键所在.

I am making a java program that classifies a set of lat/lng coordinates to a specific rectangle of a custom size, so in effect, map the surface of the earth into a custom grid and be able to identify what rectangle/ polygon a point lies in.

我正在研究的方法是使用地图投影(可能是Mercator).

The way to do this I am looking into is by using a map projection (possibly Mercator).

例如,假设我要将长形/经度分类为100m x 100m的正方形",

For example, assuming I want to classify a long/lat into 'squares' of 100m x 100m,

44.727549、10.419704和44.727572、10.420460将分类为X区域

44.727549, 10.419704 and 44.727572, 10.420460 would classify to area X

44.732496、10.528092和44.732999、10.529465将分类为区域Y,因为它们相距100m以内.(假设它们位于相同的边界内)

44.732496, 10.528092 and 44.732999, 10.529465 would classify to area Y as they are within 100m apart.(this assumes they lie within the same boundary of course)

我不太担心变形,因为我不需要显示地图,但是我确实需要能够知道一组坐标属于哪个多边形.

Im not too worried about distortion as I will not need to display the map, but I do need to be able to tell what polygon a set of coordinates belong to.

这可能吗?任何建议欢迎.谢谢.

Is this possible? Any suggestions welcome. Thanks.

修改

省略两极的投影也是可以接受的损耗

Omitting projection of the poles is also an acceptable loss

推荐答案

这是我的最终解决方案(在PHP中),为每个100m的正方形创建一个bin:

Here is my final solution (in PHP), creates a bin for every square 100m :

function get_static_pointer_table_id($lat, $lng)
{
    $earth_circumference = 40000; // km

    $lat_bin = round($lat / 0.0009);
    $lng_length = $earth_circumference * cos(deg2rad($lat));
    $number_of_bins_on_lng = $lng_length * 10;
    $lng_bin = round($number_of_bins_on_lng * $lng / 360);
    //the 'bin' unique identifier
    return $lat_bin . "_" . $lng_bin;

}

这篇关于将经度和纬度值转换为自定义大小的网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 04:19