AnsweredAssumed Answered

How to use QueryParameters to get features contained in an area?

Question asked by durand.gael on Sep 16, 2017
Latest reply on Sep 20, 2017 by ANohe-esristaff

I would like to select features according to a QueryParameters object.

I don't understand why I get all features when I call queryFeaturesAsync whereas I expect a subset of it. 

I tried in vain to change the value of SpatialRelationship, set an envelope or set max features.

 

Point gps = new Point(-1.640235, 48.127568, SpatialReferences.getWgs84());
final Polygon searchGeometry = GeometryEngine.buffer(gps, 500);

QueryParameters queryParams = new QueryParameters();
queryParams.setGeometry(searchGeometry);
queryParams.setMaxFeatures(500);
queryParams.setOutSpatialReference(SpatialReferences.getWgs84());
queryParams.setSpatialRelationship(QueryParameters.SpatialRelationship.CONTAINS);

final ListenableFuture<FeatureQueryResult> results = geoDbTable.queryFeaturesAsync(queryParams);

results.addDoneListener(new Runnable() {

@Override public void run() {
try {
final FeatureQueryResult fqr = results.get();

List result = new ArrayList();
int counter = 0;
while (fqr.iterator().hasNext()){
counter+=1;
if (counter%100 == 0) {
Log.d("FeatureQueryResult", Long.toString(counter));
}
}
}
}

Outcomes