Ejemplo n.º 1
0
 private void BuildTreeInMemo()
 {
     foreach (var recHeader in this._ShxFile.Records)
     {
         FeatureLite rec = _ShpFile.ReaderShape(recHeader.Offset, recHeader.ContentLength);
         _SpatialIndex.Insert(rec.FeatureID, rec.MBR);
     }
 }
Ejemplo n.º 2
0
        public FeatureLite ReaderShape(int recHeaderPos, int recCLength)
        {
            using (var stream = MMFCache.GetFileReadItems(_FilePath)
                                .MMF.CreateViewStream(recHeaderPos, recCLength + HEADER_LENGTH))
            {
                using (var brReader = new BinaryReader(stream))
                {
                    FeatureLite fl;

                    int fID     = Util.SwapByteOrder(brReader.ReadInt32());
                    int clength = Util.SwapByteOrder(brReader.ReadInt32());

                    ShapeType shapeType = (ShapeType)brReader.ReadInt32();  // 4

                    if (shapeType == ShapeType.Point)
                    {
                        fl = new FeatureLite(fID, shapeType
                                             , brReader.ReadDouble(), brReader.ReadDouble());
                    }
                    else
                    {
                        double xMin = brReader.ReadDouble();
                        double yMin = brReader.ReadDouble();
                        double xMax = brReader.ReadDouble();
                        double yMax = brReader.ReadDouble();// 8*4=32

                        Envelope mbr = new Envelope(xMin, xMax, yMin, yMax);

                        var shapeBytes = new byte[clength - 36];  // 4+32=36
                        brReader.BaseStream.Seek(36, 0);
                        brReader.Read(shapeBytes, 0, clength - 36);
                        fl = new FeatureLite(fID, shapeType, mbr, shapeBytes);
                    }
                    return(fl);
                }
            }
        }