wdtinc / mapbox-vector-tile-java

Java Mapbox Vector Tile Library for Encoding/Decoding
Apache License 2.0
147 stars 73 forks source link

Decoding tiles from Thunderforest results in InvalidProtocolBufferException #21

Closed boldtrn closed 6 years ago

boldtrn commented 6 years ago

I am not exactly sure why this happens, but when I try to decode tiles from ThunderForest, I receive an Exception:

com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.
        at com.google.protobuf.InvalidProtocolBufferException.truncatedMessage(InvalidProtocolBufferException.java:70)
        at com.google.protobuf.CodedInputStream.readRawBytesSlowPath(CodedInputStream.java:1211)
        at com.google.protobuf.CodedInputStream.readBytes(CodedInputStream.java:517)
        at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:516)
        at com.google.protobuf.UnknownFieldSet$Builder.mergeFrom(UnknownFieldSet.java:493)
        at com.google.protobuf.UnknownFieldSet$Builder.mergeFrom(UnknownFieldSet.java:611)
        at com.google.protobuf.UnknownFieldSet$Builder.mergeFrom(UnknownFieldSet.java:281)
        at com.google.protobuf.CodedInputStream.readGroup(CodedInputStream.java:424)
        at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:520)
        at com.google.protobuf.MessageReflection.mergeFieldFrom(MessageReflection.java:757)
        at com.google.protobuf.GeneratedMessage$ExtendableMessage.parseUnknownField(GeneratedMessage.java:847)
        at com.wdtinc.mapbox_vector_tile.VectorTile$Tile.<init>(VectorTile.java:77)
        at com.wdtinc.mapbox_vector_tile.VectorTile$Tile.<init>(VectorTile.java:43)
        at com.wdtinc.mapbox_vector_tile.VectorTile$Tile$1.parsePartialFrom(VectorTile.java:4802)
        at com.wdtinc.mapbox_vector_tile.VectorTile$Tile$1.parsePartialFrom(VectorTile.java:4796)
        at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:192)
        at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:210)
        at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:215)
        at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
        at com.wdtinc.mapbox_vector_tile.VectorTile$Tile.parseFrom(VectorTile.java:4341)
        at com.wdtinc.mapbox_vector_tile.adapt.jts.MvtReader.loadMvt(MvtReader.java:120)

I haven't debugged this in greater detail. So I don't know if this an issue from Thunderforest or from this library. Thunderforest specifies that they encode in the MVT schema. But I hadn't had any problems decoding tiles from other providers so far.

Since probably not everyone wants to sign up for a key to try this, I attached one tile from ThunderForest in this issue, downloaded from: https://tile.thunderforest.com/thunderforest.transport-v1.json?apikey={apikey} thunderforest.vector.pbf.zip

snodnipper commented 6 years ago

I am just taking a look. Using our vt-support tools I am not getting an issue. I'll check out master to identify the issue.

screen shot 2018-01-18 at 11 53 58
snodnipper commented 6 years ago

I am not getting an issue on master. Perhaps you can check out MvtReaderTest and work from there.

screen shot 2018-01-18 at 12 02 22
ShibaBandit commented 6 years ago

Are you using master branch source or a maven release?

boldtrn commented 6 years ago

Are you using master branch source or a maven release?

I used 2.0.0 from Maven. Thanks for your tests :). I actually only tested it for VTM and did not test this for this repo exclusively. It works when I just use com.wdtinc.mapbox_vector_tile.adapt.jtsMvtReaderTest. Furthermore I don't receive any exceptions, but only an empty jtsMvt if I read the file locally. If I use a stream provided by OkHttp, I saw this exception.

For some reason Gradle won't use my local MvnRepo (even though I configured it to do so) where I installed the current master 3.0.0., so I will just wait for 3.0.0 to be released. It's not really important for me at the moment, so it's easier just to wait :). I will close this issue, as it works perfect with the current master.