Select to view content in your preferred language

unable to add/save new feature point to mobile cache on ArcMobile 10.

4945
10
Jump to solution
11-21-2012 01:06 PM
KarenPinkerton
Deactivated User
WHAT WE NEED
Guidance on how to identify the causes of the issues we are having adding a new point to the layer. Is it a process problem?  Is it a code problem?  If so, who can help us identify the failure points?

The full source code is available if it would be helpful for you to decipher the issue.

We have created our project in Visual Studio 2008 .net 2.0.
What we can do:
- Run the project in Debug mode through Windows Mobile 6 classic Emulator
- Load a MobileCache of 6 Feature Layers ??? 3 editable with existing feature points & 3 as background data
- ZoomIn, ZoomOut, Pan, IdentifyFeature on map using toolbar control
- Load Existing Feature Data to screens when using the IdentifyFeature toolbar function
What we can???t do (identified so far):
- Adding new Feature Point
- How we are attempting this:
- Click toolbar button
- Click map to add new feature
- Run code that we have sourced from multiple different online examples in an attempt to add a new point ??? we have had several different stages of errors thrown from the ???The geometry is empty???, to completely destroying the MobileCache

Example of current relevant code
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
switch (toolBar1.Buttons.IndexOf(e.Button))
{
  case 0:
   MapMain.CurrentMapAction = zoomInMapAction1;
   break;
  case 1:
   MapMain.CurrentMapAction = zoomOutMapAction1;
   break;
  case 2:
   MapMain.CurrentMapAction = panMapAction1;
   break;
  case 3:
   MapMain.CurrentMapAction = null;
   break;
  case 4:
   MapMain.CurrentMapAction = addVertexSketchTool1;
   break;
  default:
   break;
}
}
private void MapMain_MouseDown(object sender, ESRI.ArcGIS.Mobile.MapMouseEventArgs e)
{
if (MapMain.CurrentMapAction == addVertexSketchTool1)
{
  AddNewFeaturePoint();
}
}
private void AddNewFeaturePoint()
{
sketchGraphicLayer1.Geometry = new ESRI.ArcGIS.Mobile.Geometries.Point();

FeatureLayer locationLayer = mobileCache1.Layers["Location"] as FeatureLayer;
using (FeatureDataTable locationTable = locationLayer.GetDataTable())
{
  DataRow locationRow = locationTable.NewRow();
  locationRow.BeginEdit();
  locationRow["LocationID"] = Guid.NewGuid();
  locationRow[locationLayer.GeometryColumnIndex] = sketchGraphicLayer1.Geometry;
  locationRow.EndEdit();
  locationTable.Rows.Add(locationRow);
  locationTable.SaveInFeatureLayer();

  DataRow[] errors = locationTable.GetErrors();
  for (int i = 0; i < errors.Length; i++)
  {
   if (errors.HasErrors)
   {
    DataColumn[] colArr = errors.GetColumnsInError();
    for (int j = 0; j < colArr.Length; j++)
    {
     MessageBox.Show(string.Format("Error '{0}' in column '{1}'.", errors.GetColumnError(colArr), colArr.ColumnName));
    }
   }
  }
}
}
0 Kudos
10 Replies
Andréde_Mattos_Ferraz
Deactivated User
Solution for me:

//this im chaging position of first record
fdt.Rows[0][fdt.GeometryColumnIndex] = newPoint; //fdt - featureDataTable
fdt.SaveInFeatureSource();
fdt.AcceptChanges();
0 Kudos