Mapillary object tiles at lower zoom levels
A recurring pain point while adding turn restrictions is not being able to have a high level overview of detected restrictions in a city, since the Mapillary vector tiles start at z14.
Would be great to have detected turn restrictions available at lower zoom levels from z10, and other objects available at higher zoom levels.
cc @gyllen @geohacker @ajithranka
@planemad Can we solve this by instead using a heatmap for lower than 14?
@gyllen this will work, any indiction to know where to zoom into helps.
@planemad You have any ideas of what you want in the heatmap (as properties)
@gyllen for now, per tile:
- total count of turn restriction objects (most important)
- total count of all objects
- first object date
- latest object date
In Berlin for instance, we're seeing no turn restrictions highlighted at z14, so it like finding a needle in a haystack at this level http://mapbox.github.io/osm-navigation-map/#14.4/52.4402/13.3576
If we zoom out, we would highlight those tiles that have at least one restriction and prioritized by the freshness of the data
@planemad So maybe a filter to the tile where you can say a prefix, something like
objects_heatmap?prefix_filter=prohibitory--no-right-turn,prohibitory--no-u-turn
Then the tile will give you prohibitory--no-right-turn:{COUNT FOR TILE} prohibitory--no-right-turn_first-seen-at:{DATE} prohibitory--no-right-turn_last-seen-at:{DATE}
prohibitory--no-u-turn:{COUNT FOR TILE} prohibitory--no-u-turn_first-seen-at:{DATE} prohibitory--no-u-turn_last-seen-at:{DATE}
total-count:{ALL FILTERED COBJECTS COUNT}
What do you think?
@gyllen perfect!
@planemad I finally had a couple of hours to fix this. Sorry for the delay. So I made the API easier.
Add objects_heatmap=true to the dynamic vector tile url and it should give you heatmaps all the way down to level 8. In the tile I will return all availble signs when they were first seen and last seen.
So example https://a.mapillary.com/v3/tiles/{z}/{x}/{y}.mapbox?objects_heatmap=true&client_id={CLIENT_ID}
Will give you properties for all signs in the following pattern {SIGN_KEY}:{COUNT FOR TILE} {SIGN_KEY}_first_seen_at:{DATE} {SIGN_KEY}_last_seen_at:{DATE}
The tile will have ONE feature having all this properties centered in the tile
A couple of caveats
- You can combine objects for the tile if you want and get more layers, I would stay away from that though since it potentially be pretty slow.
- I have not tested the tiles visually so there might be some problems, backend tests goes through though and from what I can see they look correct.
- Query does not seem that heavy since db is really good at aggregations. But when you try this out can you try to limit the source so that it only gets heatmap from ONE zoomlevel. Maybe TWO but then as a different source since you can't (what I know of) jump zoom levels.
Let me know if this works and Im excited to see if it works :)
💥 @gyllen , i'm out on the road over the weekend, will give this a try on Tue. cc @amishas157
cc @geohacker @ajithranka
@ajithranka per voice:
- When z<14
- Show markers on those tiles where there are any detected restriction signs captured in the last 30 days
@planemad Im curious, does the heatmap tiles work out for you guys?
@gyllen I'll be spending some time trying it out this week. Will share what I have soon. :-)
@gyllen, @planemad, @batpad, @geohacker
I tried out objects_heatmap layer and am able to render the counts for one particular traffic sign class (regulatory--no-left-or-u-turn--us) between zoom 8 to 14. Please try out the map here.
A couple of questions:
- Ideally I would want to show only the counts for zoom 14 tile centres but render it between zoom levels 8 to 14. I don't think there's a straight forward way to do this is GL. In the above map though, rendering between 8 and 14 is pretty fast.
- Can we show the count of all traffic signs detected within last 30 days or so? There are two problems here.
- Getting the total count. I can pull out the individual count for each class, but I don't see a way of summing these up in the map layer.
-
Filtering for last 30 days. I'm not clear on what
*_first-seen-atand*_last-seen-atrefer to. Is it the timestamp of the first seen object and the last seen object in that tile? If there are 30 objects in a tile out of which 15 were detected last month, I can't get that count (15) from just*_first-seen-atand*_last-seen-at.
Let me know what you think. I might have misunderstood something.
Capturing some notes from discussions with @planemad, @batpad and @geohacker.
- The actual count of newly detected objects within the last month is useful but not necessary. Just having an indication of whether or not there are recently detected objects in a tile should be good enough for now. Later, we might try out using a time slider for checking newly detected objects within say last day, last week or last month.
- We can use
querySourceFeatureson the vector tile to get the geojson and aggregate it directly andsetDatato a layer. SincequerySourceFeaturesis limited to the current viewport, this will need to run each time the viewport changes (like zoom or drag events). I'll be trying this out now.
@ajithranka I can give you a total count though if you want to. But you really just want it for the classes your are interested in as I understand it.
So *_first-seen-at and *_last-seen-at is exactly that. Remember that every object consist of multiple images. Thats why we give it a span, when the first image was captured that inlucded the sign and when the last image was captured that included the sign.
@gyllen @geohacker I tried using querySourceFeatures to get a features array from objects_heatmap but it fails with an uncaught type error e.renderedIDs is not a function.
See: http://bl.ocks.org/ajithranka/82059d49a452856307f81c27ff866cec
Debugging it a little more, it looks like it's not recognized as a valid protobuffer. After downloading one vector tile (https://a.mapillary.com/v3/tiles/10/163/395.mapbox?objects_heatmap=true&client_id=MFo5YmpwMmxHMmxJaUt3VW14c0ZCZzphZDU5ZDBjNTMzN2Y3YTE3) if I run pbf, I get
$ pbf 395.mapbox > 395.json
col-buffers-schema/parse.js:587
throw new Error('Unexpected token: ' + tokens[0])
The conversion fails at this point: https://github.com/mapbox/pbf/blob/master/index.js#L195.
Interestingly, the layer still renders on the map. Could this be a problem with the vector tile?
Turned out to be a GL issue. Switching to the latest version fixed it. 🌵
@ajithranka Nice, let me know if you guys are missing anything else in the tile.
@ajithranka are we still on this?
@planemad Yeah It would be cool to see this in live action
We will be getting back to turn restriction mapping next week and will be looking into this again.