Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Tangram with Maplibre #5693

Merged
merged 298 commits into from
Aug 14, 2024
Merged

Conversation

westnordost
Copy link
Member

@westnordost westnordost commented Jun 17, 2024

by @Helium314 and me.

This PR is the same as Helium314#516 only that it merges to vanilla StreetComplete.

Visible differences to Tangram-ES

  • improved style, e.g. private roads, rails and paths look better now, some issues with the old style were solved and bridges / tunnels render more correct now
  • can zoom in much further
  • quest dots are clustered on low zoom
  • no 3D building except in the buildings overlay. (They don't look so good with MapLibre)
  • icons in building overlay have no white outline anymore (technical limitation)
  • color of icons in places and things overlay adapts to day/night mode
  • color of text in overlays adapt to day/night mode
  • animation on selecting (quest) pin
  • (better) animation on selecting elements in an overlay
  • improved memory consumption
  • location accuracy circle doesn't get blurry when it is large
  • (of course, no tangram bugs. For example those flickering quest pins when zooming back out, that was horrible)
  • (... anything more?)

Blocked by

Known bugs

Remarks

  • displaying overlay and quests in the currently visible map section is implemented manually. Could potentially be removed when CustomGeometrySourceOptions.withClip always enabled? maplibre/maplibre-native#2262 is fixed
  • location dot, accuracy circle and view direction has been implemented manually because MapLibre's own LocationComponent didn't look good and felt jerky. If that changes in the future, the own rendering could be replaced

Helium314 and others added 30 commits February 22, 2024 12:01
- the single components own the sources now
- make sure that all of this UI stuff is called on the UI thread
@westnordost
Copy link
Member Author

Is MapLibre still trying to download more glyphs when offline? (It should appear in the log)
Because now, I would say, it shouldn't, because it should recognize that the glyphs should not be considered stale at least for 12 hours.

@Helium314
Copy link
Collaborator

I was unable to reproduce it until I noticed the problem was actually switching to the places overlay, which also seems to require glyphs that are not pre-downloaded.

Is there a way to make sure that overlay texts only use glyphs that are already downloaded together with tiles? Or maybe MapLibre should use some fallback instead of (whatever causes this bug)?

@westnordost
Copy link
Member Author

westnordost commented Aug 13, 2024

Hmm... perhaps it is possible to have all the font glyphs locally already. As long as one doesn't go wild with different fonts and font weights, it is not that much in terms of file size.

Not sure how to refer to them in the style JSON though.

They can be downloaded here: https://github.com/kylebarron/openmaptiles-fonts/tree/master/fonts

(Otherwise, ) does MapLibre download them as files into the app cache directory, or again into some database? If the former, it should be possible to download them all beforehand manually (like we did with tangram tiles).

Edit: Could try with asset://..., apparently it works for sprites, maybe it does work for glyphs, too.

@Helium314
Copy link
Collaborator

Edit: Could try with asset://..., apparently it works for sprites, maybe it does work for glyphs, too.

This works nicely, I wasn't able to reproduce the bug so far when having glyphs in assets!


One more issue I noticed: Sometimes switching between overlays takes a second or so. When I select an element of the old overlay before the new map features are set, I can e.g. set the address of a waste bin. It should be better for most users due to faster phone and non-debug version, but still should not happen.
Perhaps we should clear the overlay before doing the switch, or give each feature some overlay property that is checked on selecting the feature.

@westnordost
Copy link
Member Author

westnordost commented Aug 13, 2024

This works nicely, I wasn't able to reproduce the bug so far when having glyphs in assets!

Hm!

🎉?

Is this the workaround we have been looking for all this time?

(Is it possible to also specify the streetcomplete.json itself to sit in the assets folder? Currently for offline download, we have to have this remote duplicate of the streetcomplete.json)


Regarding the issue: Well, sounds like that would make sense. (The first, if it doesn't work, the second)

@Helium314
Copy link
Collaborator

Is this the workaround we have been looking for all this time?

Really looks like it is. So I'll put the fonts to assets.

Is it possible to also specify the streetcomplete.json itself to sit in the assets folder?

Unable to parse resourceUrl asset://map_theme/streetcomplete.json

@westnordost
Copy link
Member Author

Is this the workaround we have been looking for all this time?

Really looks like it is. So I'll put the fonts to assets.

But then I have to change the remove streetcomplete.json, too. I hope that works with the offline downloader

@Helium314
Copy link
Collaborator

I vaguely remember the remote json only needs the same tile URL as the local one to work properly.

overlays may take a while to load, and when the old overlay is not cleared the user can select features of the old overlay, but in context of the new overlay (e.g. switching from things to address would allow editing the address of a waste bin)
@Helium314
Copy link
Collaborator

Btw the glyph folder names are a little weird, e.g. Roboto Bold,Noto Bold. MapLibre appears to require it due to "text-font": ["Roboto Bold", "Noto Bold"] in the json.
Open Sans Regular,Arial Unicode MS Regular is accessed for address and places overlays only. This appears to be some default. We could try switching to Roboto/Noto here, then the Open Sans Regular,Arial Unicode MS Regular might not be necessary any more.

@westnordost
Copy link
Member Author

Yeah, or just one font, so that we don't need to keep around font fallbacks. After all, we do keep the fonts ourselves, no need for fallbacks.

@Helium314
Copy link
Collaborator

We could try switching to Roboto/Noto here

Current state (Open Sans Regular) on the left, Roboto Regular on the right:
fonts
I think switching to Roboto is fine, also for increased consistency e.g. with street names (different style of g).

Yeah, or just one font, so that we don't need to keep around font fallbacks. After all, we do keep the fonts ourselves, no need for fallbacks.

So I'll just use Roboto Bold and Roboto Regular and remove the Noto names.
Also will set overlay text font to Roboto Regular and remove Open Sans regular folder.

use only roboto regular and bold
add slight text offset to clusters to avoid font appearing off-center
@Helium314
Copy link
Collaborator

So I guess it's time for a little more testing now, and then... I'm not sure that maplibre/maplibre-native#2206 will eventually get fixed. Maybe we should merge this regardless?

@@ -184,6 +184,7 @@ class StyleableOverlayMapComponent(
.withProperties(
iconImage(get("icon")),
textField(get("label")),
textFont(arrayOf("Roboto Regular")),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You had to write this because MapLibre uses some font by default?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the default is Open Sans Regular and Arial Unicode MS Regular

@westnordost
Copy link
Member Author

Yes, let's do it.

@westnordost westnordost merged commit 918dbb8 into streetcomplete:master Aug 14, 2024
@westnordost westnordost deleted the maplibre branch August 14, 2024 11:03
@westnordost
Copy link
Member Author

And I'll document our findings in the respective tickets.

@Helium314
Copy link
Collaborator

I did a "live test" and noticed a few minor visual glitches. Will open issues, or do PRs/commits depending on fixes I find. (but first I'll probably spend 2 days or so on merging this into SCEE)

@westnordost
Copy link
Member Author

One thing that just came to my mind with all this offline region gehampel, are we maybe massively producing overlapping offline regions by just downloading and hence producing massive amounts of (unused / doubly used) cached map tiles? E.g. just when opening the app, the app will already download two regions (small rectangle around the user, then big rectangle around the user).

Since offline regions seemed to have never been thought through completely (maplibre/maplibre-native#2724), maybe there are issues with overlapping and managing (many) offline regions, too.

@Helium314
Copy link
Collaborator

As far as I remember from looking through the offline database, tiles are downloaded only once. Tiles and regions are linked in some db table, and a single tile may belong to more than one offline region.

Thus I think overlapping offline regions are not an issue. The small-rectangle region will be useless in the db, but only occupy very little space (download url, some dates, which tiles belong to this region).

@westnordost
Copy link
Member Author

Phew! Thank you for checking!

@Coehill
Copy link

Coehill commented Sep 15, 2024

Thank you to the developers for all of your efforts on making this available on iOS! StreetComplete is an invaluable tool and we will all benefit from more people able to map with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked blocked by another issue enhancement iOS necessary for iOS port
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Explore migration from tangram to MapLibre
4 participants