Beispiel #1
0
def build():
    #copy the toner4tilemill tree to a build dir
    copy_tree("toner4tilemill", "build")

    #remove the mml templates
    for f in glob("build/*.mml"):
        unlink(f)

    #load the project template
    templatefile = open(join('toner4tilemill', 'project.mml'))
    template = loads(templatefile.read())

    #fill in the project template
    for layer in template["Layer"]:
        if layer["id"] in ("land"):
            layer["Datasource"]["file"] = config["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

    template["name"] = config["name"]

    #dump the filled-in project template to the build dir
    with open(join('build', 'project.mml'), 'w') as output:
        output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #2
0
def build():
    #copy the osm-bright tree to a build dir
    copy_tree("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 = loads(templatefile.read())

    #fill in the project template
    for layer in template["Layer"]:
        if layer["id"] == "land-low":
            layer["Datasource"]["file"] = config["land-low"]
        elif layer["id"] == "land-high":
            layer["Datasource"]["file"] = config["land-high"]
        elif layer["id"] == "ne_places":
            layer["Datasource"]["file"] = config["ne_places"]
        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

    template["name"] = config["name"]

    #dump the filled-in project template to the build dir
    with open(join('build', 'project.mml'), 'w') as output:
        output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #3
0
def build():
    # copy the osm-bright tree to a build dir
    copy_tree("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 = loads(templatefile.read())

    # fill in the project template
    for layer in template["Layer"]:
        if layer["id"] == "land-low":
            layer["Datasource"]["file"] = config["land-low"]
        elif layer["id"] == "land-high":
            layer["Datasource"]["file"] = config["land-high"]
        elif layer["id"] == "ne_places":
            layer["Datasource"]["file"] = config["ne_places"]
        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

    template["name"] = config["name"]

    # dump the filled-in project template to the build dir
    with open(join("build", "project.mml"), "w") as output:
        output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #4
0
def build():
  #copy the osm-bright tree to a build dir
  copy_tree("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 = loads(templatefile.read())

  #fill in the project template
  for layer in template["Layer"]:
    if layer["id"] == "shoreline_300":
      layer["Datasource"]["file"] = config["shoreline_300"]
    elif layer["id"] in ("processed_p", "processed_p_outline"):
      layer["Datasource"]["file"] = config["processed_p"]
    elif layer["id"] in ("land"):
      layer["Datasource"]["file"] = config["land"]
    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

  template["name"] = config["name"]

  #dump the filled-in project template to the build dir
  with open(join('build', 'project.mml'), 'w') as output:
    output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #5
0
def install():
    assert isdir(
        config["path"]
    ), "Config.path does not point to your mapbox projects directory; please fix and re-run"
    sanitized_name = re.sub("[^\w]", "", config["name"])
    output_dir = join(config["path"], sanitized_name)
    print "installing to %s" % output_dir
    copy_tree("build", output_dir)
Beispiel #6
0
def install(style):
    assert isdir(
        config["path"]
    ), "Config.path does not point to your mapbox projects directory; please fix and re-run"
    sanitized_name = re.sub("[^\w]", "", config["name"][style])
    output_dir = join(config["path"], sanitized_name)
    print "installing to %s" % output_dir
    copy_tree("build", output_dir)

    os.system("cd " + output_dir + "; carto project.mml > mapnik.xml")
Beispiel #7
0
def pull():
    #copy the project from mapbox to osm-bright
    sanitized_name = re.sub("[^\w]", "", config["name"])
    output_dir = join(config["path"], sanitized_name)
    copy_tree(output_dir, "osm-bright", ("layers", ".thumb.png"))

    #load the project file
    project = loads(open(join("osm-bright", "project.mml")).read())

    #Make sure we reset postgis data in the project file back to its default values
    defaultconfig = defaultdict(defaultdict)
    defaultconfig["postgis"]["host"] = ""
    defaultconfig["postgis"]["port"] = ""
    defaultconfig["postgis"]["dbname"] = "osm"
    defaultconfig["postgis"]["user"] = ""
    defaultconfig["postgis"]["password"] = ""
    defaultconfig["postgis"][
        "extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
    defaultconfig["name"] = "OSM Bright"
    defaultconfig[
        "land-high"] = "http://data.openstreetmapdata.com/land-polygons-split-3857.zip"
    defaultconfig[
        "land-low"] = "http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip"
    defaultconfig[
        "ne_places"] = "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/cultural/10m-populated-places-simple.zip"

    project["name"] = defaultconfig["name"]
    for layer in project["Layer"]:
        if layer["id"] == "land-low":
            layer["Datasource"]["file"] = defaultconfig["land-low"]
        elif layer["id"] == "land-high":
            layer["Datasource"]["file"] = defaultconfig["land-high"]
        elif layer["id"] == "ne_places":
            layer["Datasource"]["file"] = defaultconfig["ne_places"]
        else:
            # Assume all other layers are PostGIS layers
            for opt, val in defaultconfig["postgis"].iteritems():
                if val and opt in layer["Datasource"]:
                    layer["Datasource"][opt] = val
                elif opt in layer["Datasource"]:
                    del layer["Datasource"][opt]

    project_template = open(
        join("osm-bright", "osm-bright.%s.mml") % config["importer"], 'w')
    project_template.write(dumps(project, sort_keys=True, indent=2))

    #now delete project.mml
    unlink(join("osm-bright", "project.mml"))
Beispiel #8
0
def pull():
    #copy the project from mapbox to osm-bright
    sanitized_name = re.sub("[^\w]", "", config["name"])
    output_dir = join(config["path"], sanitized_name)
    copy_tree(output_dir, "osm-bright", ("layers", ".thumb.png"))

    #load the project file
    project = loads(open(join("osm-bright", "project.mml")).read())

    #Make sure we reset postgis data in the project file back to its default values
    defaultconfig = defaultdict(defaultdict)
    defaultconfig["postgis"]["host"] = ""
    defaultconfig["postgis"]["port"] = ""
    defaultconfig["postgis"]["dbname"] = "osm"
    defaultconfig["postgis"]["user"] = ""
    defaultconfig["postgis"]["password"] = ""
    defaultconfig["postgis"][
        "extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
    defaultconfig["name"] = "OSM Bright"
    defaultconfig[
        "processed_p"] = "http://tilemill-data.s3.amazonaws.com/osm/coastline-good.zip"
    defaultconfig[
        "shoreline_300"] = "http://tilemill-data.s3.amazonaws.com/osm/shoreline_300.zip"
    defaultconfig[
        "land"] = "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.3.0/physical/10m-land.zip"

    project["name"] = defaultconfig["name"]
    for layer in project["Layer"]:
        if layer["id"] == "shoreline_300":
            layer["Datasource"]["file"] = defaultconfig["shoreline_300"]
        elif layer["id"] in ("processed_p", "processed_p_outline"):
            layer["Datasource"]["file"] = defaultconfig["processed_p"]
        else:
            # Assume all other layers are PostGIS layers
            for opt, val in defaultconfig["postgis"].iteritems():
                if val and opt in layer["Datasource"]:
                    layer["Datasource"][opt] = val
                elif opt in layer["Datasource"]:
                    del layer["Datasource"][opt]

    project_template = open(
        join("osm-bright", "osm-bright.%s.mml") % config["importer"], 'w')
    project_template.write(dumps(project, sort_keys=True, indent=2))

    #now delete project.mml
    unlink(join("osm-bright", "project.mml"))
Beispiel #9
0
def pull():
    # copy the project from mapbox to osm-bright
    sanitized_name = re.sub("[^\w]", "", config["name"])
    output_dir = join(config["path"], sanitized_name)
    copy_tree(output_dir, "osm-bright", ("layers", ".thumb.png"))

    # load the project file
    project = loads(open(join("osm-bright", "project.mml")).read())

    # Make sure we reset postgis data in the project file back to its default values
    defaultconfig = defaultdict(defaultdict)
    defaultconfig["postgis"]["host"] = ""
    defaultconfig["postgis"]["port"] = ""
    defaultconfig["postgis"]["dbname"] = "osm"
    defaultconfig["postgis"]["user"] = ""
    defaultconfig["postgis"]["password"] = ""
    defaultconfig["postgis"]["extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
    defaultconfig["name"] = "OSM Bright"
    defaultconfig["land-high"] = "http://data.openstreetmapdata.com/land-polygons-split-3857.zip"
    defaultconfig["land-low"] = "http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip"
    defaultconfig[
        "ne_places"
    ] = "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/cultural/10m-populated-places-simple.zip"

    project["name"] = defaultconfig["name"]
    for layer in project["Layer"]:
        if layer["id"] == "land-low":
            layer["Datasource"]["file"] = defaultconfig["land-low"]
        elif layer["id"] == "land-high":
            layer["Datasource"]["file"] = defaultconfig["land-high"]
        elif layer["id"] == "ne_places":
            layer["Datasource"]["file"] = defaultconfig["ne_places"]
        else:
            # Assume all other layers are PostGIS layers
            for opt, val in defaultconfig["postgis"].iteritems():
                if val and opt in layer["Datasource"]:
                    layer["Datasource"][opt] = val
                elif opt in layer["Datasource"]:
                    del layer["Datasource"][opt]

    project_template = open(join("osm-bright", "osm-bright.%s.mml") % config["importer"], "w")
    project_template.write(dumps(project, sort_keys=True, indent=2))

    # now delete project.mml
    unlink(join("osm-bright", "project.mml"))
Beispiel #10
0
def pull():
  #copy the project from mapbox to osm-bright
  sanitized_name = re.sub("[^\w]", "", config["name"])
  output_dir = join(config["path"], sanitized_name)
  copy_tree(output_dir, "osm-bright", ("layers", ".thumb.png"))

  #load the project file
  project = loads(open(join("osm-bright", "project.mml")).read())

  #Make sure we reset postgis data in the project file back to its default values
  defaultconfig = defaultdict(defaultdict)
  defaultconfig["postgis"]["host"]     = ""
  defaultconfig["postgis"]["port"]     = ""
  defaultconfig["postgis"]["dbname"]   = "osm"
  defaultconfig["postgis"]["user"]     = ""
  defaultconfig["postgis"]["password"] = ""
  defaultconfig["postgis"]["extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
  defaultconfig["name"] = "OSM Bright"
  defaultconfig["processed_p"] = "http://tilemill-data.s3.amazonaws.com/osm/coastline-good.zip"
  defaultconfig["shoreline_300"] = "http://tilemill-data.s3.amazonaws.com/osm/shoreline_300.zip"
  defaultconfig["land"] = "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.3.0/physical/10m-land.zip"

  project["name"] = defaultconfig["name"]
  for layer in project["Layer"]:
    if layer["id"] == "shoreline_300":
      layer["Datasource"]["file"] = defaultconfig["shoreline_300"]
    elif layer["id"] in ("processed_p", "processed_p_outline"):
      layer["Datasource"]["file"] = defaultconfig["processed_p"]
    elif layer["id"] == "land":
      layer["Datasource"]["file"] = defaultconfig["land"]
    else:
      # Assume all other layers are PostGIS layers
      for opt, val in defaultconfig["postgis"].iteritems():
        if val and opt in layer["Datasource"]:
          layer["Datasource"][opt] = val
        elif opt in layer["Datasource"]:
          del layer["Datasource"][opt]

  project_template = open(join("osm-bright", "osm-bright.%s.mml") % config["importer"], 'w')
  project_template.write(dumps(project, sort_keys=True, indent=2))

  #now delete project.mml
  unlink(join("osm-bright", "project.mml"))
Beispiel #11
0
def build():
  #copy the osm-bright tree to a build dir
  makedirs("build")
  makedirs("build/symbols")
  for file in glob(r'*.mss'):
    copy(file, "build")

  copy_tree("symbols", "build/symbols")
  copy("project.mml", "build")

  #load the project template
  templatefile = open(join('build', 'project.mml'))
  template = loads(templatefile.read())

  #fill in the project template
  for layer in template["Layer"]:
    if layer["id"] == "world":
      layer["Datasource"]["file"] = config["world"]
    elif layer["id"] == "coast-poly":
      layer["Datasource"]["file"] = config["coast-poly"]
    elif layer["id"] == "builtup":
      layer["Datasource"]["file"] = config["builtup"]
    elif layer["id"] == "necountries":
      layer["Datasource"]["file"] = config["necountries"]
    elif layer["id"] == "nepopulated":
      layer["Datasource"]["file"] = config["nepopulated"]
    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

  template["name"] = config["name"]

  #dump the filled-in project template to the build dir
  with open(join('build', 'project.mml'), 'w') as output:
    output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #12
0
def build():
    #copy the osm-bright tree to a build dir
    makedirs("build")
    makedirs("build/symbols")
    for file in glob(r'*.mss'):
        copy(file, "build")

    copy_tree("symbols", "build/symbols")
    copy("project.mml", "build")

    #load the project template
    templatefile = open(join('build', 'project.mml'))
    template = loads(templatefile.read())

    #fill in the project template
    for layer in template["Layer"]:
        if layer["id"] == "world":
            layer["Datasource"]["file"] = config["world"]
        elif layer["id"] == "coast-poly":
            layer["Datasource"]["file"] = config["coast-poly"]
        elif layer["id"] == "builtup":
            layer["Datasource"]["file"] = config["builtup"]
        elif layer["id"] == "necountries":
            layer["Datasource"]["file"] = config["necountries"]
        elif layer["id"] == "nepopulated":
            layer["Datasource"]["file"] = config["nepopulated"]
        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

    template["name"] = config["name"]

    #dump the filled-in project template to the build dir
    with open(join('build', 'project.mml'), 'w') as output:
        output.write(dumps(template, sort_keys=True, indent=2))
Beispiel #13
0
def pull():
    #copy the project from mapbox to toner4tilemill
    sanitized_name = re.sub("[^\w]", "", config["name"])
    output_dir = join(config["path"], sanitized_name)
    copy_tree(output_dir, "toner4tilemill", ("layers", ".thumb.png"))

    #load the project file
    project = loads(open(join("toner4tilemill", "project.mml")).read())

    #Make sure we reset postgis data in the project file back to its default values
    defaultconfig = defaultdict(defaultdict)
    defaultconfig["postgis"]["host"] = ""
    defaultconfig["postgis"]["port"] = ""
    defaultconfig["postgis"]["dbname"] = "osm"
    defaultconfig["postgis"]["user"] = ""
    defaultconfig["postgis"]["password"] = ""
    defaultconfig["postgis"][
        "extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
    defaultconfig["name"] = "Toner for Tilemill"
    defaultconfig[
        "processed_p"] = "http://tile.openstreetmap.org/processed_p.tar.bz2"

    project["name"] = defaultconfig["name"]
    for layer in project["Layer"]:
        if layer["id"] in ("land"):
            layer["Datasource"]["file"] = defaultconfig["processed_p"]
        else:
            # Assume all other layers are PostGIS layers
            for opt, val in defaultconfig["postgis"].iteritems():
                if val and opt in layer["Datasource"]:
                    layer["Datasource"][opt] = val
                elif opt in layer["Datasource"]:
                    del layer["Datasource"][opt]

    project_template = open(join('toner4tilemill', 'project.mml'), 'w')
    project_template.write(dumps(project, sort_keys=True, indent=2))

    #now delete project.mml
    unlink(join("toner4tilemill", "project.mml"))
def pull():
	#copy the project from mapbox to toner4tilemill
	sanitized_name = re.sub("[^\w]", "", config["name"])
	output_dir = join(config["path"], sanitized_name)
	copy_tree(output_dir, "toner4tilemill", ("layers", ".thumb.png"))

	#load the project file
	project = loads(open(join("toner4tilemill", "project.mml")).read())

	#Make sure we reset postgis data in the project file back to its default values
	defaultconfig = defaultdict(defaultdict)
	defaultconfig["postgis"]["host"]     = ""
	defaultconfig["postgis"]["port"]     = ""
	defaultconfig["postgis"]["dbname"]   = "osm"
	defaultconfig["postgis"]["user"]     = ""
	defaultconfig["postgis"]["password"] = ""
	defaultconfig["postgis"]["extent"] = "-20037508.34 -20037508.34 20037508.34 20037508.34"
	defaultconfig["name"] = "Toner for Tilemill"
	defaultconfig["processed_p"] = "http://tile.openstreetmap.org/processed_p.tar.bz2"

	project["name"] = defaultconfig["name"]
	for layer in project["Layer"]:
		if layer["id"] in ("land"):
			layer["Datasource"]["file"] = defaultconfig["processed_p"]
		else:
			# Assume all other layers are PostGIS layers
			for opt, val in defaultconfig["postgis"].iteritems():
				if val and opt in layer["Datasource"]:
					layer["Datasource"][opt] = val
				elif opt in layer["Datasource"]:
					del layer["Datasource"][opt]

	project_template = open(join('toner4tilemill', 'project.mml'), 'w')
	project_template.write(dumps(project, sort_keys=True, indent=2))

	#now delete project.mml
	unlink(join("toner4tilemill", "project.mml"))
Beispiel #15
0
    outputs = []

    for n in names:
        if n in ignores: continue

        src_name = os.path.join(src, n)
        dst_name = os.path.join(dst, n)

#def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
#              preserve_symlinks=0, update=0, verbose=1, dry_run=0):

        if os.path.islink(src_name):
            continue
        elif os.path.isdir(src_name):
            outputs.extend(copy_tree(src_name, dst_name, ignores))
        else:
            copy_file(src_name, dst_name, verbose=1)
            outputs.append(dst_name)

    return outputs

########NEW FILE########
__FILENAME__ = make
#!/usr/bin/env python

import re
import sys

from os import unlink
from json import loads, dumps
Beispiel #16
0
    outputs = []

    for n in names:
        if n in ignores: continue

        src_name = os.path.join(src, n)
        dst_name = os.path.join(dst, n)

        #def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
        #              preserve_symlinks=0, update=0, verbose=1, dry_run=0):

        if os.path.islink(src_name):
            continue
        elif os.path.isdir(src_name):
            outputs.extend(copy_tree(src_name, dst_name, ignores))
        else:
            copy_file(src_name, dst_name, verbose=1)
            outputs.append(dst_name)

    return outputs


########NEW FILE########
__FILENAME__ = make
#!/usr/bin/env python

import re
import sys

from os import unlink
Beispiel #17
0
def install():
  assert isdir(config["path"]), "Config.path does not point to your mapbox projects directory; please fix and re-run"
  sanitized_name = re.sub("[^\w]", "", config["name"])
  output_dir = join(config["path"], sanitized_name)
  print "installing to %s" % output_dir
  copy_tree("build", output_dir)