/// <summary>
        /// Fills the given simple scene with objects inside the given view and for the given zoomFactor.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="view"></param>
        /// <param name="zoomFactor"></param>
        public void Get(Scene2DSimple scene, View2D view, float zoomFactor)
        {
            lock (_stream) {             // make sure there is only synchonous access to the stream.
                // check what is in the non-simplified scene.
                IScene2DPrimitivesSource simpleSource = this.GetNonSimplifiedStream();
                simpleSource.Get(scene, view, zoomFactor);

                // check what index this zoomfactor is for.
                int idx = this.SearchForScene(zoomFactor);
                if (idx >= 0)                                              // the index was found.
                {
                    if (!_loadedScenes.TryGetValue(idx, out simpleSource)) // the scene was not found.
                    {
                        long position = _index.SceneIndexes [idx];
                        _stream.Seek(position, SeekOrigin.Begin);
                        LimitedStream stream = new LimitedStream(_stream);
                        //Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true);
                        //simpleSource = new Scene2DPrimitivesSource(serializer.Deserialize(stream));
                        OsmSharp.UI.Renderer.Scene.Storage.Styled.Scene2DStyledSerializer serializer =
                            new Styled.Scene2DStyledSerializer();
                        simpleSource = serializer.Deserialize(stream, true);
                        _loadedScenes.Add(idx, simpleSource);
                    }
                    simpleSource.Get(scene, view, zoomFactor);

                    OsmSharp.Logging.Log.TraceEvent("Scene2DLayeredSource", System.Diagnostics.TraceEventType.Verbose,
                                                    string.Format("Deserialized from scene at zoom {0} and idx {1} synchronized.", zoomFactor, idx));
                }
            }
        }
 /// <summary>
 /// Returns the non-simplified scene.
 /// </summary>
 /// <returns></returns>
 private IScene2DPrimitivesSource GetNonSimplifiedStream()
 {
     if (_nonSimplifiedScene == null)
     {
         long position = _index.SceneIndexes[_index.SceneIndexes.Length - 1];
         _stream.Seek(position, SeekOrigin.Begin);
         LimitedStream stream = new LimitedStream(_stream);
         //Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true);
         //_nonSimplifiedScene = new Scene2DPrimitivesSource(serializer.Deserialize(stream));
         OsmSharp.UI.Renderer.Scene.Storage.Styled.Scene2DStyledSerializer serializer =
             new Styled.Scene2DStyledSerializer();
         _nonSimplifiedScene = serializer.Deserialize(stream, true);
     }
     return(_nonSimplifiedScene);
 }
 /// <summary>
 /// Returns the non-simplified scene.
 /// </summary>
 /// <returns></returns>
 private IScene2DPrimitivesSource GetNonSimplifiedStream()
 {
     if (_nonSimplifiedScene == null)
     {
         long position = _index.SceneIndexes[_index.SceneIndexes.Length - 1];
         _stream.Seek(position, SeekOrigin.Begin);
         LimitedStream stream = new LimitedStream(_stream);
         //Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true);
         //_nonSimplifiedScene = new Scene2DPrimitivesSource(serializer.Deserialize(stream));
         OsmSharp.UI.Renderer.Scene.Storage.Styled.Scene2DStyledSerializer serializer =
             new Styled.Scene2DStyledSerializer();
         _nonSimplifiedScene = serializer.Deserialize(stream, true);
     }
     return _nonSimplifiedScene;
 }
        /// <summary>
        /// Fills the given simple scene with objects inside the given view and for the given zoomFactor.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="view"></param>
        /// <param name="zoomFactor"></param>
        public void Get(Scene2DSimple scene, View2D view, float zoomFactor)
        {
            lock (_stream) { // make sure there is only synchonous access to the stream.
                // check what is in the non-simplified scene.
                IScene2DPrimitivesSource simpleSource = this.GetNonSimplifiedStream ();
                simpleSource.Get (scene, view, zoomFactor);

                // check what index this zoomfactor is for.
                int idx = this.SearchForScene (zoomFactor);
                if (idx >= 0) { // the index was found.
                    if (!_loadedScenes.TryGetValue (idx, out simpleSource)) { // the scene was not found.
                        long position = _index.SceneIndexes [idx];
                        _stream.Seek (position, SeekOrigin.Begin);
                        LimitedStream stream = new LimitedStream (_stream);
                        //Scene2DRTreeSerializer serializer = new Scene2DRTreeSerializer(true);
                        //simpleSource = new Scene2DPrimitivesSource(serializer.Deserialize(stream));
                        OsmSharp.UI.Renderer.Scene.Storage.Styled.Scene2DStyledSerializer serializer =
                            new Styled.Scene2DStyledSerializer ();
                        simpleSource = serializer.Deserialize (stream, true);
                        _loadedScenes.Add (idx, simpleSource);
                    }
                    simpleSource.Get (scene, view, zoomFactor);

                    OsmSharp.Logging.Log.TraceEvent ("Scene2DLayeredSource", System.Diagnostics.TraceEventType.Verbose,
                        string.Format ("Deserialized from scene at zoom {0} and idx {1} synchronized.", zoomFactor, idx));
                }
            }
        }