-
Notifications
You must be signed in to change notification settings - Fork 120
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
Support for On-The-Fly GeoJson Layers and a new Mutator Transform #2095
Conversation
for more information, see https://pre-commit.ci
vectordatasource/transform.py
Outdated
# we expect it to already be in mercator projection and we only fill out the minimal structure of the feature tuple | ||
# there's no ID, most of the datum stuff is missing, we are mostly worried about the shape and properties | ||
# we return None if we couldnt load the layer for any reason | ||
def _load_external_layer(params, name): |
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.
this is moving over to tilequeue
where the rest of the layers are loaded and ill add a new section to queries.yaml instead of having it be part of the transform
… to load inline layers
queries.yaml
Outdated
area-inclusion-threshold: 1 | ||
simplify_before_intersect: false | ||
simplify_start: 0, | ||
layer_path: ./metatile-layers/landmarks.geojson |
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.
this property signifies an "inline" layer. when the features are loaded from file we expect them to be already processed. that is we will not try to load a landmarks.yaml
and do processing on the data that is in the geojson file. we expect the tags and values to be there and the coordinates to already be in mercator projection
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.
Could we make the name more explicit about its behavior, like pre_processed_layer_path
might be a better name?
@@ -542,6 +552,23 @@ post_process: | |||
source_layer: roads | |||
properties: [layer] | |||
|
|||
# supersede existing osm buildings with data from landmark geojson layer |
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.
landmarks mark buildings with a superseded property so that when the two overlap the downstream consumer of the tiles will be able to tell
target_attribute: superseded | ||
linear: false | ||
|
||
# turn the landmark geojson polygons into point features |
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.
the final output of the landmarks layer is a point layer, basically landmark pois with a bunch of metadata about the landmark. the mutate transform lets us both modify the geom and the properties with python code that gets eval
'd directly. pretty powerful stuff. you can reference existing properties
of a feature using the {properties}
tag and you can access the geometry using the {shape}
tag. in the future we might want to allow more stuff to be referenced.
queries.yaml
Outdated
@@ -1865,6 +1892,7 @@ post_process: | |||
- addr_housenumber | |||
- addr_street | |||
- osm_relation | |||
exclude: ['superseded'] |
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.
if a building gets marked by a landmark, we exclude it from merging with other buildings, keeping it a single entity
kdtree | ||
lxml==4.6.2 | ||
mapbox-vector-tile==1.2.0 | ||
ModestMaps==1.4.7 | ||
protobuf==3.4.0 | ||
psycopg2==2.7.3.2 | ||
pyclipper==1.0.6 | ||
pycountry==17.9.23 | ||
pyshp==2.3.0 |
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.
apparently my system thought i needed these, i didnt check to see if that was the case. i can revert
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.
ah its because setup.py has them
""" | ||
We take a layer and we modify the geometry using the python expression in the query. The expressions have access to | ||
both the existing shape and existing properties via python string format replacements {shape} and {properties} | ||
respectively. Each expression is then eval'd to replace the existing feature in the layer with the result of the | ||
expressions. By default the expressions are a no-op | ||
""" |
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.
pretty good explanation here. basically we loop over the features and eval the python in the queries.yaml to compute new properties or geometry. if you omitted one or the other (they are both optional) it just leaves the existing values unchanged.
queries.yaml
Outdated
area-inclusion-threshold: 1 | ||
simplify_before_intersect: false | ||
simplify_start: 0, | ||
layer_path: ./metatile-layers/landmarks.geojson |
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.
Could we make the name more explicit about its behavior, like pre_processed_layer_path
might be a better name?
…t non string values
…hem downstream anyway
'crs': {'type': 'name', 'properties': {'name': 'urn:ogc:def:crs:EPSG::3857'}}, | ||
'features': [ | ||
{'type': 'Feature', | ||
'properties': {'name': 'null island hut', 'superseded': True, 'height': math.pi, 'origin': [1, 1], 'id': 42}, |
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.
🙇
@@ -9,6 +9,7 @@ all: | |||
- boundaries | |||
- transit | |||
- admin_areas | |||
- landmarks |
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.
Add docs
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.
See the traffic layers for inspiration for optional layer descriptions.
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.
ha! i was looking around for docs, it seemed like even the changelog isnt up to date. ill grep around to see if i can find them!
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.
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.
The CHANGELOG is out of date. Historically that's been updated as releases are tagged – and it's past time to tag v1.9. Thanks for the nudge.
the additional integration test failures in ci are just because this branch depends on the changes in this pr: tilezen/tilequeue#414 |
if end_zoom is not None and zoom >= end_zoom: | ||
return None | ||
|
||
# for the max zoom a transform needs to be re-entrant so we take a copy here |
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.
what is max zoom
here?
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.
ah sorry the last zoom in the tile pyramids that we create (z16). there is code over in tilequeue here: https://github.com/tilezen/tilequeue/blob/master/tilequeue/process.py#L613 where it basically calls into the transforms a second time (hence re-entrancy)
I'd remove the strikethrough in the description before merging |
The basic gist here is I want to add 2 features.
Once I had those two features implemented I added a landmarks layer to the queries which simply allows you to drop a geojson file into your tile build and mark buildings with it and become a point feature layer.