Skip to content

Commit

Permalink
Merge pull request #67 from nst-guide/maki_icons_cli
Browse files Browse the repository at this point in the history
Add Python script to list differences with Maki's icon set
  • Loading branch information
pathmapper authored Dec 17, 2019
2 parents 643466f + ab5d28f commit d4e6b6c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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/`
43 changes: 43 additions & 0 deletions maki_list.py
Original file line number Diff line number Diff line change
@@ -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:')
print(sorted(maki_diff))

print('\nNames in Maki unused by OSM Libery:')
print(sorted(osm_diff))


if __name__ == '__main__':
main()

0 comments on commit d4e6b6c

Please sign in to comment.