How to use the mappyfile.load function in mappyfile

To help you get started, we’ve selected a few mappyfile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geographika / mappyfile / tests / test_sample_maps.py View on Github external
def test_unicode_map():

    with open('./tests/samples/unicode.map', "r") as mf_file:
        mf = mappyfile.load(mf_file)

    print(mappyfile.dumps(mf))
github geographika / mappyfile / tests / test_utils.py View on Github external
def test_save():

    s = """MAP NAME "TEST" END"""
    d = mappyfile.loads(s)

    output_file = os.path.join(tempfile.mkdtemp(), 'test_mapfile.map')
    mappyfile.save(d, output_file)

    with open(output_file) as fp:
        d = mappyfile.load(fp)

    assert d["name"] == "TEST"
github geographika / mappyfile / tests / test_includes.py View on Github external
def test_include_from_filehandle():

    fn = './tests/samples/include1.map'

    with open(fn) as f:
        d = mappyfile.load(f)
        assert d["name"] == "include_test"
        print(mappyfile.dumps(d))
github geographika / mappyfile / tests / test_utils.py View on Github external
def test_dump():

    s = """MAP NAME "TEST" END"""
    d = mappyfile.loads(s)
    with tempfile.NamedTemporaryFile(mode="w+", delete=False) as fp:
        mappyfile.dump(d, fp)

    with open(fp.name) as fp:
        d = mappyfile.load(fp)

    assert d["name"] == "TEST"
github geographika / mappyfile / docs / examples / accessing_values.py View on Github external
import mappyfile

# load will accept a filename (loads will accept a string)
mapfile = mappyfile.load("./docs/examples/raster.map")

# print the map name
print(mapfile["name"]) # outputs "MyMap"
       
# access layers
layers = mapfile["layers"]
layer2 = layers[1] # access by index
	
# access classes in a layer
classes = layer2["classes"]

for c in classes:
    print(c["name"])
github geographika / mappyfile / docs / examples / animation / animated_buffer.py View on Github external
def main():
    mf = "./docs/examples/animation/animated_buffer.map"
    mapfile = mappyfile.load(mf)
    img_files = create_frames(mapfile)
    create_animation(img_files)
github geographika / mappyfile / docs / examples / modifying_values.py View on Github external
import mappyfile

mapfile = mappyfile.load("./docs/examples/raster.map")

# START OF API EXAMPLE
# update the map name
mapfile["name"] = "MyNewMap"

# update the error file path in the map config section
# note key names will always need to be lower case

mapfile["config"]["ms_errorfile"] = "/ms4w/tmp/ms_error.txt"
mapfile["config"]["ON_MISSING_DATA"] = "IGNORE"

# currently will need to double-quote non-keyword properties
mapfile["web"]["metadata"]["wms_format"] = "'image/png'"

layers = mapfile["layers"]
layer = layers[0]