Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Native.Initialize();

            // enable logging and use the console as output.
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(
                new OsmSharp.WinForms.UI.Logging.ConsoleTraceListener());

            // initialize mapcss interpreter.
            var mapCSSInterpreter = new MapCSSInterpreter(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Service.Tiles.Sample.SelfHost.custom.mapcss"),
                new MapCSSDictionaryImageSource());

            var scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), new List <float>(new float[] {
                16, 14, 12, 10
            }));
            var target = new StyleOsmStreamSceneTarget(
                mapCSSInterpreter, scene, new WebMercator());
            var source = new PBFOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Service.Tiles.Sample.SelfHost.kempen.osm.pbf"));
            var progress = new OsmStreamFilterProgress();

            progress.RegisterSource(source);
            target.RegisterSource(progress);
            target.Pull();

            var merger = new Scene2DObjectMerger();

            scene = merger.BuildMergedScene(scene);

            // create a new instance (with a cache).
            var instance = new RenderingInstance();

            instance.Map.AddLayer(new LayerScene(scene));

            // add a default test instance.
            ApiBootstrapper.AddInstance("default", instance);

            // start hosting this!
            using (var host = new NancyHost(new Uri("http://*****:*****@ http://localhost:1234");
                System.Diagnostics.Process.Start("http://localhost:1234/default");
                Console.ReadLine();
            }
        }
        /// <summary>
        /// Flushes all data.
        /// </summary>
        public override void Flush()
        {
            // merge objects.
            var     merger      = new Scene2DObjectMerger();
            Scene2D mergedScene = merger.BuildMergedScene(_scene);

            _scene = null;

            // serialize scene.
            TagsCollectionBase metaTags = new TagsCollection();

            mergedScene.Serialize(_stream, true, metaTags);

            _stream.Flush();
            base.Flush();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the tests.
        /// </summary>
        /// <returns>Serialized scene.</returns>
        public static Stream Test()
        {
            // create a layered scene.
            Scene2D scene = new Scene2D(new OsmSharp.Math.Geo.Projections.WebMercator(), new List <float>(new float[] {
                16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6
            }));

            // tests map css interpreter.
            MapCSSInterpreterTests.TestInterpret("MapCSSInterpreter", @"mapcss\default.mapcss", scene, "kempen-big.osm.pbf");

            var merger = new Scene2DObjectMerger();

            scene = merger.BuildMergedScene(scene);

            // tests serialization of the scene.
            return(Scene2DTests.TestSerialize("Scene2DLayered", @"mapcss\default.map", scene, true));
        }