Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private void createContainer()
  2. {
  3.    // Get references to required classes:
  4.    // -- m_stationNamesTbl holds a reference to the table with all station names
  5.    // -- m_pipesFC holds a reference to the pipes feature class
  6.    // -- m_containerFC holds a reference to the container feature class
  7.    if (InitClasses() == false)
  8.       return;
  9.  
  10.    // Start the edit operation.. assumes we're already editing
  11.    m_pEditor.StartOperation();
  12.  
  13.    // Get a cursor on the station names class and iterate through all stations
  14.    IQueryFilter pStationQF = new QueryFilter();
  15.    ICursor pStationCur = m_stationNamesTbl.Search(pStationQF, true);
  16.    IRow pStationRow = pStationCur.NextRow();
  17.    while (pStationRow != null)
  18.    {
  19.       string stationName = Convert.ToString(pStationRow.get_Value(m_stationNameFI));
  20.  
  21.       // Get all pipes in the station and return it as a point collection
  22.       IPolyline stationPipes = GetStationPipePolyline(stationName);
  23.  
  24.       // Create our polygon using the station pipes extent
  25.       ITopologicalOperator4 pTopoOp = (ITopologicalOperator4)stationPipes;
  26.       IPolygon stationBoundary = (IPolygon)pTopoOp.ConvexHull();
  27.  
  28.       // Create the container feature and assign the extent geometry
  29.       IFeature containerFea = m_containerFC.CreateFeature();
  30.       containerFea.Shape = stationBoundary;
  31.       containerFea.Store();
  32.       pStationRow = pStationCur.NextRow();
  33.    }
  34.    m_pEditor.StopOperation("Create container polygons");
  35. }