ClassifyManholes

Land Desktop Map 3D Samples

 
ClassifyManholes
 
 
 

The ClassifyManholes command activates the Classify entry point method of the Commands class. This entry point calls the DoWork method of the Implement class which handles the entire operation of the sample. DoWork does the following:

  1. Get the base Layer object.
  2. Calls PromptUserToSelectRoads. This function prompts the user to select features from the document. It also prompts the user to type in a double which represents the buffer distance. These values are returned.
  3. Checks the return values of PromptUserToSelectRoads. If the user did not select any features or if the selected features come from more than one layer, the sample ends.
  4. DoWork creates and sets a filter by calling the MgSelectionBase.GenerateFilter and MgFeatureQueryOptions.SetFilter API methods.
  5. Calls the DoBuffer function. This function selects all features in the specified layer according to the filter that was just created. It goes to the layer class definition and gets the property names for all properties. It then loops through all the selected features, extracting the properties for each feature and placing them in a collection of type MgBatchPropertyCollection. The collection is then returned.
  6. Extracts the schema and feature class name by using the AcMapLayer.FeatureClassName API property.
  7. Calls the SaveAndAddBufferLayer function. It first creates an FDO feature class object using the utility method CreateFdoFeatureClass. It creates a new schema structure and assigns the FDO feature class to the schema. It then calls the utility method CreateSdfFile to create the SDF file with the specified schema. SaveAndAddBufferLayer then connects to the SDF file using the ConnectToSdfFile utility method. Each of the property sets are then examined and each of the geometry properties are renamed to “BufferedRoadsGeometry”. It then uses a FeatureService object (which it obtains using the utility class) to run a MgFeatureCommandCollection command to insert all of the FDO feature classes into the feature source (the SDF file). The feature classes in the SDF file then read and drawn into the map pane into a new layer. A reference to this new layer is obtained, and it is made visible. The reference to the SDF file is returned.
  8. Calls FindManholesInBuffer to find the manholes that intersect with buffer geometry and then upload those manholes as point features to a SDF file. Using the TransactionManager object for the current document’s database, it loops through all entities in the database for manholes. The geometry of each manhole is modified by the GetCircleGeometry helper function, which creates a circle-type shape out of two arcs. Using the GeometryIntersects helper function, each manhole is also compared to every other feature to see if it intersects. If so, its Id is added a collection of object Id’s, which is then returned.
  9. Calls UploadManholes to create a SDF file for manholes and save all manhole information to it. First, UploadManholes gets a reference to the database transaction manager. It then gets the table of all manhole features, and creates a SDF file from the table schema and data using the function CreateManholeSDF. UploadManholes then loops through all the manhole features.
  10. UploadManholes calls the function UploadManhole for each manhole feature. Using the database transaction manager, it obtains the Circle object representing the manhole, extracts the position, and creates a new property containing the position information. It then loops through all the column definitions of the manhole table, creates FDO property equivalents for each, and adds them to the manhole feature object. Finally, it adds the position property created earlier to the feature, which is then returned.
  11. UploadManholes adds each of the features returned by UploadManhole to a MgBatchPropertyCollection collection of features. It then uses a FeatureService object (which it obtains using the utility class) to run a MgFeatureCommandCollection command to insert all of the FDO feature classes into the feature source (the SDF file). The features are added to the document using the utility function AddAllToMap. UploadManholes then obtains a reference to the layer containing the manhole features and selected and highlights all manholes.