我确定有关于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
更多推荐
用物化看问题
发布评论