예제 #1
0
        public int date_granularity = 1000;                                        // 18

        internal static PrimitiveBlock Read(Stream stream)
        {
            PrimitiveBlock obj = new PrimitiveBlock();
            int            b   = stream.ReadByte();

            if (b != 10)
            {
                throw new NotImplementedException();
            }
            obj.stringtable = StringTable.Read(stream);
            b = stream.ReadByte();
            while (b == 18)
            {
                obj.primitivegroup.Add(PrimitiveGroup.Read(stream));
                b = stream.ReadByte();
            }
            // NOTE: looks like those OSMSharp broken up files don't have any of these
            if (b == 136)
            {
                obj.granularity = (int)OSMReader.ReadVarInt(stream);
                b = stream.ReadByte();
            }
            if (b == 152)
            {
                obj.lat_offset = OSMReader.ReadVarInt(stream);
                b = stream.ReadByte();
            }
            if (b == 160)
            {
                obj.lon_offset = OSMReader.ReadVarInt(stream);
                b = stream.ReadByte();
            }
            if (b == 144)
            {
                obj.date_granularity = (int)OSMReader.ReadVarInt(stream);
                b = stream.ReadByte();
            }
            if (b != -1)
            {
                throw new NotImplementedException();
            }
            return(obj);
        }
예제 #2
0
        internal static StringTable Read(Stream stream)
        {
            StringTable obj    = new StringTable();
            long        length = OSMReader.ReadVarInt(stream);
            long        end    = stream.Position + length;

            obj.vals = new List <string>();
            while (stream.Position < end)
            {
                int b = stream.ReadByte();
                if (b != 10)
                {
                    throw new NotImplementedException();
                }
                obj.vals.Add(OSMReader.ReadString(stream));
            }
            if (stream.Position != end)
            {
                throw new NotImplementedException();
            }
            return(obj);
        }
