PolygonOperation

Land Desktop Map 3D Samples

 
PolygonOperation
 
 
 

When you enter the PlygonOperation command on the Map command-line, you cause the Commands object’s PolygonOperationCommand method to be executed. This method displays What operation do you want? [Union, Intersects, Difference, Subtract]: on the command-line and waits for you to make your choice. Once it has your choice, it creates a PolygonOp object and passes your choice to the RunPolygonOp method. This method does the following:

  1. Uses the AcMapMap class to get the current AcMapMap object.
  2. Uses the AcMapMap object to get MgSelectionBase object and uses the latter to get an MgReadOnlyLayerCollection object.
    NoteYou can add polygons to the drawing and select them so that they are included in theMgReadOnlyLayerCollection object .
  3. Counts the layers in the MgReadOnlyLayerCollection object and if there are none, displays the following message on the command-line: Please select two polygons first.
  4. Gets an MgLayerBase object from the MgReadOnlyLayerCollection object.
  5. Uses the MgSelectionBase and MgLayerBase objects to generate a string containing the filter expression, “(FeatId=1) OR (FeatId=2)“.
  6. Creates an MgFeatureQueryOptions object and sets its filter to the value of the filter expression generated in the previous step.
  7. Uses the MgLayerBase object to generate an MgResourceIdentifier object identifying the feature source.
  8. Uses an MgFeatureService object and the MgResourcIdentifier, MgLayerBase, and MgFeatureQueryOptions objects to create an MgFeatureReader object containing the features in the layer.
  9. Uses an MgAgfReaderWriter object and the MgFeatureReader object to get the MgGeometry objects from the selected features and add them to a list.
  10. Throws an exception if there are less than 2 polygons in the list.
  11. Creates an MgGeometry object that contains the results of performing the requested spatial operation on the first two geometries in the list.
    NoteGiven the two polygons contained in the SAMPLES.sdf file, the geometry resulting from any of the spatial operations performed is never an MgMultiGeometry object.
  12. Creates an OSGeo.FDO.Schema.FeatureSchema object in preparation for creating a feature out of the results of the spatial operation. This is described in the topic CreateResultsFdoSchema.
  13. Uses the Schema.FeatureSchema object to create an sdf file to contain the results of the spatial operation. This is described in the topic CreateSdfFile.
  14. Creates an MgResourceIdentifier object representing the sdf file created in the previous step and connects to that file. This is described in the topic ConnectToSdfFile.
  15. Uses an MgAgfReaderWriter object and the MgGeometry object to create an MgGeometryProperty object and adds the latter to an MgPropertyCollection object.
  16. Uses the MgPropertyCollection object to create an MgInsertFeatures object and adds the latter to an MgFeatureCommandCollection object.
  17. Uses an MgFeatureService object, the MgFeatureCommandCollection object, and the MgResourceIdentifier object to add the results geometry property to the Result.sdf file.
  18. Uses the MgResourceIdentifier object to add the results geometry property as a layer to the map. This is described in the topic AddAllToMap.