mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

Get StyleOptimisedVectorTile data from an AbstractMap implementation [Question]

Open Alexphauge opened this issue 9 years ago • 10 comments

Hello,

I was wondering if it would be possible to grab the vector data from the already build map, instead of doing as per the VectorTileExample where we create a new map and it has a specific MapId and is of type VectorTile. We're only interested in what is actually used (Therefore the StyleOptimisedVector was really nice for us 👍) but we're also interested in skinning using the data.

I might just have missed how it works, but well, if you have time to explain how I would appreciate it a whole bunch. :)

Thanks!

Alexphauge avatar Aug 15 '17 13:08 Alexphauge

@Alexphauge I'm a bit confused by this question. Style-optimized vector tiles are a way of requesting "filtered" vector tiles from our servers (using a style). Read more here: https://www.mapbox.com/api-documentation/#retrieve-tiles.

It sounds like you want to access vector tile data in Unity after you've already had the factories build the map? Well, if you have a reference to a UnityTile, it contains the VectorData. Alternatively, you can request data from any FeatureBehaviour generated.

If I misunderstood your question, can you please clarify? Thank you!

david-rhodes avatar Aug 15 '17 14:08 david-rhodes

Elaborating on style-optimized vector tiles: let's say you create a style and the only layer you add is building. When you use that style's MapId with a StyleOptimizedVectorTileFactory, you will only get the building layer from the returned vector tile.

david-rhodes avatar Aug 15 '17 14:08 david-rhodes

Yep, that was exactly what I was looking for, both with regards to the style optimized and the vectordata on UnityTiles. Thanks a lot!

Alexphauge avatar Aug 15 '17 14:08 Alexphauge

@Alexphauge Uhh, I just remembered that VectorData is not currently hooked up. IIRC, this was by design as we didn't want to cache the entire JSON string (and string operations are slow). We can and should improve this, however. Can you describe your use-case?

david-rhodes avatar Aug 15 '17 14:08 david-rhodes

Right now, I think we're just at a stage where we are trying to get the right look in our application. The designers thought we might need the entire JSON for this, so I was just planning ahead, making sure we actually could access the JSON. There'll be some design meetings for the next weeks time, so I might be able to come back to you with a specific use-case. :)

And that other error just took my attention, so I'm in no hurry with this anymore.

Alexphauge avatar Aug 15 '17 14:08 Alexphauge

Little reminder: tile data shouldn't be converted to or stored in GeoJSON format at all - these strings can get real huge real fast.

Addtionally, the ToGeoJson() methods of the underlying vector-tile-cs library are going to be removed some time in the not too distant future. Probably during the next (already looming) refactor. They are by no means properly coded and only served for debugging during early development of vector-tile-cs.

wilhelmberg avatar Aug 15 '17 15:08 wilhelmberg

Yeah, that was also my immediate concern looking at the VectorTileExample. Getting a string for my location brought the string to 28000 characters, I can't even imagine a place where there's proper information.

Alexphauge avatar Aug 16 '17 07:08 Alexphauge

I'm sure you could cache the pieces you are interested in or the raw data itself.

david-rhodes avatar Aug 16 '17 13:08 david-rhodes

Yeah, i'm thinking the same. - I am still interested in grabbing the style optimized GeoJSON though, if that's possible, and then possibly serialize that to what we need. It seems they would like to put in some form of ruined buildings in certain building spaces. I'm not entirely sure how to go about this as it's not a final design or anything, but having access to the style optimized GeoJSON was probably a good start. At least in my head... Could probably end up being able to use your modifiers/layers/factories setup. Feel free to close this down though, as I can't provide a specific use-case right now, I can just open a new thread when I get one ^^

Alexphauge avatar Aug 21 '17 12:08 Alexphauge

@Alexphauge Let me know when you have a more concrete use-case and we can help guide you in the right direction/update the SDK.

david-rhodes avatar Aug 21 '17 15:08 david-rhodes