예제 #3
0
        public List <long> refs = new List <long>(); // 8, packed, signed, delta coded

        internal static Way Read(Stream stream)
        {
            Way  obj           = new Way();
            long lengthInBytes = OSMReader.ReadVarInt(stream);
            long end           = stream.Position + lengthInBytes;
            int  b             = stream.ReadByte();

            if (b != 8)
            {
                throw new NotImplementedException();
            }
            obj.id = OSMReader.ReadVarInt(stream);
            b      = stream.ReadByte();
            if (b == 18)
            {
                obj.keys = OSMReader.ReadPackedVarInts(stream).ConvertAll(x => (int)x).ToList();
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 26)
            {
                obj.vals = OSMReader.ReadPackedVarInts(stream).ConvertAll(x => (int)x).ToList();
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 34)
            {
                //obj.info = Info.Read(stream);
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 66)
            {
                obj.refs = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            throw new NotImplementedException();
        }
예제 #4
0
        internal static DenseNodes ReadNodeStart(MemoryStream stream)
        {
            DenseNodes obj           = new DenseNodes();
            long       lengthInBytes = OSMReader.ReadVarInt(stream);
            long       end           = stream.Position + lengthInBytes;
            int        b             = stream.ReadByte();

            if (b == 10)
            {
                obj.id = new List <long>();
                long length = OSMReader.ReadVarInt(stream);
                if (length > 0)
                {
                    obj.id.Add(OSMReader.ReadSignedVarInt(stream));
                }
                stream.Seek(end, SeekOrigin.Begin);
                return(obj);
            }
            if (b == 42)
            {
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 66)
            {
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 74)
            {
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 82)
            {
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            throw new NotImplementedException();
        }
예제 #5
0
        public List <int> keys_vals = new List <int>();  // 10, packed

        internal static DenseNodes Read(Stream stream)
        {
            DenseNodes obj           = new DenseNodes();
            long       lengthInBytes = OSMReader.ReadVarInt(stream);
            long       end           = stream.Position + lengthInBytes;
            int        b             = stream.ReadByte();

            if (b == 10)
            {
                obj.id = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                b      = stream.ReadByte();
            }
            if (b == 42)
            {
                //obj.denseinfo = DenseInfo.Read(stream);
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 66)
            {
                obj.lat = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 74)
            {
                obj.lon = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 82)
            {
                //obj.keys_vals = OSM.ReadPackedVarInts(stream).ConvertAll(x => (int)x).ToList();
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            throw new NotImplementedException();
        }
예제 #6
0
        public List <bool> visible;   // 6, packed

        internal static DenseInfo Read(Stream stream)
        {
            DenseInfo obj           = new DenseInfo();
            long      lengthInBytes = OSMReader.ReadVarInt(stream);
            long      end           = stream.Position + lengthInBytes;
            int       b             = stream.ReadByte();

            if (b == 10)
            {
                obj.version = OSMReader.ReadPackedVarInts(stream).ConvertAll(x => (int)x).ToList();
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 18)
            {
                obj.timestamp = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 26)
            {
                obj.changeset = OSMReader.ReadPackedDeltaCodedVarInts(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 34)
            {
                obj.uid = OSMReader.ReadPackedDeltaCodedVarInts(stream).ConvertAll(x => (int)x).ToList();
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 42)
            {
                obj.user_sid = OSMReader.ReadPackedDeltaCodedVarInts(stream).ConvertAll(x => (int)x).ToList();
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 50)
            {
                OSMReader.SkipBytes(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            throw new NotImplementedException();
        }
예제 #7
0
        public bool visible;     // 6

        internal static Info Read(Stream stream)
        {
            Info obj           = new Info();
            long lengthInBytes = OSMReader.ReadVarInt(stream);
            long end           = stream.Position + lengthInBytes;
            int  b             = stream.ReadByte();

            if (b == 8)
            {
                obj.version = (int)OSMReader.ReadVarInt(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 16)
            {
                obj.timestamp = (int)OSMReader.ReadVarInt(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 24)
            {
                obj.changeset = OSMReader.ReadVarInt(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 32)
            {
                obj.uid = (int)OSMReader.ReadVarInt(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 40)
            {
                obj.user_sid = (int)OSMReader.ReadVarInt(stream);
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            if (b == 48)
            {
                obj.visible = OSMReader.ReadVarInt(stream) == 1;
                if (stream.Position > end)
                {
                    throw new NotImplementedException();
                }
                if (stream.Position == end)
                {
                    return(obj);
                }
                b = stream.ReadByte();
            }
            throw new NotImplementedException();
        }
예제 #8
0
        public List <ChangeSet> changesets = new List <ChangeSet>();  // 5

        internal static PrimitiveGroup Read(Stream stream)
        {
            PrimitiveGroup obj           = new PrimitiveGroup();
            long           lengthInBytes = OSMReader.ReadVarInt(stream);
            long           end           = stream.Position + lengthInBytes;
            int            b             = stream.ReadByte();

            while (b == 10 || b == 18 || b == 26 || b == 34 || b == 42)
            {
                if (b == 10)
                {
                    OSMReader.SkipBytes(stream);
                    if (stream.Position > end)
                    {
                        throw new NotImplementedException();
                    }
                    if (stream.Position == end)
                    {
                        return(obj);
                    }
                    b = stream.ReadByte();
                }
                else if (b == 18)
                {
                    obj.dense.Add(DenseNodes.Read(stream));
                    if (stream.Position > end)
                    {
                        throw new NotImplementedException();
                    }
                    if (stream.Position == end)
                    {
                        return(obj);
                    }
                    b = stream.ReadByte();
                }
                else if (b == 26)
                {
                    obj.ways.Add(Way.Read(stream));
                    if (stream.Position > end)
                    {
                        throw new NotImplementedException();
                    }
                    if (stream.Position == end)
                    {
                        return(obj);
                    }
                    b = stream.ReadByte();
                }
                else if (b == 34)
                {
                    obj.relations.Add(Relation.Read(stream));
                    if (stream.Position > end)
                    {
                        throw new NotImplementedException();
                    }
                    if (stream.Position == end)
                    {
                        return(obj);
                    }
                    b = stream.ReadByte();
                }
                else if (b == 42)
                {
                    OSMReader.SkipBytes(stream);
                    if (stream.Position > end)
                    {
                        throw new NotImplementedException();
                    }
                    if (stream.Position == end)
                    {
                        return(obj);
                    }
                    b = stream.ReadByte();
                }
            }
            throw new NotImplementedException();
        }