Beispiel #1
0
        //Indexing
        public static async Task CreateIndex(string shpFileName)
        {
            ShxReader shxFile = new ShxReader(Shapefile.GetShxFileName(shpFileName));

            var shapes = await ReadAsync(shpFileName);

            int numberOfRecords = shxFile.NumberOfRecords;

            List <Indexing.ShpIndex> indexes = new List <Indexing.ShpIndex>(numberOfRecords);

            for (int i = 0; i < numberOfRecords; i++)
            {
                int offset, contentLength;

                shxFile.GetRecord(i, out offset, out contentLength);

                if (contentLength == 2)
                {
                    continue;
                }

                indexes.Add(new Indexing.ShpIndex()
                {
                    RecordNumber       = i,
                    MinimumBoundingBox = shapes[indexes.Count].MinimumBoundingBox
                });
            }

            Indexing.IndexIO.Write(GetIndexFileName(shpFileName), indexes);
        }
Beispiel #2
0
        private static IShapeCollection ExtractPolygons(System.IO.BinaryReader shpReader, ShxReader shxReader, List <Indexing.ShpIndex> indexes)
        {
            List <Polygon> geometries = new List <Polygon>(indexes.Count);

            for (int i = 0; i < indexes.Count; i++)
            {
                int offset, contentLength;

                shxReader.GetRecord(indexes[i].RecordNumber, out offset, out contentLength);

                geometries[i] = PolygonReader.Read(shpReader, offset, contentLength);
            }

            return(new ShapeCollection <Polygon>(geometries));
        }
Beispiel #3
0
        private static IEsriShapeCollection ExtractPolyLines(System.IO.BinaryReader shpReader, ShxReader shxReader, List <Indexing.ShpIndex> indexes, int srid)
        {
            List <EsriPolyline> geometries = new List <EsriPolyline>(indexes.Count);

            for (int i = 0; i < indexes.Count; i++)
            {
                int offset, contentLength;

                shxReader.GetRecord(indexes[i].RecordNumber, out offset, out contentLength);

                geometries[i] = PolyLineReader.Read(shpReader, offset, contentLength, srid);
            }

            return(new EsriShapeCollection <EsriPolyline>(geometries));
        }