From 4404afe01e16b11404f379b4feebed9a56a1bbfe Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 17 Dec 2019 09:44:57 -0700 Subject: [PATCH 1/2] Add Python script to list differences with Maki's icon set --- README.md | 10 ++++++++-- maki_list.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 maki_list.py diff --git a/README.md b/README.md index 63b9632..c8a5573 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A free Mapbox GL basemap style for everyone with complete liberty to use and sel ## Usage -You can use the style in your Mapbox GL maps. +You can use the style in your Mapbox GL maps. By default, the vector tiles and glyphs are served from [Maptiler Cloud](https://www.maptiler.com/cloud/) and the raster tiles and sprites directly from GitHub. You would need to [subscribe](https://www.maptiler.com/cloud/plans) to Maptiler Cloud to get an access key and replace the placeholder {key} for the [vector source](https://github.com/maputnik/osm-liberty/blob/gh-pages/style.json#L11) and [glyphs](https://github.com/maputnik/osm-liberty/blob/gh-pages/style.json#L23) with your own key. @@ -68,6 +68,12 @@ This style actually triggered the need for the development of [Maputnik](https:/ A [Maki](https://github.com/mapbox/maki) icon set using colors to distinguish between icon categories. +Maki is a living project and adds new icons over time, which means that there +could be new icons that OSM Liberty could use for POIs. `maki_list.py` is a +simple script to list both the names in OSM Liberty's iconset that don't map to +any valid Maki name, and the Maki names that are not currently used in OSM +Liberty's iconset. You can run the script with `python3 maki_list.py`. + **Color Palette** Color Name | Hex Value @@ -85,7 +91,7 @@ Green | `#76a723` 2. Apply your changes and download the icons in SVG format and the iconset in JSON format. 3. Optional: Format the JSON with `cat iconset.json | jq -MS '.'` for better legibility. 4. Add the SVG files from the folder [svgs_not_in_iconset](https://github.com/maputnik/osm-liberty/tree/gh-pages/svgs/svgs_not_in_iconset) to the folder `svgs` downloaded from the Maki Editor. -These are the SVGs for road shields, the dot used for city and town layers and the road area pattern which could not be modified using the Maki Editor. To modify these you could use e.g. [Inkscape](https://inkscape.org). +These are the SVGs for road shields, the dot used for city and town layers and the road area pattern which could not be modified using the Maki Editor. To modify these you could use e.g. [Inkscape](https://inkscape.org). 5. Install [spritezero-cli](https://github.com/mapbox/spritezero-cli): `npm install -g @mapbox/spritezero-cli` 6. Generate the low resolution sprite: `spritezero osm-liberty ./svgs/` 7. Generate the high resolution sprite: `spritezero --retina osm-liberty@2x ./svgs/` diff --git a/maki_list.py b/maki_list.py new file mode 100644 index 0000000..3c3c110 --- /dev/null +++ b/maki_list.py @@ -0,0 +1,43 @@ +import requests + + +def main(): + osm_iconset_url = 'https://raw.githubusercontent.com/maputnik/osm-liberty/gh-pages/iconset.json' + + r = requests.get(osm_iconset_url) + osm_iconset = r.json() + + osm_iconset_keys = [ + list(group['svgs'].keys()) for group in osm_iconset['iconGroups']] + osm_iconset_keys = [ + item for sublist in osm_iconset_keys for item in sublist] + + maki_url = 'https://api.github.com/repos/mapbox/maki/contents/icons' + r = requests.get(maki_url) + maki_names = [x['name'] for x in r.json()] + + # Maki names are hyphenated; iconset names are both hyphenated and underscored + # I'll take the iconset names and change the underscores to hyphens + osm_iconset_keys = [x.replace('_', '-') for x in osm_iconset_keys] + + # Remove the -11.svg and -15.svg from each name list to easily deduplicate + # each list + maki_names = [ + x.replace('-11.svg', '.svg').replace('-15.svg', '.svg') + for x in maki_names] + osm_iconset_keys = [ + x.replace('-11.svg', '.svg').replace('-15.svg', '.svg') + for x in osm_iconset_keys] + + maki_diff = set(maki_names).difference(osm_iconset_keys) + osm_diff = set(osm_iconset_keys).difference(maki_names) + + print('Names in Maki unused by OSM Libery:') + sorted(maki_diff) + + print('\nNames in Maki unused by OSM Libery:') + sorted(osm_diff) + + +if __name__ == '__main__': + main() From ab5d28fdb4ffa76c4ad28e95cb0c2ba11e873f2b Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 17 Dec 2019 11:42:00 -0700 Subject: [PATCH 2/2] Fix print statements --- maki_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maki_list.py b/maki_list.py index 3c3c110..2ad0c8b 100644 --- a/maki_list.py +++ b/maki_list.py @@ -33,10 +33,10 @@ def main(): osm_diff = set(osm_iconset_keys).difference(maki_names) print('Names in Maki unused by OSM Libery:') - sorted(maki_diff) + print(sorted(maki_diff)) print('\nNames in Maki unused by OSM Libery:') - sorted(osm_diff) + print(sorted(osm_diff)) if __name__ == '__main__':