显示经度/纬度点的子集? [英] Displaying a subset of longitude/latitude points?
问题描述
我以这种方式制作了一组坐标(纬度和经度):
I have an array of coordinates (latitude and longitude) maded in this way:
[0] = "45.01234,9.12345"
[1] = "46.11111,9.12345"
[2] = "47.22222,9.98765"
[...] etc
在一个循环中,将这些坐标转换为米(UTM北移/ UTM东移),然后将这些坐标转换为屏幕上的像素(X / Y)(输出设备是iPhone)在自定义地图上绘制路线。
In a loop, convert these coordinates in meters (UTM northing / UTM easting) and after that I convert these coords in pixel (X / Y) on screen (the output device is an iPhone) to draw a route line on a custom map.
[0] = "512335.00000,502333.666666"
[...] etc
返回的像素将传递到在屏幕上绘制线的方法(模拟路线计算)。
The returning pixel are passed to a method that draw a line on screen (simulating a route calculation).
[0] = "20,30"
[1] = "21,31"
[2] = "25,40"
[...] etc
作为坐标(纬度/经度)也是很多,我需要截断纬度/经度数组,以消除未填入地图范围(屏幕上地图的可见部分)的值。
地图范围是2对经纬度坐标,左上和右下。
As coordinate (lat/lon) are too many, I need to truncate lat/lon array eliminating the values that doesn't fill in the map bound (the visible part of map on screen).
Map bounds are 2 couple of coords lat/lon, upper left, and lower right.
现在,在此数组上循环的最佳方法是什么(未排序),并检查值是否在范围内,并在除去外部值之后?
要返回只包含屏幕上可见坐标的干净数组吗?
Now, what is the best way to loop on this array (NOT SORTED) and check if a value is or not in bound and after remove the value that is outside?
To return a clean array that contains only the coords visible on screen?
注意:coords数组是一个很大的数组。 4000/5000个项目。
此方法应在每次拖动或缩放时循环播放。
Note: the coords array is a very big array. 4000/5000 Couple of items.
This is a method that should be looped every drag or zoom.
如何在以下位置优化搜索和控件这个数组?
How can I optimize search and controls in this array?
推荐答案
我建议将其分为几个步骤:
I'd suggest breaking this into several steps:
- 在新坐标系中将每个经度/纬度对转换为米。
- 创建一个包含所有点的kd-tree数据结构集合。这样,您就可以非常有效地查询位于给定矩形范围内的点。
- 每当视口发生变化时,请在kd树中找到将在该矩形中显示的所有点。 / li>
- 要显示点,请遍历要显示的点集并显示每个点。
这篇关于显示经度/纬度点的子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!