Merge pull request #67 from nst-guide/maki_icons_cli
Add Python script to list differences with Maki's icon set
This commit is contained in:
commit
d4e6b6c524
@ -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.
|
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 Palette**
|
||||||
|
|
||||||
Color Name | Hex Value
|
Color Name | Hex Value
|
||||||
|
43
maki_list.py
Normal file
43
maki_list.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user