如何查询“附近”的实体 与 Google App Engine 中的 GeoPt 属性有关吗?
我应该如何创建一个 GQL 查询,根据 GeoPt 属性返回最近的实体(距离我当前的位置)? 我是否应该创建一个“距离”函数来计算一组距离相当近的实体?
提前致谢!
How should I create a GQL query that returns the nearest entities (from my current location) based on their GeoPt property? Should I just created a 'distance' function that calculates for a set of entities with a reasonably close distance?
Thanks ahead of time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将 App Engine 中的位置存储在 Quadtree 结构中。
以下是如何完成此操作的描述:Google App Engine 上的地理查询
You could store the locations in App Engine in a Quadtree structure.
Here's one description of how it would be done: Geographic Queries on Google App Engine
我想我会取得某种挖掘成就,但它是:
我正在寻找这个问题的解决方案,并遇到了谷歌的官方文档:
https://cloud.google.com/appengine/docs/java/search /query_strings#Java_Queries_on_geopoint_fields
我真的认为谷歌应该对此发出更多的声音。 我觉得很奇怪,他们有关于 Python 的课程来做同样的事情,但没有说明如何在 Java 上做同样的事情。
I guess I'm going to some kind of digger achievement, but here it is:
I was looking for a solution for this issue and came across this Google's oficial docs:
https://cloud.google.com/appengine/docs/java/search/query_strings#Java_Queries_on_geopoint_fields
I really think that Google should have made some more noise about this. I find it weird that they have a lesson on Python for doing the same thing but says nothing on how to do it for Java.
geohash 在不同的哈希值中设置非常接近的点,因此应该首选另一层或下一层。 您可以进行半径、二次内部/外部形状测试甚至任何数学形状,并测试该点是否在我们的外部形状内。
geohash set very close points in different hashes so another or next layer should be preferred. you can make a radius, quadratic inside/outside shape test or even any mathematical shape and test whether the point is within our outside the shape.
App Engine 不会特殊对待 GeoPt 属性 - 它没有内置的空间索引。 然而,有许多第三方库添加了对空间索引的支持。 最好的(在我看来)是 geomodel。
App Engine doesn't treat GeoPt properties specially - it has no built in spatial indexing. There are a number of third-party libraries that add support for spatial indexing, however. The best one (in my opinion) being geomodel.