2

I want to place river names in Tilemill. I use "text-dy" to displace label from the center line of a river. But for labeling polygonal rivers, names extracted from lines are used too. So at a small zoom, labels of polygon rivers crawl over river's banks (see attachment_1).

I used ST_intersects to exclude from the selection linear rivers being intersected by polygonal ones, and not to displace labels for them:

( SELECT way,name,
  FROM planet_osm_line
  WHERE waterway IN ('river','canal') AND name IS NOT NULL
  AND ST_Intersects(way,(
    SELECT ST_Collect(way)
    FROM planet_osm_polygon
    WHERE waterway = 'riverbank' AND way && !bbox!))
) AS riv_center

It runs sucessfully, but there are some other problem: line rivers, falling into polygon ones, have short intersection with them and are labelled too (see attachment_2). Maybe one can specify some tolerance for intersection to exclude all line rivers from selection?

Thanks in advance.

Attachment_1

Attachment_2

2

You can check that intersection is at least 90% of a river segment's length. And not select it in two layers, but just make it a column: SELECT way, name, (CASE WHEN ST_Length(ST_Intersection(way, (...))) / ST_Length(way) < 0.3 THEN 1 ELSE 0 END) AS linear FROM ...

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.