9

I labeled my osm-lines-layer (PostGIS) with symbols for primary roads and motorways. While the symbols for the primary roads are well placed - with enough distance between each - the two-lane motorway is labeled with one label per lane (as you can see in the image).

Is it possible, to set something like a radius from each label, within no other label of the same type can be placed? Or can I just say: label one lane of a two-lane road?

I'm using qgis. The OSM-Data is imported to PostGIS with osm2pgsql.

enter image description here

EDIT:This new screenshot shows more detail:

enter image description here

5
+50

To label only one lane of a two-lane road I'm using the expression:

 angle_at_vertex($geometry,1) <= 180

and use it as filter. This works because in OSM each lane is drawn in their direction.

In the example below I'm using the expression angle_at_vertex($geometry,1) as label and in the second picture the expression angle_at_vertex($geometry,1) <= 180 as filter.

Before:

enter image description here

After:

enter image description here

Settings:

enter image description here

  • Now that's one clever little trick. +1 also for the QML file. – ThingumaBob May 16 at 7:18
2

I don't know the schema of the OSM tables, but you asked for a query like this:

DELETE FROM labels WHERE label_id  IN (
    SELECT label_id_2 FROM (
        SELECT a.label_id AS label_id_1, b.label_id AS label_id_2 
        FROM labels AS a, labels AS b WHERE STDWithin(a.the_geom,b.the_geom, 0.001) and a.street = b.street and a.label_id != b.label_id
    )
)

This may work but It would be better if you have an id for the same label for different directions, and then this query would work 100%:

DELETE FROM labels WHERE label_id  IN (
    SELECT label_id_2 FROM (
        SELECT a.label_id AS label_id_1, b.label_id AS label_id_2 
        FROM labels AS a, labels AS b WHERE a.same_road_label_id = b.same_road_label_id;
    )
)
  • Looks fine, but Im not familiar with sql-programming. So, could you please explain what "a.label_id", "a.label_id_1" and so on stands for? My table has a ID (column osm_id) and a column (ref) for the label (for example "A70"). – MAP Oct 10 '14 at 19:04
  • I've nicknamed labels table as "a" and "b", and label_id column(osm_id) as label_id_1 and label_id_2 with the "AS" statement, I had to because in the deepest subquery we have two columns(label_id) and two tables(labels) with the same name. – Francisco Valdez Oct 16 '14 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.