Points Attribute Editing

657
3
12-19-2013 04:13 PM
DaniSetiawan
New Contributor
Hi Everyone,

Actually I have asked this question before at this thread. But till now I still not get the solution how to edit the attribute of point, the solution at the thread above is working. But it can't apply in my application, it impossible to change hundreds of thousands of point to polygon, waste a lot of time.

Is there anyone of you face same problem?
Is there anyone of you solve this problem?
What should I must do?
Please help

Regards
0 Kudos
3 Replies
JasonKnisley
Occasional Contributor
You definitely don't need to convert anything to polygons to do this.

If you are using an ArcGISFeatureLayer then what you want to do it set an OnSingleTapListener on your MapView, and then in your OnSingleTap() method call featureLayer.getGraphicIDs(x, y, tolerance) where the tolerance is a dp value. Increasing the tolerance will increase the radius around the tapped point for which graphic ids will be returned. In my experience 15 is a good value, but depending on the scale the map is at, higher or lower values may be appropriate. The results are sorted, however, so the id at index 0 will be the graphic closest to the tapped point. If you are getting an empty array returned then you need to increase your tolerance parameter.

If you are using an ArcGISDynamicMapServiceLayer then the concept is similar: it's all about setting an appropriate tolerance around the point. In this case you'll be using an IdentifyTask to get a feature from the server, and so in your IdentifyParameters you'll want to call setTolerance(tolerance) before executing your IdentifyTask.
0 Kudos
DaniSetiawan
New Contributor
Hi Jason Knisley,

Thank you for respond my question, I have called the featureLayer.getGraphicIDs(x, y, tolerance) method but I get this error on logcat
12-21 22:38:59.498: E/AndroidRuntime(3011): FATAL EXCEPTION: main
12-21 22:38:59.498: E/AndroidRuntime(3011): java.lang.IllegalStateException: Graphics layer is not bounded to a map!
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.android.map.GraphicsLayer.nativeGetGraphicsAt(Native Method)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.android.map.GraphicsLayer.getGraphicIDs(Unknown Source)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.android.map.GraphicsLayer.getGraphicIDs(Unknown Source)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.arcgis.android.samples.attributeeditor.AttributeEditorActivity$2.onSingleTap(AttributeEditorActivity.java:148)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.android.map.MapOnTouchListener.onSingleTap(Unknown Source)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.esri.android.map.MapGestureDetector$a.onSingleTapConfirmed(Unknown Source)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:281)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at android.os.Looper.loop(Looper.java:137)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at android.app.ActivityThread.main(ActivityThread.java:4514)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at java.lang.reflect.Method.invokeNative(Native Method)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at java.lang.reflect.Method.invoke(Method.java:511)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-21 22:38:59.498: E/AndroidRuntime(3011):  at dalvik.system.NativeStart.main(Native Method)


I'm not sure where to put the featureLayer.getGraphicIDs(x, y, tolerance) method, here my code at line 148 based error on logcat above
      public void onSingleTap(float x, float y) {

        // convert event into screen click
        pointClicked = mapView.toMapPoint(x, y);

        // build a query to select the clicked feature
        Query query = new Query();
        query.setOutFields(new String[] { "*" });
        query.setSpatialRelationship(SpatialRelationship.INTERSECTS);
        query.setGeometry(pointClicked);
        query.setInSpatialReference(mapView.getSpatialReference());

        // call the select features method and implement the callbacklistener
        featureLayer.getGraphicIDs(x, y, 15);
        
        featureLayer.selectFeatures(query, ArcGISFeatureLayer.SELECTION_METHOD.NEW, new CallbackListener<FeatureSet>() {

          // handle any errors
          public void onError(Throwable e) {

            Log.d(TAG, "Select Features Error" + e.getLocalizedMessage());

          }

          public void onCallback(FeatureSet queryResults) {

            if (queryResults.getGraphics().length > 0) {

              Log.d(TAG, "Feature found id=" + queryResults.getGraphics()[0].getAttributeValue(featureLayer.getObjectIdField()));

              // set new data and notify adapter that data has changed
              listAdapter.setFeatureSet(queryResults);
              listAdapter.notifyDataSetChanged();

              // This callback is not run in the main UI thread. All GUI
              // related events must run in the UI thread,
              // therefore use the Activity.runOnUiThread() method. See
              // http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)
              // for more information.
              AttributeEditorActivity.this.runOnUiThread(new Runnable() {

                public void run() {

                  // show the editor dialog.
                  showDialog(ATTRIBUTE_EDITOR_DIALOG_ID);

                }
              });
            }
          }
        });
      }


am I wrong?
0 Kudos
ErwinSoekianto
Esri Regular Contributor
a workaround, please use buffer for the geometry,

=============
Query query = new Query();
        query.setOutFields(new String[] { "*" });
        query.setSpatialRelationship(SpatialRelationship.INTERSECTS);
        Geometry geom=(GeometryEngine.buffer(pointClicked,mapView.getSpatialReference(),100,null));
        query.setGeometry(geom);
        query.setInSpatialReference(mapView.getSpatialReference());
=============

Please note that the buffer number can be adjusted, I purposely make it big to make sure that we can get the query result back.
0 Kudos