Skip to content

Instantly share code, notes, and snippets.

@pastk
Last active October 25, 2023 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pastk/4cdb563b9a705ad6511500d6eebf4146 to your computer and use it in GitHub Desktop.
Save pastk/4cdb563b9a705ad6511500d6eebf4146 to your computer and use it in GitHub Desktop.
"Improve Styling System" Organic Maps GSOC'23 project
The goal of the project was to refactor the styling system to make it more predictable, robust, simple,
easier for debugging and future-proof.
I managed to refactor the most complicated part of it - the drawing priorities system.
And now Organic Maps is running using this new system. Unfortunately it took longer than expected
(there were many nuances and hardcoded behavior for special cases), so it came at the expense of some other tasks not done,
i.e. the style files syntax largely hasn't been changed yet (except the priorities-related part).
Also it became clear that syntax improvements doesn't make much sense without prior design of related refactorings
and future features, so more work went into this direction instead.
The most of the work was done in the main Organic Maps repository https://github.com/organicmaps/organicmaps
and on its styles generator / processor Kothic https://github.com/organicmaps/kothic.
Many PRs to the main repo are dependent on / contain a link to a corresponding Kothic PR
(e.g. https://github.com/organicmaps/kothic/pull/10).
Following is the list of the main PRs only for brewity, follow the links from there if necessary.
What has been done (a list of merged pull requests).
Priorities system:
- Main PR with a list of changes "Refactor priorities system" https://github.com/organicmaps/organicmaps/pull/4645
- "Render main type overlay draw rules only" https://github.com/organicmaps/organicmaps/pull/4835
- "Display drules with automatic priorities as comments in priorities files" https://github.com/organicmaps/organicmaps/pull/5731
- "minVisibleScale-related cleanup and optimization" https://github.com/organicmaps/organicmaps/pull/5903
- "Remove navigation mode priority exceptions" https://github.com/organicmaps/organicmaps/pull/5868
- "Improve housenumbers display and prioritization" https://github.com/organicmaps/organicmaps/pull/5976
Layering sub-system:
- "Draw background areas in size order" https://github.com/organicmaps/organicmaps/pull/4581
- "Make water areas foreground and above linear waterways" https://github.com/organicmaps/organicmaps/pull/4927
- "Improve layer=* pocessing" https://github.com/organicmaps/organicmaps/pull/5366
A related meta-issue is "Improve / refactor drawing priorities system" https://github.com/organicmaps/organicmaps/issues/4314.
It contains a TODO list in the end with the items that are good to address still.
Styling system in general:
- "Make "text-optional: true" default behavior" https://github.com/organicmaps/organicmaps/pull/4852
- "Use a ': none;' syntax for disabling area and icon drules" https://github.com/organicmaps/organicmaps/pull/5789
- "Optimize RulesHolder" https://github.com/organicmaps/organicmaps/pull/6015
- "Simplify Stylist init invocation" https://github.com/organicmaps/organicmaps/pull/6019
- "Refactor Stylist and RuleDrawer" https://github.com/organicmaps/organicmaps/pull/6034
- "Refactor apply_feature_functors" https://github.com/organicmaps/organicmaps/pull/6243
- "Replace casing-width evals with casing-width-add" https://github.com/organicmaps/organicmaps/pull/4293
- "Update kothic to use speed optimizations" https://github.com/organicmaps/organicmaps/pull/4429
...and many more smaller fixes and minor improvements.
A related meta-issue is "Improve / refactor styles system" https://github.com/organicmaps/organicmaps/issues/4317
that includes TODO ideas.
Challenges encountered:
a vast, complicated and not documented codebase with 10+years history, hence a lot of time went to
examination of many baked in exceptions / workarounds and peculiar behaviors and design of a new system
that would be friendlier and simpler, yet would support all the current use cases (and some extra)
without breaking anything major.
Discussions about approaches and design of related refactorings and planned features:
(they need to be defined better in order to proceed with style files syntax improvements)
- "Refactor types system for access= and fee= OSM tags" https://github.com/organicmaps/organicmaps/issues/1312#issuecomment-1706344221
- "Dynamic Detail Thresholds / Dynamic styling based on map density" https://github.com/organicmaps/organicmaps/issues/6223#issuecomment-1755768079
- "Determine features' visibilities by their priorities, size and the current map density (not pre-defined zoom levels)" https://github.com/organicmaps/organicmaps/issues/6330
- "Feasibility of the "dynamic tags" styling mechanism" https://github.com/organicmaps/organicmaps/issues/6331
I'm planning to continue working on this project and finishing it eventually.
@vng
Copy link

vng commented Oct 25, 2023

Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment