-
Notifications
You must be signed in to change notification settings - Fork 827
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
Convert layers to YAML #947
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1be5578
Add a script that takes a yaml file and converts it to a JSON file
pnorman 9918536
Convert the MML file from JSON to YAML
pnorman 45dbf13
Use alias to avoid duplicating SQL connection information
pnorman ba95ac9
Conver SQL from in-line escaped scalars to block scalars
pnorman 95a56f0
Clean up SQL in the YAML file
pnorman d31bd93
Add documentation on YAML and SQL to CONTRIBUTING.md
pnorman 72d5baa
Add PyYAML to dependencies, but only if editing the MML file
pnorman 08d3fb8
Fix typo and missed caps/quotes
pnorman dcbdae6
Whitespace fixes
pnorman 56cd8e0
More caps fixes
pnorman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,16 @@ You should fork the project into your own repo, create a topic branch | |
there and then make one or more pull requests back to the gravitystorm repository. | ||
Your pull requests will then be reviewed and discussed. | ||
|
||
## Editing Layers | ||
|
||
OpenStreetMap Carto uses a YAML file for defining layers. Some of the rationale is outlined in [a GitHub issue](https://github.com/gravitystorm/openstreetmap-carto/issues/711). Editing SQL in a YAML file is much friendlier than editing escaped SQL in a JSON file. | ||
|
||
This requires a preprocessing step to convert the YAML to JSON. A script is provided at ``scripts/yaml2mml.py``, which depends on PyYAML, available through ``pip install pyyaml`` or packaged on Ubuntu as ``python-yaml``. | ||
|
||
After editing the YAML file, run ``./scripts/yaml2mml.py < project.yaml > project.mml && touch project.mml`` to update the file and force TileMill to reload it. | ||
|
||
When committing changes, add the entire project.mml file with ``git add project.mml``. One of the big advantages of this system is that to resolve any layer merge conflicts, they only need to be resolved in the YAML file where they are easier to handle, then the JSON file can be regenerated. | ||
|
||
## CartoCSS Style Guidelines | ||
|
||
* Always specify zoom levels as either >= or < . Don't use = or =< or > | ||
|
@@ -18,7 +28,6 @@ Your pull requests will then be reviewed and discussed. | |
* Two space indents. No tabs. | ||
* space after : but not before | ||
* Dashes, not underscores, in layer names | ||
* Name SQL subqueries after the layer name (but use underscores) | ||
* Avoid restating defaults, e.g. don't add `point-allow-overlap = false` | ||
* Avoid repeating the layer name for layers with mutiple attachments, i.e., prefer | ||
|
||
|
@@ -48,6 +57,20 @@ instead of | |
``` | ||
* Order the selectors in a style-sheet in rough order of importance (i.e., highway=primary, then highway=secondary) and beyond that, add layers that are rendered later (i.e., higher) lower in the file. | ||
|
||
## SQL Style Guidelines | ||
Because SQL within JSON or YAML will not generally be syntax highlighted, indentation and caps are particularly important. | ||
|
||
* SQL keywords in caps, as in PostgreSQL documentation | ||
* Two space indents. No tabs. | ||
* Start with ``(SELECT`` and start the columns on the next line. | ||
* Two indents for columns, to bring them to the same indent level as later clause contents | ||
* Add indentation after ``SELECT``s until the end of the sub-select. | ||
* Add indentation for contents of ``FROM``, ``WHERE``, ``ORDER BY`` and other clauses | ||
* Put content with WHERE, etc if it's short | ||
* Add indentation if necessary for complex function calls, WHERE parenthesis, and CASE statements | ||
* One space before and after = etc | ||
* Name SQL subqueries after the layer name (but use underscores) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about spaces after commas? We are currently inconsistent in that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been making that consistent |
||
## Previews | ||
|
||
Some changes benefit from a review from a wider audience. In most cases some static images are sufficient, but sometimes a demo layer is necessary. pnorman has a private server which can host layers and has some data from parts of the world loaded. Before requesting this in a pull request, make sure that you don't anticipate any more changes to it. | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean with this line?