简体   繁体   English

Android Maps utils上的Quadtree

[英]Quadtree on android maps utils

I'm developing a android application with google maps v2 that draw polygons on the google maps. 我正在使用google maps v2开发一个android应用程序,以便在google maps上绘制多边形。 But now i have to identify a click on a certain polygon and popup a window. 但是现在我必须确定在某个多边形上的单击并弹出一个窗口。

I found this useful library on github 我在github上发现了这个有用的库

This library has the method containsLocation implemented. 该库已实现了containsLocation方法。 This method receives a LatLng (from click on the map) and a List (the polygon). 此方法接收LatLng(在地图上单击)和List(多边形)。 This is fine but if i have 1 million polygon in the map i cant iterate all and test if a certain LatLng belongs to a certain Polygon. 很好,但是如果我在地图上有100万个多边形,则无法全部迭代,并测试某个LatLng是否属于某个多边形。 I remember that i can use a quadtree to get more performance and this library also implements a quadtree but it uses point. 我记得我可以使用四叉树来获得更高的性能,该库也实现了四叉树,但它使用了点。 What is the best way of doing this? 最好的方法是什么? May i have to reimplement this quadtree for a quadtree of LatLng ? 我可以为LatLng的四叉树重新实现此四叉树吗? Or in each click i have to convert this click to a point and search on a point quadtree? 还是在每次单击中我都必须将此点击转换为一个点并在一个点四叉树上进行搜索?

Regards 问候

you cannot use a Point- Quadtree, you need an Object-Quadtree for your Polygons. 您不能使用点四叉树,而需要多边形的对象四叉树。 An object quadree uses the bounding box of the polygon or any object for adding into the tree. 对象四边形使用多边形或任何对象的边界框添加到树中。

you dont need to consider latLong, use x,y with x= longitude, and y = Latitude. 您无需考虑latLong,使用x = y(x =经度)和y =纬度。

Consider reading Hanan Sammet: Foundations of multidimensional data structures. 考虑阅读Hanan Sammet:多维数据结构的基础。

I think you need to implement a quadtree that stores the polygons, then query the tree to see which polygon (if any) contains the LatLng. 我认为您需要实现一个存储多边形的四叉树,然后查询树以查看哪个多边形(如果有)包含LatLng。 If you search around I'm sure you can find a decent implementation. 如果您四处搜索,我相信您会找到一个不错的实现。

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

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