Пример #1
0
 /// <summary>
 /// Creates a new enumerator.
 /// </summary>
 /// <param name="graph"></param>
 public EdgeEnumerator(RouterLiveEdgeDataSource graph)
 {
     _graph   = graph;
     _edges   = null;
     _vertex1 = 0;
     _vertex2 = 0;
 }
Пример #2
0
        /// <summary>
        /// Does the v1 deserialization.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="lazy"></param>
        /// <param name="vehicles"></param>
        /// <returns></returns>
        protected override IBasicRouterDataSource <LiveEdge> DoDeserialize(
            LimitedStream stream, bool lazy, IEnumerable <string> vehicles)
        {
            // serialize all tile meta data.
            stream.Seek(0, SeekOrigin.Begin);

            var compressionFlag = new byte[1];

            stream.Read(compressionFlag, 0, 1);
            bool decompress = (compressionFlag[0] == (byte)1);

            var tileCountBytes = new byte[4];

            stream.Read(tileCountBytes, 0, tileCountBytes.Length);

            var tileMetaEndBytes = new byte[8];

            stream.Read(tileMetaEndBytes, 0, tileMetaEndBytes.Length);
            var tileMetaEnd = BitConverter.ToInt64(tileMetaEndBytes, 0);

            // deserialize meta data.
            var metas = (SerializableGraphTileMetas)_runtimeTypeModel.Deserialize(
                new CappedStream(stream, stream.Position, tileMetaEnd - stream.Position), null,
                typeof(SerializableGraphTileMetas));

            // create the datasource.
            var routerDataSource = new RouterLiveEdgeDataSource(stream, decompress, metas, Zoom,
                                                                this, vehicles, 1000);

            if (!lazy)
            {
                // pre-load everything.
                for (int tileIdx = 0; tileIdx < metas.TileX.Length; tileIdx++)
                {
                    routerDataSource.LoadMissingTile(
                        new Tile(metas.TileX[tileIdx], metas.TileY[tileIdx], Zoom));
                }
            }

            // return router datasource.
            return(routerDataSource);
        }
Пример #3
0
 /// <summary>
 /// Creates a new enumerators.
 /// </summary>
 /// <param name="source">The datasource the edges come from.</param>
 /// <param name="edges">The edge data.</param>
 public NeighbourEnumerator(RouterLiveEdgeDataSource source,
                            List <Tuple <uint, uint, uint, LiveEdge> > neighbours)
 {
     _source     = source;
     _neighbours = neighbours;
 }