0

Im trying to build an App in android Studio with the ArcGis API. While building an Adapter I noticed, that all the Attributes, except "OBJECTID", is returning null, even though they actually have content. It is also not returning every attribute. Essientially this query asks the server for features in an area of 1000m around the user. This in itself works, it creates 3 Obstacle Objects. Does anyone has an Idea how to fix this or get the other attributes using the OBJECTID? Help is much appreciated! Thanks in advance

public void queryFeatures(Location location, int radius){
    double userLat = location.getLatitude();
    double userLon = location.getLongitude();
    com.esri.arcgisruntime.geometry.Point userLocation = new com.esri.arcgisruntime.geometry.Point(userLon, userLat, SpatialReferences.getWgs84());
    LinearUnit unit = new LinearUnit(LinearUnitId.METERS);
    // Defining a circle around the users position
    Geometry bufferGeometry = GeometryEngine.bufferGeodetic(userLocation, radius, unit, Double.NaN, GeodeticCurveType.GEODESIC);

    // Defining the query paramteres
    QueryParameters queryParameters = new QueryParameters();
    queryParameters.setGeometry(bufferGeometry);
    queryParameters.setSpatialRelationship(QueryParameters.SpatialRelationship.INTERSECTS);

    // the actual query
    final ListenableFuture<FeatureQueryResult> queryResult = mServiceFeatureTable.queryFeaturesAsync(queryParameters);
    queryResult.addDoneListener(() -> {
        try {
            FeatureQueryResult result = queryResult.get();
            for (Feature feature : result){
                if (Obstacle.doesObstacleExist((ArcGISFeature) feature)) {
                    ArcGISFeature arcGISFeature = (ArcGISFeature) feature;
                    Map attr = arcGISFeature.getAttributes();
                    locationManager.addObserver(new Obstacle((ArcGISFeature) feature));
                }
            }
        } catch (Exception e) {
            Log.d("featurequery", e.getMessage());
        }
    });
}

1 Answer 1

1

I think you should add a parameter

mServiceFeatureTable.queryFeaturesAsync(queryParameters, ServiceFeatureTable.QueryFeatureFields.LOAD_ALL
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.