/// <summary> /// Reads the header of a Shapefile /// </summary> /// <param name="reader">The Shapefile stream</param> /// <returns>The shapefile header</returns> private void ReadFileHeader(BinaryReader reader, out ShapefileShapeType shapeType, out BoundingBox bounds) { // Read File Code. int FileCode = NumberReader.ReadIntBE(reader); //Verify that the file has the correct file code (9994) if (FileCode != 9994) { throw new FormatException("Invalid FileCode encountered. Expecting a file code of 9994."); } //Skip unused section reader.BaseStream.Seek(20, SeekOrigin.Current); // Read the File Length. long fileLength = NumberReader.ReadIntBE(reader); // Skip the Version number of the shapefile. reader.BaseStream.Seek(4, SeekOrigin.Current); // Get the shape type of the shapefile. Note that shapefiles can only contain one type of shape per file shapeType = (ShapefileShapeType)NumberReader.ReadIntLE(reader); // Get the bounding box of the Bounding Box. bounds = ReadBoundingBox(reader); }
/// <summary> /// Read the header of a record /// </summary> /// <param name="reader">The Shapefile stream</param> /// <returns>The number of records in the file</returns> private int ReadRecordHeader(BinaryReader reader) { int recordNumber = NumberReader.ReadIntBE(reader); //Skip content length and shape type properties of shape record reader.BaseStream.Seek(8, SeekOrigin.Current); return(recordNumber); }