Exemplo n.º 1
0
        static int ReadNodesPath(byte[] buf, int ofs, out OsmNode[] nodes)
        {
            ulong tmp;
            int   p = ProtoBuf.ReadVarInt(buf, ofs, out tmp);

            nodes = new OsmNode[tmp];
            for (int i = 0; i < nodes.Length; i++)
            {
                p += OsmNode.ReadBinary(buf, ofs + p, out nodes[i]);
            }
            return(p);
        }
Exemplo n.º 2
0
        OsmRelation GetRelationData(long relationIndex, out OsmWay[] osmWays, out OsmNode[] osmNodes)
        {
            var buf = cacheBuffer;

            cacheData.Position = relationIndex;
            cacheData.Read(buf, 0, sizeof(int));

            int size = BitConverter.ToInt32(buf, 0) - sizeof(int);

            if (cacheData.Read(buf, sizeof(int), size) != size)
            {
                throw new IOException("EOF?");
            }

            int         p = sizeof(int);
            OsmRelation osmRelation;

            p += OsmRelation.ReadBinary(buf, p, out osmRelation);
            ulong tmp;

            p      += ProtoBuf.ReadVarInt(buf, p, out tmp);
            osmWays = new OsmWay[tmp];
            for (int i = 0; i < osmWays.Length; i++)
            {
                p += OsmWay.ReadBinary(buf, p, out osmWays[i]);
            }
            DecodeDelta(osmWays);
            p       += ProtoBuf.ReadVarInt(buf, p, out tmp);
            osmNodes = new OsmNode[tmp];
            for (int i = 0; i < osmNodes.Length; i++)
            {
                p += OsmNode.ReadBinary(buf, p, out osmNodes[i]);
            }
            DecodeDelta(osmNodes);
            if (p != size + sizeof(int))
            {
                throw new PbfParseException();
            }

            return(osmRelation);
        }