public ShapeFileHeader(ShapeFileType shapeFileType) { fileCode = 9994; version = fileVersionNumber; this.shapeFileType = shapeFileType; boundingBox = new ShapeFileBoundingBox(); }
public static ShapeFileBoundingBox GetHeaderBoundingBox(Stream stream) { stream.Seek(boundingBoxStartPostion, SeekOrigin.Begin); ShapeFileBoundingBox returnBoundingBox = new ShapeFileBoundingBox(); BinaryReader br = new BinaryReader(stream); returnBoundingBox.minX = br.ReadDouble(); returnBoundingBox.minY = br.ReadDouble(); returnBoundingBox.maxX = br.ReadDouble(); returnBoundingBox.maxY = br.ReadDouble(); return(returnBoundingBox); }
/// <summary> /// merge the input Bounding Box, store the result /// </summary> /// <param name="targetBox">the input BoundingBox to be merged</param> public void MergeBoundingBox(ShapeFileBoundingBox targetBox) { if (minX == 0 && minY == 0 && maxX == 0 && maxY == 0) { minX = targetBox.minX; maxX = targetBox.maxX; minY = targetBox.minY; maxY = targetBox.maxY; } else { minX = targetBox.MinX < minX ? targetBox.MinX : minX; maxX = targetBox.MaxX > maxX ? targetBox.MaxX : maxX; minY = targetBox.MinY < minY ? targetBox.MinY : minY; maxY = targetBox.MaxY > maxY ? targetBox.MaxY : maxY; } }
public static ShapeFileHeader GetHeaderFromStream(Stream stream) { ShapeFileHeader returnHeader = new ShapeFileHeader(); stream.Seek(0, SeekOrigin.Begin); returnHeader.fileCode = IOUtil.ReadIntFromStream(stream, WkbByteOrder.BigEndian); stream.Seek(fileLengthInfoPosition, SeekOrigin.Begin); returnHeader.fileLength = IOUtil.ReadIntFromStream(stream, WkbByteOrder.BigEndian); returnHeader.version = IOUtil.ReadIntFromStream(stream, WkbByteOrder.LittleEndian); returnHeader.shapeFileType = ConvertIntToShapeFileType(IOUtil.ReadIntFromStream(stream, WkbByteOrder.LittleEndian)); returnHeader.boundingBox = ShapeFileBoundingBox.GetHeaderBoundingBox(stream); return(returnHeader); }