Skip to content

Instantly share code, notes, and snippets.

@lukasmartinelli
Created August 6, 2016 21:31
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 lukasmartinelli/36f62ce9d38a1431c797556a880733f2 to your computer and use it in GitHub Desktop.
Save lukasmartinelli/36f62ce9d38a1431c797556a880733f2 to your computer and use it in GitHub Desktop.
Patch sources of a Mapbox GL style with settings from style and purge private details
import json
import sys
if __name__ == '__main__':
if len(sys.argv) >= 2:
style_src = sys.argv[1]
patch_src = sys.argv[2]
else:
print('patch_mabpox_gl_style.py <style> <patch-src>')
sys.exit(1)
with open(style_src) as style_fh:
with open(patch_src) as patch_fh:
style_doc = json.load(style_fh)
patch_doc = json.load(patch_fh)
style_doc["sources"] = patch_doc["sources"]
style_doc["sprite"] = patch_doc["sprite"]
style_doc["glyphs"] = patch_doc["glyphs"]
del style_doc["created"]
del style_doc["id"]
del style_doc["modified"]
del style_doc["owner"]
del style_doc["draft"]
print(json.dumps(style_doc, sort_keys=True, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment