/// <summary> /// Creates a new DbfWriter /// </summary> /// <param name="filePath">The path to the new DBF file to be created. If filePath does not include the ".dbf" extension it will be added</param> /// <param name="dataFields">A DbfFieldDesc aray describing the field of the DBF file</param> public DbfWriter(String filePath, DbfFieldDesc[] dataFields) { if(dataFields==null || dataFields.Length==0) throw new ArgumentException("datafields can not be null or zero length"); this.fileName = filePath; this.dataFields = dataFields; setupStream(); writeHeader(); }
/// <summary> /// Creates a ShapeFileWriter class /// </summary> /// <remarks> /// <para> /// To create a ShapeFileWriter to create a polygon shapefile pass in ShapeType.Polygon /// </para> /// <para> /// To create a ShapeFileWriter to create a point shapefile pass in ShapeType.Point /// </para> /// <para> /// To create a ShapeFileWriter to create a polyline shapefile pass in ShapeType.Polyline /// </para> /// </remarks> /// <param name="baseDir">The path to the base directory where the shape file should be created</param> /// <param name="shapeFileName">The name of the shapefile to create</param> /// <param name="shapeFileType">The ShapeType of the shapefile</param> /// <param name="dataFields">array of DbfFieldDesc objects describing the fields to be created in the shape file's DBF file</param> /// <returns></returns> public static ShapeFileWriter CreateWriter(string baseDir, string shapeFileName, ShapeType shapeFileType, DbfFieldDesc[] dataFields) { switch (shapeFileType) { case ShapeType.Polygon: return new PolygonShapeFileWriter(baseDir, shapeFileName, dataFields); case ShapeType.NullShape: throw new ArgumentException("Can not create shapefile using NullShape ShapeType"); case ShapeType.Point: return new PointShapeFileWriter(baseDir, shapeFileName, dataFields); case ShapeType.PolyLine: return new PolyLineShapeFileWriter(baseDir, shapeFileName, dataFields); default: throw new ArgumentException("Unknown ShapeType"); } }
internal PolygonShapeFileWriter(String baseDir, String shapeFileName, DbfFieldDesc[] datafields):base(baseDir, shapeFileName, datafields) { this.ShapeType = ShapeType.Polygon; WriteFileHeaders(); }
/// <summary> /// ShapeFileWriter Constructor /// </summary> /// <remarks>Derived classes must call this constructor</remarks> /// <param name="baseDir">The base directory where the 3 shapefile files will be created</param> /// <param name="shapeFileName">The name of the shapefile. The shapefile will be generated at baseDir + shapeFileName + ".shx|.shp|.dbf|.cpg</param> /// <param name="dataFields">DbfFieldDesc array describing the dbf fields of the shapefile</param> protected ShapeFileWriter(string baseDir, string shapeFileName, DbfFieldDesc[] dataFields) { if(dataFields==null || dataFields.Length==0) throw new ArgumentException("dataFields can not be null or zero length"); this.BaseDirectory = baseDir; this.FileName = shapeFileName; this.dataFields = dataFields; SetupFiles(); }