go-spatial / tegola-web-demo

13 stars 6 forks source link

Method for separating highways with multiple shields #21

Open PetersonGIS opened 6 years ago

PetersonGIS commented 6 years ago

When a highway has multiple names/numbers they are separated with a semicolon in the name field. This renders as a single highway shield with many numbers whereas it should render separate shields for each name along the line.

PetersonGIS commented 6 years ago

Options:

Read more about the semicolon separator in OpenStreetMap here: https://wiki.openstreetmap.org/wiki/Semi-colon_value_separator

PetersonGIS commented 6 years ago

Using the split_part function in the config.toml we can do something like this:

[[providers.layers]] name = "transport_lines_11-12" geometry_fieldname = "geometry" id_fieldname = "osm_id" sql = "SELECT ST_AsBinary(geometry) AS geometry, osm_id, name, ref, class, type, tunnel, bridge, access, service, split_part(ref,';',1) ref1, split_part(ref, ';',2) ref2, split_part(ref, ';',3) ref3, split_part(ref, ';',4) ref4 FROM osm_transport_lines WHERE type IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link', 'rail', 'taxiway', 'runway', 'apron') AND geometry && !BBOX!"

The style.json can then reference the 4 different ref fields to place individual shields.

Shields in existing camo style that need to be fixed: roadshields_camo_before

Shields after the ref field is parsed out and the style is modified:

roadshields_camo_after

ARolek commented 6 years ago

@PetersonGIS did you have a PR you want to send in for this one? Looks like a great way to clean up some of the highway carto.

PetersonGIS commented 6 years ago

Yes indeed. See above link to #45. The PR is just in the tegola-osm repo for now. Will PR for the style change once that's done I guess.

ARolek commented 6 years ago

@PetersonGIS I see. I will review that PR early next week.

PetersonGIS commented 6 years ago

Just waiting on tiles to be re-run, then I'll test out the style changes. @ARolek if you can just ping me when the ref1, ref2, etc. is live in https://osm.tegola.io