1

I am building a program that will search thru the GAE data store that have latitude and longtitude parameters to ge the users that are within the specific geolocation block, bellow is the code snipet:

public Iterable<Entity> GetJSONForEntitiyNearByUsingBounds(float lng,float     lat,GeoLocation.GeoLocationBoundry bound)
{
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Filter filter_min_lngt=new FilterPredicate("lng", FilterOperator.LESS_THAN, bound.lng1);
    Filter filter_max_lngt=new FilterPredicate("lng", FilterOperator.LESS_THAN, bound.lng2);
    Filter filter_min_lat=new FilterPredicate("lat", FilterOperator.GREATER_THAN, bound.lat1);
    Filter filter_max_lat=new FilterPredicate("lat", FilterOperator.LESS_THAN, bound.lat2);

    Filter filter_lng=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_min_lngt,filter_max_lngt));
    Filter filter_lat=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_min_lat,filter_max_lat));


    Filter filter=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_lng,filter_lat));

    q.setFilter(filter);

    PreparedQuery pq = datastore.prepare(q);


    return pq.asIterable();
}

the is is that when i loop the query to extract the Entity the folowing message appear java.lang.IllegalArgumentException: Only one inequality filter per query is supported. Encountered both lng and lat

can somebody help me because i don't know what is the issue

4

1 回答 1

1

请参阅查询限制:它明确指出,不等式文件管理器一次只能用于一个属性。

您的问题的解决方案是 geohashing:https ://stackoverflow.com/search?q=%5Bgoogle-app-engine%5D+geohashing

于 2012-08-07T05:23:29.230 回答