-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build up and generate mapfiles from Python dict #51
Comments
This is possible now, although the type needs to be set for each object - I'm in the middle of documenting a JSONSchema for the full Mapfile dict structure for a MapServer RFC.
Outputs:
|
Thanks @geographika. Are there examples of adding layers (and other objects) from dicts as well? Example, add a layer object like: import mappyfile
m = {"__type__": "map", "name": "Example", "extent": [0, 0, 100, 100]}
m['layers'].append({'name': 'weather alerts', 'type': 'Point'}) |
There should probably be a docs page with some examples. In the meantime, anything of which there can be multiples is named in the plural, and is of type list. import mappyfile
m = {"__type__": "map", "name": "Example", "extent": [0, 0, 100, 100]}
# create a list of layers
m['layers'] = [{"__type__": "layer", 'name': 'weather alerts', 'type': 'Point'}]
print(mappyfile.dumps(m)) If ordering of objects in the Mapfile is important (and using py2) you can use: from mappyfile.ordereddict import CaseInsensitiveOrderedDict
m = CaseInsensitiveOrderedDict({"__type__": "map", "name": "Example", "extent": [0, 0, 100, 100]})
# create a list of layers
m['layers'] = [{"__type__": "layer", 'name': 'weather alerts', 'type': 'Point'}]
print(mappyfile.dumps(m))
A draft version of the RFC with full spec/details is at: http://mappyfile.readthedocs.io/en/latest/rfc.html |
In our of our projects our core workflow is to generate a mapfile based on various system configurations (YAML, JSON, etc.). It would be valuable to have mappyfile be able to save a mapfile from a Python dictionary. Example of possible workflow:
The text was updated successfully, but these errors were encountered: