Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #933 +/- ##
===========================================
+ Coverage 56.61% 56.67% +0.06%
===========================================
Files 969 973 +4
Lines 24667 24704 +37
Branches 5009 5017 +8
===========================================
+ Hits 13966 14002 +36
- Misses 8483 8484 +1
Partials 2218 2218
☔ View full report in Codecov by Sentry. |
8b36899 to
7dd5251
Compare
|
I don't think we want to do this. Changing the size of the map we request affects the information density returned in the image. On an
iOS has the same behaviour as the old code: they pass the size in points to MapTiler, which will be 2x or 3x smaller than the number of pixels depending on the device. (Presumably, on 3x devices the map isn't "pixel perfect" either) |
That's not what this code does: Requested dimension is halved for @2x images thereby yielding the same pixel size static image but with twice the resolution (i.e. zoomed in). |
Ah, I missed that. As it happens, that's exactly what I did when I first implemented it (halving the pixel count and requesting |
|
You can see the zoom out in the second image as well, and that zoom will change based on the density of the device, which we don't want. If you find a device with a density double your current one, it'll look like the bottom image, right? |
Yes, and on the same device the current implementation will look twice as more blurred. I don't think there's a right choice here: both choices have pros and cons. So either we keep the sharpness constant at the expense of a decreased content size. |
|
IMO if the lack of crispness is an issue we should look at alternatives to maptiler that can provide images in the right density rather than just 1x and 2x (or at least provide controls for the map area separate to the dimensions of the static map). [But obviously that's probably out of scope for this initial implementation 😓 ] |
|
Just putting again the screenshots from previous comment but in a table so that we can compare easily
|
|
Thanks! The table helps to evaluate and compare the various content sizes, but to evaluate sharpness the images should be looked at 100% size (or even better by running the code on a screen of a real device). |
bmarty
left a comment
There was a problem hiding this comment.
I have no particular remark on the code, but maybe what can be strange is that the event will be rendered differently between 2 devices. Also I think user can still open the map fullscreen by clicking on it and zoom as they want, so I think it's fine.
| val width = if (retina) width / 2 else width | ||
| val height = if (retina) height / 2 else height | ||
| val scale = if (retina) "@2x" else "" | ||
| return "${baseUrl}/${mapId}/static/${lon},${lat},${zoom}/${width}x${height}${scale}.webp?key=${apiKey}&attribution=bottomleft" |
There was a problem hiding this comment.
FTR, attribution was managed manually on Element Android since the rendering was declared too small, and on the new screenshots of this PR, they are smaller again (and truncated due to the round corner). More info in element-hq/element-android#6247. I am not sure if it was in your radar, so now you know!
|
Just to illustrate the pathological case, this is what a Sony Xperia Z5 Premium would look like:
And this is what it looks like in eleweb: |
Request static images with the correct pixel size to match the screen pixels. @2x images will be requested on xhdpi or higher devices.
Don't request bigger image size on displays denser than 2x. Handle weird image sizes without crashing.
7dd5251 to
1ea4c5f
Compare
…asier customization by forks.
1ea4c5f to
c3b82f5
Compare
@csmith You hit the nail on the head. To properly (i.e. with a correct content size) rasterize a vector image (such as a map) we need 2 things:
We can easily get this information from the Android OS but MapTiler's static map API doesn't take it as an input. It effectively only allows 1 and 2 as scaling factors. I've changed the PR to basically keep the existing behavior but with a few tweaks:
|
csmith
left a comment
There was a problem hiding this comment.
LGTM, thanks!
I added a small doc in docs/maps.md about passing in properties and forking etc, I guess that probably needs a slight update now
|
Done! |
|
Kudos, SonarCloud Quality Gate passed! |














Related to: