Editing environment and workflow

The editing environment for a Mobile client application is impacted by a variety of factors, including the geodatabase, the SDE setup, the map compilation, the options used when the service is published, and how the client application is designed and built. This document will focus on the factors within the client development, please see the related documents for details on how to setup and publish your mobile service. Be aware that the geodatabase design and setup will have a major impact on the editing environment since it controls what is editable. When the mobile map document is created it defines what layers are used, the spatial reference being used, the map extent, and the visibility of the layers. Publishing the map document as a mobile service, allows the mobile clients to connect and make edits, but the settings used when publishing can control who can access the service and limit the client applications.

Editing environment in the client application includes the featurelayers to edit, the snapping environment, the input method, the type of edit feature, the type of edit operation, and quality checks.

If you are creating a new feature, the workflow will look like the following steps. To set the featurelayer to be edited you must first open the mobilecache to ensure the layers to be edited are there and editable. Then it is time to set the snapping environment, and create the geometry for the new feature using the sketch graphic and mapaction. After the geometry is created, a new row is added to the feature datatable and the attributes are set. The final step will be to post the new data back to the server, and perform some quality checks.

As all of these steps can have many options and variations, there is much more information found in the related documents. These editing environments are just the minimum setting required for a basic editing operation, and should be further refined for a production application.

Steps:
  1. Set the mobileCache properties for the application to access the data.

    mobileCache1.StoragePath = "C:\\data" + "\\MapCache";
    mobileCache1.Open();
    map1.MapLayers.AddRange(mobileCache1);
    

  2. Get the layers that can be edited from the application.

    foreach (FeatureLayer flayer in mobileCache1.Layers);
    {
    //make the first editable layer from the local cache our target
    if (flayer.AllowNew)
      FeatureLayer editlayer = flayer ;
    }
    

  3. Create the snapping agent for the editlayer, set its properties.

    SnappingEnvironment snapEnv;
    snapEnv = mMap.SnappingEnvironment;
    SnappingAgent snapAgent = new SnappingAgent(flayer.MakeMapLayer());
    snapAgent.SnappingType = SnappingType.Edge;
    snapAgent.Active = true;
    snapEnv.SnappingAgents.Add(snapAgent);
    snapEnv.Tolerance = flayer.GetExtent().Width / 10; 
    snapEnv.ShowSegmentLength = true;
    snapEnv.ShowToleranceRadius = true;
    snapEnv.Active = true;
    

  4. Perform your editing operation, which can be adding, modifying, deleting a feature, or updating the feature attributes. The code below shows how to create a simple polygon feature.

    sketchGraphicLayer1.Geometry = new Polygon();
    // sets map action to add vertex sketch
    map1.CurrentMapAction = addVertexSketchTool1;
    FeatureDataTable fTable = editlayer.GetDataTable();
    // creates a new row
    DataRow editedFeature = fTable.NewRow();
    //sets the new geometry to the feature layer data table
    fTable.Rows.Add(editedFeature);         
    //sets the new geometry to the geometry field
    editedFeature[editlayer.GeometryColumnIndex] = sketchGraphicLayer1.Geometry;
    // updates the feature layer data table
    fTable.SaveInFeatureLayer();
    

  5. Post the changes made back to the server using the mobile Connection.

    FeatureLayerSyncAgent flSyncAgent = new FeatureLayerSyncAgent( editlayer,m_SyncAgent.MapDocumentConnection);
    if (flSyncAgent.IsValid)
      {
      flSyncAgent.SynchronizationDirection = SyncDirection.UploadOnly;
      flSyncAgent.Synchronize();
      }
    


9/20/2011