I've trying to find a solution to applying the OpenStreetMap z-order in QGIS after using osm2pgsql. Everything is working perfectly, until I add the each layer to the canvas, where the z-order is not being applied.
I've tried searching for solution for the last couple of hours and have yet to find anything that is working.
Here are the steps I've taken thus far:
osm2pgsql -d OSM_Test -l -u -U 'username' -W -H 'host' -P 'port' -k 'filepath'/oregon-latest.osm.pbf
Note: '<...>' is being used as a placeholder.
- Each layer (line, point, polygon, road) is added with a land layer from Natural Earth.
- Rule-based styles are added for each OpenStreetMap road type.
I know that I can combine each road style with the z-order, however, this can create 60 different options for each road type/style.
Where am I going wrong? or am I missing something with a PostGIS function than can applied to the z-order?
I have confirmed that the z-order column is present for each.
Answer
The z_order is just a column in the database tables. You can filter the data for a certain value (or range of values), and apply your styles. Then you can duplicate the layer, but set the filter to another z value.
The order of rendering is defined by the order of the layers in the QGIS table of content. The top layer will be rendered on top of the others.
Points don't seem to have a z_order, I have only NULL values in the point table.
The original Mapnik style uses order by z_order in the SQL Query, but that is not possible in the simple QGIS query. So you have to use the DB Manager.
Select the PostGIS, your database, public schema, planet_line table, then click on the SQL Window icon, and enter:
Select * from planet_line order by z_order;
Check Load as new Layer, Click on Retreive Columns, select osm_id as unique integer and way as Geometry column, then click on Load now!.
This works as expected, but you will not get the nice road casing at crossings. The Mapnik style uses four rendering rules for bridges, filtered by the layer column, drawing casing and fill for each layer before rendering the next one.
No comments:
Post a Comment