用物化看问题

编程入门 行业动态 更新时间:2024-10-22 18:35:25
本文介绍了用物化看问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我确定有关于GeoPt字段的@Index注释。

然而,下面的语句似乎并不奏效$ / b>

ofy()。load ) .type(GeoStat.class) .filter(geoPt.latitude> =,neLat) .limit(10);

是否可以在Objectify中查询GeoPt字段?

GeoPt 。如果您希望在纬度上进行查询,请单独编制索引(可能会在@OnSave方法中写入专用字段)。但是,如果您尝试执行地理空间查询(即,包含在矩形中),请注意您不能执行两个不等式过滤器(边界内的纬度,边界内的经度)。

好消息是,最近google增加了直接对数据存储区执行地理空间查询的功能: google/appengine/docs/java/datastore/geosearchrel =nofollow> cloud.google/appengine/docs/java/datastore/geosearch

GeoPt center = new GeoPt(latitude,longitude); double radius = valueInMeters; Filter f = new StContainsFilter(geoPt,new Circle(center,radius)); ofy()。load()。type(GeoStat.class).filter(f);

请注意,数据存储的地理空间搜索目前是Alpha版本,对于邀请已关闭。因此,尽管您可以使地理空间搜索在本地工作,但它仍然不能用于生产。请参阅: Google App Engine> GeoSpatial Alpha邀请

I am having the hardest time querying a GeoPt field with Objectify.

I made sure there's an @Index annotation about the GeoPt field.

However, the statement below doesn't seem to work

ofy().load() .type(GeoStat.class) .filter("geoPt.latitude >=", neLat) .limit(10);

Is querying GeoPt field possible in Objectify?

解决方案

The datastore does not support querying a GeoPt in this way. If you wish to query on latitude, index it separately (possibly writing to a private field in an @OnSave method). However, if you're trying to perform a geospatial query (ie, contained in a rectangle), note that you cannot perform two inequality filters (latitude in bounds, longitude in bounds).

The good news is that very recently google added the ability to perform geospatial queries directly to the datastore:

cloud.google/appengine/docs/java/datastore/geosearch

GeoPt center = new GeoPt(latitude, longitude); double radius = valueInMeters; Filter f = new StContainsFilter("geoPt", new Circle(center, radius)); ofy().load().type(GeoStat.class).filter(f);

Note, that geospatial search for datastore is currently an Alpha release, that is closed for invitations. So, while you can get the geospatial search to work locally, it still cannot be used in production. See: Google App Engine › GeoSpatial Alpha Invite

更多推荐

用物化看问题

本文发布于:2023-10-15 02:50:59,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!