Esempio n. 1
0
        private void BuildGrid()
        {
            WebMercatorGrid grid = new WebMercatorGrid();
            //
            List <Coordinate> coordinates = new List <Coordinate>();

            coordinates.Add(new Coordinate(109, 20));
            coordinates.Add(new Coordinate(117.2, 25.6));
            Bound bound = new Bound(coordinates);

            //构建尺度6格网
            for (int i = 10; i < 17; i++)
            {
                grid.Build(bound, i);
            }
            //shpfile路径
            string    shpPath   = System.IO.Directory.GetCurrentDirectory() + @"\DATA\shp\china\guangdong.shp";
            ShpReader shpReader = new ShpReader();

            shpReader.Read(shpPath);
            //
            string outputDir = System.IO.Directory.GetCurrentDirectory() + @"\dataset";

            grid.CutShape(shpReader.FeaureCollection, outputDir);
        }
Esempio n. 2
0
        public static void Build()
        {
            _isRunning = true;
            //1.搜索线
            IShpReader      lineReader = new ShpReader(_dir + @"\" + _lineName + ".shp");
            WebMercatorGrid lineGrid   = new WebMercatorGrid();

            for (int i = _startLevel; i < _endLevel; i++)
            {
                lineGrid.Build(lineReader.Bounds, i);
            }
            //1.1线切片输出
            lineGrid.CutShapeOrderByGrid(lineReader, _outDir + _lineName + @"\");

            //2.搜索面
            IShpReader      polygonReader = new ShpReader(_dir + @"\" + _polygonName + ".shp");
            WebMercatorGrid polygonGrid   = new WebMercatorGrid();

            for (int i = _startLevel; i < _endLevel; i++)
            {
                polygonGrid.Build(polygonReader.Bounds, i);
            }
            //2.1线切片输出
            polygonGrid.CutShapeOrderByGrid(polygonReader, _outDir + _polygonName + @"\");

            //3.搜索点
            IShpReader      pointReader = new ShpReader(_dir + @"\" + _ptName + ".shp");
            WebMercatorGrid pointGrid   = new WebMercatorGrid();

            for (int i = _startLevel; i < _endLevel; i++)
            {
                pointGrid.Build(pointReader.Bounds, i);
            }
            //3.1线切片输出
            pointGrid.CutShapeOrderByGrid(pointReader, _outDir + _ptName + @"\");
            _isRunning = false;
        }