< Summary

Class:Itinero.Network.Tiles.Standalone.StandaloneNetworkTile
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Attributes.cs
/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Boundaries.cs
/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.cs
/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Global.cs
/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Serialization.cs
Covered lines:160
Uncovered lines:188
Coverable lines:348
Total lines:574
Line coverage:45.9% (160 of 348)
Covered branches:37
Total branches:74
Branch coverage:50% (37 of 74)
Tag:263_26948838820

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
SetAttributes(...)62.5%862.5%
GetAttributes()83.33%688.23%
AddOrGetString(...)83.33%682.35%
WriteAttributesTo(...)0%40%
ReadAttributesFrom(...)0%40%
ReadAttributesFrom(...)0%20%
WriteAttributesTo(...)0%20%
.ctor(...)100%1100%
AddBoundaryCrossing(...)75%493.75%
GetBoundaryCrossings()100%4100%
.ctor(...)100%1100%
get_NetworkTile()100%1100%
GetEnumerator()100%1100%
get_TileId()100%1100%
.ctor(...)100%1100%
AddGlobalRestriction(...)80%1088.23%
GetGlobalRestrictions()87.5%887.5%
WriteGlobal(...)0%20%
ReadGlobal(...)0%20%
ReadGlobal(...)100%10%
WriteGlobal(...)100%10%
WriteTo(...)100%10%
WriteEdgesAndVerticesTo(...)0%20%
ReadFrom(...)0%20%
ReadEdgesAndVerticesFrom(...)0%20%
ReadFrom(...)0%20%
ReadEdgesAndVerticesFrom(...)100%10%
ToBytes()0%20%
WriteToBuffer(...)100%10%
WriteEdgesAndVerticesTo(...)100%10%
GetSerializedSizeUpperBound()0%20%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Attributes.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.IO;
 4using Itinero.IO;
 5using Itinero.Network.Storage;
 6
 7namespace Itinero.Network.Tiles.Standalone;
 8
 9public partial class StandaloneNetworkTile
 10{
 11    /// <summary>
 12    /// Stores the attributes, starting with the number of attributes and then alternating key-value pairs.
 13    /// </summary>
 14    private byte[] _attributes;
 15
 2716    private uint _nextAttributePointer = 0;
 17
 18    /// <summary>
 19    /// Stores each string once.
 20    /// </summary>
 21    private string[] _strings;
 22
 2723    private uint _nextStringId = 0;
 24
 25    private uint SetAttributes(IEnumerable<(string key, string value)> attributes)
 3126    {
 3127        var start = _nextAttributePointer;
 28
 3129        long cPos = start;
 3130        long p = start + 1;
 3131        var c = 0;
 15532        foreach (var (key, value) in attributes)
 3133        {
 3134            if (_attributes.Length <= p + 16)
 035            {
 036                Array.Resize(ref _attributes, (int)(_attributes.Length + 256));
 037            }
 38
 3139            var id = this.AddOrGetString(key);
 3140            p += _attributes.SetDynamicUInt32(p, id);
 3141            id = this.AddOrGetString(value);
 3142            p += _attributes.SetDynamicUInt32(p, id);
 43
 3144            c++;
 3145            if (c == 255)
 046            {
 047                _attributes[(int)cPos] = 255;
 048                c = 0;
 049                cPos = p;
 050                p++;
 051            }
 3152        }
 53
 3154        if (_attributes.Length <= cPos)
 055        {
 056            Array.Resize(ref _attributes, (int)(_attributes.Length + 256));
 057        }
 58
 3159        _attributes[(int)cPos] = (byte)c;
 60
 3161        _nextAttributePointer = (uint)p;
 62
 3163        return start;
 3164    }
 65
 66    internal IEnumerable<(string key, string value)> GetAttributes(uint? pointer)
 3667    {
 3668        if (pointer == null)
 069        {
 070            yield break;
 71        }
 72
 3673        var p = pointer.Value;
 74
 3675        var count = -1;
 76        do
 3677        {
 3678            count = _attributes[p];
 3679            p++;
 80
 14481            for (var i = 0; i < count; i++)
 3682            {
 3683                p += (uint)_attributes.GetDynamicUInt32(p, out var keyId);
 3684                p += (uint)_attributes.GetDynamicUInt32(p, out var valId);
 85
 3686                yield return (_strings[keyId], _strings[valId]);
 3687            }
 7288        } while (count == 255);
 3689    }
 90
 91    private uint AddOrGetString(string s)
 6292    {
 29893        for (uint i = 0; i < _nextStringId; i++)
 10194        {
 10195            var existing = _strings[i];
 10196            if (existing == s)
 1497            {
 1498                return i;
 99            }
 87100        }
 101
 48102        if (_strings.Length <= _nextStringId)
 0103        {
 0104            Array.Resize(ref _strings, (int)(_strings.Length + 256));
 0105        }
 106
 48107        var id = _nextStringId;
 48108        _nextStringId++;
 109
 48110        _strings[id] = s;
 48111        return id;
 62112    }
 113
 114    private void WriteAttributesTo(Stream stream)
 0115    {
 0116        stream.WriteVarUInt32(_nextAttributePointer);
 0117        for (var i = 0; i < _nextAttributePointer; i++)
 0118        {
 0119            stream.WriteByte(_attributes[i]);
 0120        }
 121
 0122        stream.WriteVarUInt32(_nextStringId);
 0123        for (var i = 0; i < _nextStringId; i++)
 0124        {
 0125            stream.WriteWithSize(_strings[i]);
 0126        }
 0127    }
 128
 129    private void ReadAttributesFrom(Stream stream)
 0130    {
 0131        _nextAttributePointer = stream.ReadVarUInt32();
 0132        _attributes = new byte[_nextAttributePointer];
 0133        for (var i = 0; i < _nextAttributePointer; i++)
 0134        {
 0135            _attributes[i] = (byte)stream.ReadByte();
 0136        }
 137
 0138        _nextStringId = stream.ReadVarUInt32();
 0139        _strings = new string[_nextStringId];
 0140        for (var i = 0; i < _nextStringId; i++)
 0141        {
 0142            _strings[i] = stream.ReadWithSizeString();
 0143        }
 0144    }
 145
 146    private void ReadAttributesFrom(byte[] data, ref int offset)
 0147    {
 0148        _nextAttributePointer = BitCoderBuffer.GetVarUInt32(data, ref offset);
 0149        _attributes = new byte[_nextAttributePointer];
 0150        Buffer.BlockCopy(data, offset, _attributes, 0, (int)_nextAttributePointer);
 0151        offset += (int)_nextAttributePointer;
 152
 0153        _nextStringId = BitCoderBuffer.GetVarUInt32(data, ref offset);
 0154        _strings = new string[_nextStringId];
 0155        for (var i = 0; i < _nextStringId; i++)
 0156        {
 0157            _strings[i] = BitCoderBuffer.GetWithSizeString(data, ref offset);
 0158        }
 0159    }
 160
 161    private void WriteAttributesTo(byte[] data, ref int offset)
 0162    {
 0163        BitCoderBuffer.SetVarUInt32(data, ref offset, _nextAttributePointer);
 0164        Buffer.BlockCopy(_attributes, 0, data, offset, (int)_nextAttributePointer);
 0165        offset += (int)_nextAttributePointer;
 166
 0167        BitCoderBuffer.SetVarUInt32(data, ref offset, _nextStringId);
 0168        for (var i = 0; i < _nextStringId; i++)
 0169        {
 0170            BitCoderBuffer.SetWithSizeString(data, ref offset, _strings[i]);
 0171        }
 0172    }
 173}

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Boundaries.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using Itinero.Network.Storage;
 4using Itinero.Network.Tiles.Standalone.Global;
 5
 6namespace Itinero.Network.Tiles.Standalone;
 7
 8public partial class StandaloneNetworkTile
 9{
 2710    private byte[] _crossings = new byte[1024];
 11    private uint _crossingsPointer;
 12
 13    internal void AddBoundaryCrossing(bool isIncoming, GlobalEdgeId globalEdgeId, VertexId vertex,
 14        IEnumerable<(string key, string value)> attributes, uint edgeTypeId)
 1715    {
 1716        if (vertex.TileId != this.NetworkTile.TileId)
 017            throw new ArgumentException("Can only add boundary crossings that cross into the tile");
 18
 1719        ArrayBaseExtensions.EnsureMinimumSize(ref _crossings, _crossingsPointer + 36);
 20        // Use Int64 so the sign-as-direction signal round-trips for any uint LocalId. Int32 would
 21        // silently wrap to the wrong sign for LocalIds with the high bit set; for typical small
 22        // vertex LocalIds the encoded byte sequence is identical to the previous Int32 encoding.
 1723        if (isIncoming)
 824        {
 25            // incoming if vertex is encoded as a positive number.
 826            _crossingsPointer += _crossings.SetDynamicInt64(_crossingsPointer, (long)(vertex.LocalId + 1));
 827        }
 28        else
 929        {
 30            // outgoing if vertex is encode as a negative number.
 931            _crossingsPointer += _crossings.SetDynamicInt64(_crossingsPointer, -(long)(vertex.LocalId + 1));
 932        }
 1733        _crossingsPointer += _crossings.SetDynamicUInt32(_crossingsPointer, edgeTypeId);
 1734        _crossingsPointer += _crossings.SetGlobalEdgeId(_crossingsPointer, globalEdgeId);
 35
 1736        var a = this.SetAttributes(attributes);
 1737        _crossingsPointer += _crossings.SetDynamicUInt32(_crossingsPointer, a);
 1738    }
 39
 40    /// <summary>
 41    /// Gets all boundary crossing edges.
 42    /// </summary>
 43    /// <returns>An enumerable with all boundary crossing edges.</returns>
 44    public IEnumerable<(bool isIncoming, GlobalEdgeId globalEdgeId, VertexId vertex,
 45        IEnumerable<(string key, string value)> attributes, uint edgeTypeId)> GetBoundaryCrossings()
 2346    {
 2347        var pointer = 0L;
 3948        while (pointer < _crossingsPointer)
 1649        {
 1650            pointer += _crossings.GetDynamicInt64(pointer, out var localIdSigned);
 51            bool isIncoming;
 52            uint localId;
 1653            if (localIdSigned > 0)
 854            {
 855                localId = (uint)(localIdSigned - 1);
 856                isIncoming = true;
 857            }
 58            else
 859            {
 860                localId = (uint)(-localIdSigned - 1);
 861                isIncoming = false;
 862            }
 1663            pointer += _crossings.GetDynamicUInt32(pointer, out var edgeTypeId);
 1664            pointer += _crossings.GetGlobalEdgeId(pointer, out var globalEdgeId);
 1665            pointer += _crossings.GetDynamicUInt32(pointer, out var a);
 66
 1667            yield return (isIncoming, globalEdgeId, new VertexId(this.TileId, localId), this.GetAttributes(a),
 1668                edgeTypeId);
 1669        }
 2370    }
 71}

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.cs

