forrestkaye

Create Feature for offline Runtime Geodatabase

Discussion created by forrestkaye on Jun 3, 2014
Latest reply on Jun 5, 2014 by forrestkaye
I am trying to create a point feature and add it to an offline runtime Geodatabase.  I have followed the "Offline editor" sample to the best of my ability but am still having trouble figuring it out.  The offline editor sample seemed pretty complex and does not seem to work all that well itself.

My approach was to use the "Create Runtime Geodatabase" sample and add in a map touch listener that added a point on each tap to the wildfire.geodatabase. 

I've worked through what seems like should work but when I try to verify that I've added a feature by using the queries "gdbFeatureTable.getNumberOfFeatures()" and "gdbFeatureTable.getAddedFeaturesCount()" they never change.


Do I need to do something else to do the GeodatabaseFeatureTable besides "addFeature(feature)" like .Save() or something?

Will the feature be added if it is blank? Since I'm only using gdbFeatureTable.createNewFeature() instead of gdbFeatureTable.createFeatureWithTemplate().  Are there possibly requirements not being met by my blank feature that is then being tossed out on add?

My goal is to just get something rolling and build up in complexity.

Here is my code:


private void handleTap(final MotionEvent e) {

    TextView pTextView1 = (TextView) findViewById(R.id.editText1);
    
    localGdbFilePath = createGeodatabaseFilePath();
    
 Geodatabase localGdb = null;
    try {
      localGdb = new Geodatabase(localGdbFilePath);
    } catch (FileNotFoundException a) {
      a.printStackTrace();
    }
    
    for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseTables()) {
        if (gdbFeatureTable.hasGeometry())
         
         if (gdbFeatureTable.getGeometryType() == Geometry.Type.POINT ){ 
          //Checking on status of table...
          pTextView1.setText(gdbFeatureTable.getGeometryType() + " " + gdbFeatureTable.isEditable() + " " + gdbFeatureTable.getTableName() + " " + gdbFeatureTable.getEditableAttributeFields());

          //Point point = map.toMapPoint(new Point(e.getX(), e.getY()));
          Double X = mMapView.getCenter().getX();
          Double Y = mMapView.getCenter().getY();
          
          Point point = new Point(X,Y);
                        //not using the geometry at this point...

          
          
          Feature pFeature2 = null;
    try {
     pFeature2 = gdbFeatureTable.createNewFeature();
    } catch (TableException e1) {

     e1.printStackTrace();
    }
          

           try {
            gdbFeatureTable.addFeature(pFeature2);
     } catch (TableException e1) {

      e1.printStackTrace();
     }
          }
      }
     }


Any insight is much appreciated, Thanks!

Outcomes