forked from mapbox/osm-bright
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also adding a build dir so we don't change the files in osm-bright, making it much easier to work on the code and commit it to source control
- Loading branch information
Showing
4 changed files
with
51 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
|
||
import json | ||
from os import unlink, mkdir, listdir, chdir, getcwd | ||
from sys import path | ||
from glob import glob | ||
from shutil import copytree, rmtree | ||
from os.path import join, isdir, split | ||
|
||
from configure import config, processed_p, shoreline_300 | ||
|
||
def clean(): | ||
if isdir("build"): | ||
rmtree("build") | ||
|
||
for f in glob("build/*.html"): unlink(f) | ||
|
||
def build(): | ||
#copy the osm-bright tree to a build dir | ||
copytree("osm-bright", "build") | ||
|
||
#remove the mml templates | ||
for f in glob("build/*.mml"): | ||
unlink(f) | ||
|
||
#load the project template | ||
templatefile = open(join('osm-bright', 'osm-bright.%s.mml' % config["importer"])) | ||
template = json.loads(templatefile.read()) | ||
|
||
#fill in the project template | ||
for layer in template["Layer"]: | ||
if layer["id"] == "shoreline_300": | ||
layer["Datasource"]["file"] = shoreline_300 | ||
elif layer["id"] in ("processed_p", "processed_p_outline"): | ||
layer["Datasource"]["file"] = processed_p | ||
else: | ||
# Assume all other layers are PostGIS layers | ||
for opt, val in config["postgis"].iteritems(): | ||
if (val == ""): | ||
if (opt in layer["Datasource"]): | ||
del layer["Datasource"][opt] | ||
else: | ||
layer["Datasource"][opt] = val | ||
|
||
#dump the filled-in project template to the build dir | ||
with open(join('build', 'project.mml'), 'w') as output: | ||
output.write(json.dumps(template, sort_keys=True, indent=2)) | ||
|
||
if __name__ == "__main__": | ||
clean() | ||
build() |
File renamed without changes.
File renamed without changes.