Ejemplo n.º 1
0
        internal long WriteTo(Stream stream)
        {
            var p = stream.Position;

            // write header and version.
            stream.WriteWithSize($"{nameof(Graph)}");
            stream.WriteByte(1);

            // writes zoom and edge data size.
            stream.WriteByte((byte)_zoom);
            stream.WriteByte((byte)_edgeDataSize);

            // write tile index.
            stream.WriteByte((byte)TileSizeInIndex);
            _tiles.CopyToWithHeader(stream);

            // write vertices.
            stream.WriteByte((byte)CoordinateSizeInBytes);
            stream.Write(BitConverter.GetBytes((long)_vertexPointer), 0, 8);
            _vertices.CopyToWithSize(stream);
            _edgePointers.CopyToWithSize(stream);

            // write edges.
            stream.Write(BitConverter.GetBytes((long)_edgePointer), 0, 8);
            _edges.CopyToWithSize(stream);

            // write shapes.
            _shapes.CopyTo(stream);

            return(stream.Position - p);
        }