public override bool Execute(DotSpatial.Data.ICancelProgressHandler cancelProgressHandler) { var dt_stream = _stream_layer.DataTable; var segid = from dr in dt_stream.AsEnumerable() select (dr.Field<int>(SegmentField) + 1); var dic = Path.GetDirectoryName(_stream_layer.FilePath); var out_fn = Path.Combine(dic, "sfr_cpm.shp"); string msg=""; Dictionary<int, ReachFeatureCollection> fea_list = new Dictionary<int, ReachFeatureCollection>(); foreach(var id in segid) { fea_list.Add(id, new ReachFeatureCollection(id)); } cancelProgressHandler.Progress("Package_Tool", 10, "Calculating..."); if (StreamGridInctLayer != null) _out_sfr_layer = StreamGridInctLayer.DataSet as FeatureSet; else { _out_sfr_layer = _stream_layer.Intersection1(_grid_layer, FieldJoinType.All, null); _out_sfr_layer.Projection = _stream_layer.Projection; _out_sfr_layer.SaveAs(out_fn, true); } cancelProgressHandler.Progress("Package_Tool", 30, "Calculation of intersectons between Grid and Stream finished"); PrePro(fea_list, out msg); cancelProgressHandler.Progress("Package_Tool", 70, "Calculation of reach parameters finished"); if(msg != "") cancelProgressHandler.Progress("Package_Tool", 80, "Warnings: " + msg); Save2SFRFile(fea_list); cancelProgressHandler.Progress("Package_Tool", 90, "SFR file saved"); return true; }
public override bool Execute(ICancelProgressHandler cancelProgressHandler) { IFeatureSet fs = FeatureSet.Open(FeatureFile); IFeatureSet polygon_fs = FeatureSet.Open(PolygonFile); var outfs = fs.Intersection1(polygon_fs, FieldJoinType.All, cancelProgressHandler); outfs.SaveAs(OutputFeatureFile, true); return(true); }