Exemplo n.º 1
0
        public static ISourceProvider CreateSourceProvider(MapConfig config)
        {
            var             tileSize = new Size(config.TileSize);
            var             extent   = new Extent(config.Extent);
            Coordinate      origin   = origin = new Coordinate(config.Origin);
            string          url      = config.Url;
            var             paras    = config.UrlParas;
            ISourceProvider source   = null;

            switch (config.Type.ToUpper())
            {
            case "BAIDU":
                var tileGrid = new TmsTileGrid(config.Resolutions, extent, origin, tileSize);
                source = new BaiduMapProvider(tileGrid, config.Url, paras, config.OffsetZoom);
                break;

            case "WMTS":
                var wmtsTileGrid = new WmtsTileGrid(config.Resolutions, extent, origin, tileSize);
                source = new WmtsSourceProvider(wmtsTileGrid, url, paras);
                break;

            case "WMS":
                tileGrid = new TmsTileGrid(config.Resolutions, extent, origin, tileSize);
                source   = new WmsSourceProvider(tileGrid, config.Url, paras);
                break;

            case "ARCSERVERREST":
                tileGrid = new WmtsTileGrid(config.Resolutions, extent, origin, tileSize);    //new TileGrid(config.Resolutions, extent, origin, tileSize);
                source   = new ArcServerRestProvider(tileGrid, config.Url, paras);
                break;
            }
            return(source);
        }
Exemplo n.º 2
0
        public static MapConfig Load()
        {
            MapConfig config = null;

            using (FileStream fs = new FileStream(Path.Combine(Environment.CurrentDirectory, "mapConfig.json"),
                                                  FileMode.Open, FileAccess.Read))
            {
                StreamReader sr   = new StreamReader(fs, Encoding.UTF8);
                string       json = sr.ReadToEnd();
                config = JsonConvert.DeserializeObject <MapConfig>(json);
            }

            //if (config.TileSize == null)
            //{
            //    config.TileSize = new int[] { 256, 256 };
            //}
            //if (config.Origin == null)
            //{
            //    config.Origin = new double[] { config.Extent[0], config.Extent[3] };
            //}
            if (string.IsNullOrEmpty(config.SavePath))
            {
                config.SavePath = Path.Combine(Environment.CurrentDirectory, "Tiles");
                Directory.CreateDirectory(config.SavePath);
            }
            if (string.IsNullOrEmpty(config.Output))
            {
                config.Output = "File";
            }
            return(config);
        }
Exemplo n.º 3
0
        public static MapConfig Load()
        {
            MapConfig instance = null;

            using (FileStream fs = new FileStream(Path.Combine(Environment.CurrentDirectory, "mapConfig.json"),
                                                  FileMode.Open, FileAccess.Read))
            {
                StreamReader sr   = new StreamReader(fs, Encoding.UTF8);
                string       json = sr.ReadToEnd();
                instance = JsonConvert.DeserializeObject <MapConfig>(json);
            }
            return(instance);
        }
Exemplo n.º 4
0
        public static ISourceProvider CreateSourceProvider(MapConfig config)
        {
            ISourceProvider source = null;

            switch (config.Type.ToLower())
            {
            case "baidu":
                source = new BaiduMapProvider(config);
                break;

            case "gaode":
                source = new GaodeMapProvider(config);
                break;

            case "tencent":
                source = new TencentMapProvider(config);
                break;

            case "tms":
                source = new TmsSourceProvider(config);
                break;

            case "wmts":
                source = new WmtsSourceProvider(config);
                break;

            case "wmtsxyz":
                source = new WmtsXyzTileSourceProvider(config);
                break;

            case "wms":
                source = new WmsSourceProvider(config);
                break;

            case "arcserverrest":
                source = new ArcServerRestProvider(config);
                break;

            case "arcserverlocaltile":
                source = new ArcServerLocalTileProvider(config);
                break;
            }
            return(source);
        }
        public static ITileOutputStrategy CreateOutputStrategy(MapConfig config)
        {
            ITileOutputStrategy result = null;

            switch (config.Output.ToLower())
            {
            case "file":
                result = new DefaultOutputStrategy();
                break;

            case "sqlite":
                result = new SqliteOutputStrategy();
                break;

            default:
                result = new DefaultOutputStrategy();
                break;
            }
            return(result);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("加载mapConfig.json...");
            MapConfig     mapConfig = MapConfig.Load();
            TileGenerator generator = new Core.TileGenerator(mapConfig);
            var           tileIndex = 0;

            generator.TileLoaded += new EventHandler <TileCoord>((sender, tileCoord) =>
            {
                ++tileIndex;
                Console.WriteLine(string.Format("Tile : zoom :  {0} x: {1} y :{2},已完成:{3}/{4}", tileCoord.Zoom, tileCoord.X,
                                                tileCoord.Y, tileIndex, generator.Source.TileGrid.TileTotal));
            });
            Console.WriteLine("服务已启动......");
            Console.WriteLine("输入回车退出...");

            generator.Start();
            Console.ReadLine();
            generator.Close();
        }
        public static ISourceProvider CreateSourceProvider(MapConfig config)
        {
            ISourceProvider source = null;

            switch (config.Type.ToLower())
            {
            case "baidu":
                source = new BaiduMapProvider(config);
                break;

            case "wmts":
                source = new WmtsSourceProvider(config);
                break;

            case "wms":
                source = new WmsSourceProvider(config);
                break;

            case "arcserverrest":
                source = new ArcServerRestProvider(config);
                break;
            }
            return(source);
        }