Inheritance: IPathResolver
Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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()
            }
        }
Esempio n. 3
0
File: Startup.cs Progetto: 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);
        }