mapbox / mapbox-sdk-cs

C# libraries for Mapbox API layer
https://mapbox.github.io/mapbox-sdk-cs/
Other
20 stars 11 forks source link

Handle "Tile does not exist" in tile responses #73

Closed david-rhodes closed 7 years ago

david-rhodes commented 7 years ago

Reference: https://github.com/mapbox/mapbox-unity-sdk/issues/45

Rather than catching that a tile does not exist, we try to parse the raw bytes (which is not a .pbf), and this eventually leads to a ParseError. I can see this being a common issue with custom tilesets as tiles are not generated for regions with no data.

@BergWerkGIS What is the most elegant way to solve this? I doubt we really want to throw an exception. . .

wilhelmberg commented 7 years ago

@david-rhodes vector-tile-cs will continue throwing exceptions on errors and we won't change that.

mapbox-sdk-cs catches the exception and sets sets the error message correctly here.

Unfortunately the detailed error message gets overwritten with "ParserError" here.

Quick fix would be to remove this.error = "ParseError"; to get the error message stemming from vector-tile-cs.

However I don't like string properties as indicators for failure. Reminder: As we've seen full .Net Framework "initializes" strings to null whereas UWP/Windows Desktop/Store initializes them to "", so checking for errors that way poses to be very error prone.

I'd like to see something similar to the current refactoring of HTTPRequest:


wrt https://github.com/mapbox/mapbox-unity-sdk/issues/45

After current refactoring of HTTPRequest is in place the code shouldn't even get to decoding the vector tile as the Reponse will have the HasErrorproperty set, because of the 404 for the request:

image

david-rhodes commented 7 years ago

@BergWerkGIS Glad to see this will be refactored. However, after removing this.error = "ParseError", the error message then becomes Unknown tile tag: 15 which does not tell us the tile is missing. Is the request technically a 404? I don't see that in my browser.

wilhelmberg commented 7 years ago

@david-rhodes everything already done and awaiting your review:

https://github.com/mapbox/mapbox-sdk-cs/pull/75 https://github.com/mapbox/mapbox-unity-sdk/pull/47

If a 404 is received it won't even be passed to vector-tile-cs: https://github.com/mapbox/mapbox-sdk-cs/blob/BergWerkGIS-multithread-filesource/src/Map/Tile.cs#L162-L176

Is the request technically a 404? I don't see that in my browser.

Yes. You can get a 404 and some data as well, like in this case. Browsers normally don't show the status code of the response.

wilhelmberg commented 7 years ago

Done in #75