/// <summary> /// Creates a new instance of FeatureSet by opening disk-based shapefile. /// </summary> /// <param name="filename">Filename of shapefile to open (.shp extension).</param> public FeatureSet(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException("File not found: " + filename); } _shapefile = new Shapefile(); if (!_shapefile.Open(filename)) { throw new ApplicationException("Failed to open shapefile: " + _shapefile.ErrorMessage()); } }
/// <summary> /// Creates a new disk-based shapefile and open it as new feature set. /// </summary> /// <returns>Feature set for newly created shapefile.</returns> public static IFeatureSet CreateShapefile(string filename, GeometryType geomType, ZValueType zValue = ZValueType.None) { if (geomType == GeometryType.None) { throw new ArgumentException("Invalid geometry type."); } var shpType = GeometryHelper.GeometryType2ShpType(geomType, zValue); var sf = new Shapefile(); if (!sf.CreateNew(filename, shpType)) { throw new ApplicationException("Failed to create shapefile: " + sf.ErrorMessage()); } var fs = new FeatureSet(sf); return(fs); }