简体   繁体   English

对于相同位置的点,经纬度略有变化

[英]slight changes in long lat for varations of point with the same location

Bit of a weird one this. 这有点奇怪。 I'm rendering datasets on a map and need to split out points that have exactly the same long and lat. 我正在地图上绘制数据集,需要分割长和纬度完全相同的点。 I had the idea of grouping my dataset by long and lat and where they are the same adjusting slightly so that they are visible as seperate entities on the map - rather than overlapping. 我的想法是将我的数据集按l​​ong和lat分组,它们在相同的地方稍有调整,以便它们在地图上显示为单独的实体-而不是重叠。

I'm using linq to group them and then enumerating my grouped items and I'd like to spiral the adjusted points around the orginal point (this is a requirement as I may have a few hundred points that are the same geographically) so that they spread out from the original point. 我正在使用linq将它们分组,然后枚举分组的项目,我想将调整后的点绕原点盘旋(这是一个要求,因为我可能有数百个地理上相同的点),以便它们从原点散开。

Does anyone know of a simple calculation i can add to my loop to adjust the items in this manner. 有谁知道一个简单的计算,我可以添加到我的循环中,以这种方式调整项目。

Thanks, 谢谢,

The math behind this is pretty simple. 这背后的数学非常简单。 A circle can be represented by the sine function in the x-axis and the cosine function in the y-axis. 圆可以通过x轴上的正弦函数和y轴上的余弦函数表示。 Here's some pseudo-code: 这是一些伪代码:

int num = OverlappingPoints.Length;
for(int i = 0; i < num; ++i)
{
    int radius = 50;

    // using 2*pi because most math functions use radians... change 2*pi to 360 if your math library uses 360 degrees instead of 2*pi radians to represent a circle.
    Map.Plot(OverlappingPoints[i].Latitude + radius*sin(2*pi*i/num),
        OverlappingPoints[i].Latitude + radius*cos(2*pi*i/num));
}

That pseudo-code, if properly implemented, will draw the points out in a circle around the original point. 如果正确实现,该伪代码将在原始点周围画出一个圆。 Change the radius multiplier to the sine and cosine functions if you want to increase the radius of the circle. 如果要增加圆的半径,请将半径乘数更改为正弦和余弦函数。 If you want the points to spiral out instead of making a circle , choose a number of points per circle revolution and replace num with that number in the sin/cos functions. 如果要使点逐渐成螺旋形而不是画圆 ,请在每转一圈中选择一个点数,然后在sin / cos函数中将num替换为该数。 Also, increase the radius after each loop iteration, probably by using a number and multiplying it by the loop index. 另外,在每次循环迭代之后,可以增加半径,方法可能是使用数字并将其乘以循环索引。 (ie you could change radius to 50*i ). (即,您可以将radius更改为50*i )。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM