Skip to content

OSM Tag Frequency Counter for UI Color Analysis#1432

Closed
chinweibegbu wants to merge 8 commits intofacebook:mainfrom
chinweibegbu:style-tag-frequency
Closed

OSM Tag Frequency Counter for UI Color Analysis#1432
chinweibegbu wants to merge 8 commits intofacebook:mainfrom
chinweibegbu:style-tag-frequency

Conversation

@chinweibegbu
Copy link

@chinweibegbu chinweibegbu commented May 16, 2024

OSM Tag Frequency Counter for UI Color Analysis

TL;DR
I used empirical analysis to identify the most relevant colors on the map for the purpose of creating colorblind-friendly map color schemes.

Overview

In order to create data-informed colorblind-friendly color schemes for the map, I measured the frequency of OSM tags rendered within a specific map extent.

This PR includes code incorporated from #1365. However, the main contribution of this PR is the chunk of code in /modules/pixi/PixiLayerOsm.js which does the OSM tag counting. This code was instrumental in #1384, specifically in the creation of three (3) colorblind-friendly color schemes.

NOTE: For the most part, this conversation is going to be held independent of the color system proposed in #1384

Thought Process Summary

Rapid has 39 distinct HEX colors referenced in /modules/core/StyleSystem.js and /data/colors.js. The aim is create colorblind-friendly color schemes in which:

  • All colors are colorblind-accessible
  • All color interactions are colorblind-accessible

One approach to this would be to create new color schemes which replace all 39 colors while ensuring the two conditions listed above.

A much simpler approach would be to focus on 5-10 colors which are most relevant to a colorblind user. That is what this PR addresses. The core question being asked is:

"How does one identify the most relevant colors on the map?"

Approaches

This section covers three potential approaches to answering the question above. Approaches no. 1 and no. 2 were attempted in the course of this PR. Approach no. 3 was not attempted due to the amount of resources and time it would require.

These approaches are NOT conclusive (hence the ISSUEs highlighted) and can be built upon further.

Approach no. 1

"How many times is each color referred to in the StyleSystem.js file?"

PROCESS: Use the file search function in whatever file editor being used

ISSUE: Does not account for how often that specific definition is rendered on the map e.g. red is only referred to once in StyleSystem.js but the feature that uses it (building) occurs the most on the map (specific to the evaluation map location)

Approach no. 2

Builds on Approach no. 1 by asking: "How many times is each OSM tag and value RENDERED?"

PROCESS: Programmatically count during the render() function call in /modules/pixi/PixiLayerOsm.js and print the results in console

ISSUE: Does not account for how features change across the map with changes in location and zoom level. >>> NOTE: One cannot evaluate the entire map at once because Render only renders the features (areas/polygons, lines and points) at a certain zoom level

Approach no. 3

Builds on Approach no. 2 by asking: "How many times is each OSM tag and value rendered ACROSS THE ENTIRE MAP?"

PROCESS: Move across the map in tiles/extents at every possible zoom and evaluate at every possible location >> Very rigorous, very time-consuming

ISSUE: Does not account for the relative size of the feature being rendered e.g. building is the OSM tag rendered the most BUT features like highway get rendered a lot bigger and take up more visual space

Results and Implications

This section is based on the data gathered in Approach no. 2. The frequency counter code chunk is dependent on the entities rendered in the current map extent (as specified in the URL used).

Research Context and Results

Research Implications

Based on the data gathered, I identified the 4 or 5 most frequently-used colors which heavily impacted accessibility. These identifications were further backed by visual confirmation using the colorblind emulators incorporated from #1365.

Once these colors were identified, the initial question - "How does one identify the most relevant colors on the map?" - was considered answered. You can check out the /data/color_schemes.json file in #1384 to see how these identified colors were redefined.

salvinax and others added 8 commits March 28, 2024 12:41
Add default and example color scheme objects to colors.json.

Minify colors.json in build_data.js. Add colors.json to DataLoaderSystem's fileMap.

Add color scheme helper functions to StyleSytem, with comments to describe each functions parameters and return values (where applicable).

Update StyleSystem's styleMatch() function to interact with color scheme objects from colors.json rather than from STYLE_DECLARATIONS.

Fix white space discrepancies in StyleSystem.

Update color_selection.js and colorblind_mode_options.js to use StyleSystem rather than the non-existent ColorSystem.

Uncomment color schemes and colorblind mode options sections in preferences.js to add them to the Preferences pane of the UI.

Refs: Issue facebook#1230
Rename example color scheme to high_contrast to reflect its functionality in colors.json

Update core.yaml to match the renamed example color scheme

Reduce boilerplate code and comments relating to color scheme handling in StyleSystem.js

Add missing semicolon in build_data.js to facilitate formatting consistency

Refs: Issue facebook#1230
Add debugging code in to allow programmer count the tags (OSM keys and values) which are  rendered for a particular map zoom, latitude and longitude.
Add default and example color scheme objects to colors.json.

Minify colors.json in build_data.js. Add colors.json to DataLoaderSystem's fileMap.

Add color scheme helper functions to StyleSytem, with comments to describe each functions parameters and return values (where applicable).

Update StyleSystem's styleMatch() function to interact with color scheme objects from colors.json rather than from STYLE_DECLARATIONS.

Fix white space discrepancies in StyleSystem.

Update color_selection.js and colorblind_mode_options.js to use StyleSystem rather than the non-existent ColorSystem.

Uncomment color schemes and colorblind mode options sections in preferences.js to add them to the Preferences pane of the UI.

Refs: Issue facebook#1230
Add debugging code in to allow programmer count the tags (OSM keys and values) which are  rendered for a particular map zoom, latitude and longitude.
@bhousel
Copy link
Contributor

bhousel commented Aug 29, 2024

This is really interesting work, but I don't know what to do with it right now. Thanks!
see also my comments on #1384 (comment)

@bhousel bhousel closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants