Java Quartz SDK Feature Query Question

860
1
05-12-2017 06:28 AM
thomasbales
Occasional Contributor

I am wondering how to return the results of a result set from a query against an online feature service. The example code for FeatureLayerQuerySample.java does work for returning a single result. Of course the reason is for the if condition. However, if I change the query to

query.setWhereClause("objectid < 10") ;

and modify the if to a while loop, I will only get one object id when I should have multiple. Additionally, the while loop never stops. What am I missing?

 while (result.iterator().hasNext()) {  // was an if statement
          // get state feature and zoom to it
          Feature feature = result.iterator().next();

         System.out.println(feature.getAttributes().get("objectid"));

  

Is there a bug? I really want to start using this SDK but I am constantly running into problems. The online query in the last java release works but is somewhat cumbersome and I have a requirement to transfer some of the data of my online feature services into a database or flat file so another application can consume my GIS table data.

Ref: https://developers.arcgis.com/java/latest/sample-code/feature-layer-query.htm

Tags (3)
0 Kudos
1 Reply
nita14
by
Occasional Contributor III

Hi Thomas,

try using the following snippet from Android SDK. I think, you might need to specify setMaxFeatures to get it working.

        QueryParameters query = new QueryParameters();
        query.setMaxFeatures(1000);
        query.setReturnGeometry(true);
        query.setGeometry(bBox);
        query.setOutSpatialReference(SpatialReference.create(102100));
        List<Graphic> list = new ArrayList<>();
        try {
            ListenableFuture<FeatureQueryResult> tableQueryResult = sft.queryFeaturesAsync(query);
            FeatureQueryResult result = tableQueryResult.get();
            for (Iterator<Feature> iter = result.iterator(); iter.hasNext(); ) {
                Feature feature = iter.next();
                Polygon poly = GeometryEngine.buffer(feature.getGeometry(), 10);
                list.add(new Graphic(poly, incSymbolPoly));
                list.add(new Graphic(feature.getGeometry(), incSymbolPoint));
                list.add(new Graphic(feature.getGeometry(), incSymbolText));
            }

            DisplayMap.getTrafficIncOverlay().getGraphics().addAll(list);

        } catch (InterruptedException | ExecutionException e) {
            Log.e("ERROR", e.getCause().getMessage());
        }

Hope this helps,

Adam

0 Kudos