用物化看问题 [英] Querying Geopt with Objectify
问题描述
我确定有关于GeoPt字段的@Index注释。
然而,下面的语句似乎并不奏效$ / b>
ofy()。load )
.type(GeoStat.class)
.filter(geoPt.latitude> =,neLat)
.limit(10);
是否可以在Objectify中查询GeoPt字段?
好消息是,最近google增加了直接对数据存储区执行地理空间查询的功能: google.com/appengine/docs/java/datastore/geosearchrel =nofollow> https://cloud.google.com/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:
https://cloud.google.com/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
这篇关于用物化看问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!