算法,用于显示经度/纬度点的一个子集? [英] Algorithm for displaying a subset of longitude/latitude points?

查看:189
本文介绍了算法,用于显示经度/纬度点的一个子集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


今天来了一个小问题。


Today come out a little problem.

我已经以这种方式坐标(纬度和经度)的阵列maded:

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东向),之后我将这些COORDS像素(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对夫妇的COORDS纬度/经度,左上角和右下角。

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.

现在,什么是循环这个数组(不排序)的最佳方法,检查是否值或者不绑定后删除超出价值?
要返回一个干净的数组,其中包含唯一可见的COORDS在屏幕上?

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.

任何人有一个想法,以优化搜索和控件数组?

Anyone have an idea to optimize search and controls in this array?

千恩万谢,
A

many thanks,
A

推荐答案

我建议打破这一成几个步骤:

I'd suggest breaking this into several steps:

  1. 在每一个经度/纬度对转换为一对米的新的坐标系中
  2. 创建一个kd树数据结构来保存所有点的集合。这可以让你有效地查询这非常有效点都在一个给定的矩形范围内。
  3. 每当视区改变,发现所有的点在将要显示在该矩形的kd树。
  4. 要显示的点,迭代将要显示的点的集合,并显示他们每个人。

这篇关于算法,用于显示经度/纬度点的一个子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