#LineLine coverage
 1namespace Itinero.Network.Tiles.Standalone;
 2
 3/// <summary>
 4/// A standalone network tile.
 5/// </summary>
 6public partial class StandaloneNetworkTile
 7{
 278    internal StandaloneNetworkTile(NetworkTile networkTile)
 279    {
 2710        _attributes = new byte[1024];
 2711        _strings = new string[128];
 12
 2713        this.NetworkTile = networkTile;
 2714    }
 15
 93616    internal NetworkTile NetworkTile { get; }
 17
 18    /// <summary>
 19    /// Gets an enumerator to access the non-boundary edges.
 20    /// </summary>
 21    /// <returns></returns>
 22    public IStandaloneNetworkTileEnumerator GetEnumerator()
 2723    {
 2724        var enumerator = new NetworkTileEnumerator();
 2725        enumerator.MoveTo(this.NetworkTile);
 2726        return enumerator;
 2727    }
 28
 29    /// <summary>
 30    /// Gets the tile id.
 31    /// </summary>
 48832    public uint TileId => this.NetworkTile.TileId;
 33}

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Global.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.IO;
 4using System.Linq;
 5using Itinero.IO;
 6using Itinero.Network.Storage;
 7using Itinero.Network.Tiles.Standalone.Global;
 8using Itinero.Network.TurnCosts;
 9
 10namespace Itinero.Network.Tiles.Standalone;
 11
 12public partial class StandaloneNetworkTile
 13{
 14    // here we store all the data about global restrictions that could not be turned into turn costs yet because the net
 15    // the edge of the tiles. we store the global edge ids of the restriction along with the type so we can create the t
 16    // is being completed
 17    private uint _globalRestrictionsPointer;
 2718    private byte[] _globalRestrictions = new byte[0];
 19
 20    /// <summary>
 21    /// Adds a global restriction for processing when the tile is loaded.
 22    /// </summary>
 23    /// <param name="sequence">The sequence of global edge ids with local edge ids if they are already known.</param>
 24    /// <param name="isProhibitory">The type of restriction.</param>
 25    /// <param name="turnCostTypeId">The turn cost type, already determined.</param>
 26    /// <param name="attributes">The raw attributes of the restriction.</param>
 27    public void AddGlobalRestriction(IEnumerable<(GlobalEdgeId globalEdgeId, EdgeId? edge)> sequence,
 28        bool isProhibitory, uint turnCostTypeId, IEnumerable<(string key, string value)> attributes)
 1429    {
 1430        var edges = sequence.ToList();
 1431        if (edges.Count > OrderCoder.MaxOrderHeadTail) throw new ArgumentException(
 032                $"Cannot add turn costs for vertices with more than {OrderCoder.MaxOrderHeadTail} edges.");
 33
 34        // make sure there is space in the turn cost array.
 1435        var maxLength = _globalRestrictionsPointer + 5 + 5 + 5 +
 1436                        (edges.Count * (9 + 5 + 5 + 5));
 2137        while (_globalRestrictions.Length < maxLength)
 738        {
 739            Array.Resize(ref _globalRestrictions, (int)(_globalRestrictions.Length + 256));
 740        }
 41
 42        // add turn.
 1443        var a = this.SetAttributes(attributes);
 1444        _globalRestrictionsPointer += _globalRestrictions.SetDynamicUInt32(_globalRestrictionsPointer, a);
 45        // Use Int64 so the sign-as-prohibitory-flag signal round-trips for any uint turnCostTypeId.
 46        // Int32 would silently wrap for ids with the high bit set; for typical small ids the encoded
 47        // byte sequence is identical to the previous Int32 encoding.
 1448        if (isProhibitory)
 1449        {
 50            // isProhibitory if turnCostTypeId is encoded as a positive number.
 1451            _globalRestrictionsPointer += _globalRestrictions.SetDynamicInt64(_globalRestrictionsPointer, (long)(turnCos
 1452        }
 53        else
 054        {
 55            // not isProhibitory if turnCostTypeId is encoded as a negative number.
 056            _globalRestrictionsPointer += _globalRestrictions.SetDynamicInt64(_globalRestrictionsPointer, -(long)(turnCo
 057        }
 1458        _globalRestrictionsPointer += _globalRestrictions.SetDynamicUInt32(_globalRestrictionsPointer, (uint)edges.Count
 9859        foreach (var (globalEdgeId, edgeId) in edges)
 2860        {
 2861            _globalRestrictionsPointer += _globalRestrictions.SetGlobalEdgeId(_globalRestrictionsPointer, globalEdgeId);
 2862            if (edgeId == null)
 1463            {
 1464                _globalRestrictionsPointer += _globalRestrictions.SetDynamicUInt32Nullable(_globalRestrictionsPointer,
 1465                    null);
 1466            }
 67            else
 1468            {
 1469                _globalRestrictionsPointer += _globalRestrictions.SetDynamicUInt32Nullable(_globalRestrictionsPointer,
 1470                    edgeId.Value.LocalId);
 1471            }
 2872        }
 1473    }
 74
 75    /// <summary>
 76    /// Gets all the global restrictions.
 77    /// </summary>
 78    /// <returns></returns>
 79    public IEnumerable<(IReadOnlyList<(GlobalEdgeId globalEdgeId, EdgeId? edgeId)> edges, bool isProhibitory, uint turnC
 80        IEnumerable<(string key, string value)> attributes)> GetGlobalRestrictions()
 2781    {
 2782        var pointer = 0L;
 4183        while (pointer < _globalRestrictionsPointer)
 1484        {
 1485            pointer += _globalRestrictions.GetDynamicUInt32(pointer, out var a);
 1486            pointer += _globalRestrictions.GetDynamicInt64(pointer, out var turnCostTypeSigned);
 87            uint turnCostType;
 88            bool isProhibitory;
 1489            if (turnCostTypeSigned > 0)
 1490            {
 1491                isProhibitory = true;
 1492                turnCostType = (uint)turnCostTypeSigned - 1;
 1493            }
 94            else
 095            {
 096                isProhibitory = false;
 097                turnCostType = (uint)(-turnCostTypeSigned - 1);
 098            }
 1499            pointer += _globalRestrictions.GetDynamicUInt32(pointer, out var edgeCount);
 14100            var edges = new (GlobalEdgeId globalEdgeId, EdgeId? edge)[edgeCount];
 84101            for (var i = 0; i < edgeCount; i++)
 28102            {
 28103                pointer += _globalRestrictions.GetGlobalEdgeId(pointer, out var globalEdgeId);
 28104                pointer += _globalRestrictions.GetDynamicUInt32Nullable(pointer,
 28105                    out var localId);
 106
 28107                EdgeId? edgeId = null;
 28108                if (localId != null)
 14109                {
 14110                    edgeId = new EdgeId(this.TileId, localId.Value);
 14111                }
 112
 28113                edges[i] = (globalEdgeId, edgeId);
 28114            }
 115
 14116            yield return (edges, isProhibitory, turnCostType, this.GetAttributes(a));
 14117        }
 27118    }
 119
 120    private void WriteGlobal(Stream stream)
 0121    {
 0122        stream.WriteVarUInt32(_globalRestrictionsPointer);
 0123        for (var i = 0; i < _globalRestrictionsPointer; i++)
 0124        {
 0125            stream.WriteByte(_globalRestrictions[i]);
 0126        }
 0127    }
 128
 129    private void ReadGlobal(Stream stream)
 0130    {
 0131        _globalRestrictionsPointer = stream.ReadVarUInt32();
 0132        _globalRestrictions = new byte[_globalRestrictionsPointer];
 0133        for (var i = 0; i < _globalRestrictionsPointer; i++)
 0134        {
 0135            _globalRestrictions[i] = (byte)stream.ReadByte();
 0136        }
 0137    }
 138
 139    private void ReadGlobal(byte[] data, ref int offset)
 0140    {
 0141        _globalRestrictionsPointer = BitCoderBuffer.GetVarUInt32(data, ref offset);
 0142        _globalRestrictions = new byte[_globalRestrictionsPointer];
 0143        Buffer.BlockCopy(data, offset, _globalRestrictions, 0, (int)_globalRestrictionsPointer);
 0144        offset += (int)_globalRestrictionsPointer;
 0145    }
 146
 147    private void WriteGlobal(byte[] data, ref int offset)
 0148    {
 0149        BitCoderBuffer.SetVarUInt32(data, ref offset, _globalRestrictionsPointer);
 0150        Buffer.BlockCopy(_globalRestrictions, 0, data, offset, (int)_globalRestrictionsPointer);
 0151        offset += (int)_globalRestrictionsPointer;
 0152    }
 153}

/home/runner/work/routing2/routing2/src/Itinero/Network/Tiles/Standalone/StandaloneNetworkTile.Serialization.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using Itinero.IO;
 4
 5namespace Itinero.Network.Tiles.Standalone;
 6
 7public partial class StandaloneNetworkTile
 8{
 9    public void WriteTo(Stream stream)
 010    {
 011        var version = 2;
 012        stream.WriteVarInt32(version);
 13
 14        // write base tile.
 015        this.NetworkTile.WriteTo(stream);
 16
 17        // write edges and vertices for boundary crossings.
 018        this.WriteEdgesAndVerticesTo(stream);
 19
 20        // write attributes.
 021        this.WriteAttributesTo(stream);
 22
 23        // write global ids.
 024        this.WriteGlobal(stream);
 025    }
 26
 27    private void WriteEdgesAndVerticesTo(Stream stream)
 028    {
 029        stream.WriteVarUInt32(_crossingsPointer);
 030        for (var i = 0; i < _crossingsPointer; i++)
 031        {
 032            stream.WriteByte(_crossings[i]);
 033        }
 034    }
 35
 36    public static StandaloneNetworkTile ReadFrom(Stream stream)
 037    {
 038        var version = stream.ReadVarInt32();
 039        if (version != 2)
 040        {
 041            throw new InvalidDataException("Cannot deserialize tiles: Invalid version #.");
 42        }
 43
 044        var networkTile = NetworkTile.ReadFrom(stream);
 045        var standaloneNetworkTile = new StandaloneNetworkTile(networkTile);
 46
 47        // read boundary crossings.
 048        standaloneNetworkTile.ReadEdgesAndVerticesFrom(stream);
 49
 50        // read attributes.
 051        standaloneNetworkTile.ReadAttributesFrom(stream);
 52
 53        // read global.
 054        standaloneNetworkTile.ReadGlobal(stream);
 55
 056        return standaloneNetworkTile;
 057    }
 58
 59    private void ReadEdgesAndVerticesFrom(Stream stream)
 060    {
 61        // read vertex pointers.
 062        _crossingsPointer = stream.ReadVarUInt32();
 063        _crossings = new byte[_crossingsPointer];
 064        for (var i = 0; i < _crossingsPointer; i++)
 065        {
 066            _crossings[i] = (byte)stream.ReadByte();
 067        }
 068    }
 69
 70    public static StandaloneNetworkTile ReadFrom(byte[] data, int offset)
 071    {
 072        var version = BitCoderBuffer.GetVarInt32(data, ref offset);
 073        if (version != 2)
 074        {
 075            throw new InvalidDataException("Cannot deserialize tiles: Invalid version #.");
 76        }
 77
 078        var networkTile = NetworkTile.ReadFromBuffer(data, ref offset);
 079        var standaloneNetworkTile = new StandaloneNetworkTile(networkTile);
 80
 081        standaloneNetworkTile.ReadEdgesAndVerticesFrom(data, ref offset);
 082        standaloneNetworkTile.ReadAttributesFrom(data, ref offset);
 083        standaloneNetworkTile.ReadGlobal(data, ref offset);
 84
 085        return standaloneNetworkTile;
 086    }
 87
 88    private void ReadEdgesAndVerticesFrom(byte[] data, ref int offset)
 089    {
 090        _crossingsPointer = BitCoderBuffer.GetVarUInt32(data, ref offset);
 091        _crossings = new byte[_crossingsPointer];
 092        Buffer.BlockCopy(data, offset, _crossings, 0, (int)_crossingsPointer);
 093        offset += (int)_crossingsPointer;
 094    }
 95
 96    public byte[] ToBytes()
 097    {
 098        var maxSize = this.GetSerializedSizeUpperBound();
 099        var buffer = new byte[maxSize];
 0100        var offset = 0;
 0101        this.WriteToBuffer(buffer, ref offset);
 0102        if (offset == maxSize) return buffer;
 0103        var result = new byte[offset];
 0104        Buffer.BlockCopy(buffer, 0, result, 0, offset);
 0105        return result;
 0106    }
 107
 108    private void WriteToBuffer(byte[] data, ref int offset)
 0109    {
 110        const int version = 2;
 0111        BitCoderBuffer.SetVarInt32(data, ref offset, version);
 112
 0113        this.NetworkTile.WriteToBuffer(data, ref offset);
 0114        this.WriteEdgesAndVerticesTo(data, ref offset);
 0115        this.WriteAttributesTo(data, ref offset);
 0116        this.WriteGlobal(data, ref offset);
 0117    }
 118
 119    private void WriteEdgesAndVerticesTo(byte[] data, ref int offset)
 0120    {
 0121        BitCoderBuffer.SetVarUInt32(data, ref offset, _crossingsPointer);
 0122        Buffer.BlockCopy(_crossings, 0, data, offset, (int)_crossingsPointer);
 0123        offset += (int)_crossingsPointer;
 0124    }
 125
 126    private int GetSerializedSizeUpperBound()
 0127    {
 0128        var size = 5;
 0129        size += this.NetworkTile.GetSerializedSizeUpperBound();
 130
 0131        size += 5 + (int)_crossingsPointer;
 132
 0133        size += 5 + (int)_nextAttributePointer;
 0134        size += 5;
 0135        for (var i = 0; i < _nextStringId; i++)
 0136        {
 0137            size += 8 + System.Text.Encoding.Unicode.GetByteCount(_strings[i]);
 0138        }
 139
 0140        size += 5 + (int)_globalRestrictionsPointer;
 141
 0142        return size;
 0143    }
 144}