开发者

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

Bit of a weird one this. I'm rendering datasets on开发者_JAVA百科 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.

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.

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. 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. Also, increase the radius after each loop iteration, probably by using a number and multiplying it by the loop index. (i.e. you could change radius to 50*i).

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