상속: IPathResolver
예제 #1
0
파일: Global.asax.cs 프로젝트: jbrwn/tc
        protected void Application_Start(object sender, EventArgs e)
        {
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            ErrorConfig.Register(GlobalConfiguration.Configuration);

            //Mapnik config
            MapnikProvider.RegisterDatasources(Server.MapPath("~/bin/mapnik/input"));
            MapnikProvider.RegisterFonts(Server.MapPath("~/bin/mapnik/fonts"));

            //Bootstrap TileCook config file repository
            string layerDir = WebConfigurationManager.AppSettings["ConfigDirectory"] != null ?
                WebConfigurationManager.AppSettings["ConfigDirectory"] : Server.MapPath("~/App_Data/Config");
            IPathResolver pathResolver = new PathResolver(layerDir);
            TileCookConfig.LoadConfigs(new LayerRepository(), layerDir);
        }
예제 #2
0
파일: TileCookConfig.cs 프로젝트: jbrwn/tc
        public static void LoadConfigs(ILayerRepository repository, string configDir)
        {
            // Create configuration object map
            IPathResolver pathResolver = new PathResolver(configDir);
            LayerMap LayerMap = new LayerMap(
                new GridSetMap(
                    new EnvelopeMap()
                ),
                new CacheMap(pathResolver),
                new ProviderMap(
                    new VectorTileLayerMap(
                        new GridSetMap(
                            new EnvelopeMap()
                        ),
                        new CacheMap(pathResolver),
                        new VectorTileProviderMap(pathResolver),
                        new EnvelopeMap()
                    ),
                    pathResolver
                ),
                new EnvelopeMap()
            );

            // Deserialize config files
            JsonSerializer serializer = new JsonSerializer();
            try
            {
                foreach (string file in Directory.EnumerateFiles(configDir, "*.json", SearchOption.TopDirectoryOnly))
                {
                    using (StreamReader sr = new StreamReader(file))
                    {
                        using (JsonTextReader reader = new JsonTextReader(sr))
                        {
                            LayerConfig LayerConfig = (LayerConfig)serializer.Deserialize(reader, typeof(LayerConfig));
                            Layer l = LayerMap.Map(LayerConfig);
                            repository.Put(l);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw;
                //Trace.TraceWarning()
            }
        }
예제 #3
0
파일: Startup.cs 프로젝트: jbrwn/tc
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();
            WebApiConfig.Register(config);
            ErrorConfig.Register(config);
            app.UseWebApi(config);

            //Mapnik config
            MapnikProvider.RegisterDatasources("mapnik/input");
            MapnikProvider.RegisterFonts("mapnik/fonts");

            //Bootstrap TileCook config file repository
            string layerDir = ConfigurationManager.AppSettings["ConfigDirectory"] != null ?
                ConfigurationManager.AppSettings["ConfigDirectory"] : "Config";
            IPathResolver pathResolver = new PathResolver(layerDir);
            TileCookConfig.LoadConfigs(new LayerRepository(), layerDir);
        }