Пример #1
0
 public ShapeFileHeader(ShapeFileType shapeFileType)
 {
     fileCode           = 9994;
     version            = fileVersionNumber;
     this.shapeFileType = shapeFileType;
     boundingBox        = new ShapeFileBoundingBox();
 }
Пример #2
0
        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);
        }
Пример #3
0
 /// <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;
     }
 }
Пример #4
0
        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);
        }