Skip to content
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

roads-fill railway ordering (affects ways with both railway and aeroway tag) #942

Closed
pnorman opened this issue Sep 13, 2014 · 5 comments
Closed

Comments

@pnorman
Copy link
Collaborator

pnorman commented Sep 13, 2014

The roads-fill layer has the following SQL for getting railways

SELECT 
    way, prio, 
    COALESCE(
      ('railway_' || (CASE WHEN railway='preserved' AND service IN ('spur','siding','yard') THEN 'INT-preserved-ssy'::text WHEN (railway='rail' AND service in ('spur','siding','yard')) THEN 'INT-spur-siding-yard' ELSE railway END)),
      ('aeroway_' || aeroway)
    ) AS feature,
    horse, foot, bicycle, tracktype,
    CASE WHEN access in ('destination') THEN 'destination'::text 
      WHEN access IN ('no', 'private') THEN 'no'::text 
      ELSE NULL 
    END as access,
    construction,
    CASE WHEN service in ('parking_aisle','drive-through','driveway') THEN 'INT-minor'::text 
      ELSE 'INT-normal'::text 
    END as service,
    NULL as oneway, 
    'no' as link,
    CASE WHEN layer IS NULL THEN '0' ELSE layer END AS layernotnull 
  FROM planet_osm_line 
    JOIN (VALUES
      ('railway_rail',430),
      ('railway_spur',430),
      ('railway_siding',430),
      ('railway_subway',420),
      ('railway_narrow_gauge',420),
      ('railway_light_rail',420),
      ('railway_preserved',420),
      ('railway_funicular',420),
      ('railway_monorail',420), 
      ('railway_miniature',420),
      ('railway_turntable',420),
      ('railway_tram',410),
      ('railway_disused',400),
      ('railway_construction',400),
      ('aeroway_runway',60),
      ('aeroway_taxiway',50),
      ('railway_platform',90)) as ordertable (feature, prio) 
    ON COALESCE(('railway_' || planet_osm_line.railway), ('aeroway_' || planet_osm_line.aeroway)) = ordertable.feature 
  WHERE (tunnel IS NULL OR NOT tunnel IN ('yes','building_passage')) 
    AND (covered IS NULL OR NOT covered='yes') 
    AND (bridge IS NULL OR NOT bridge IN ('yes','viaduct'))

(roads portion omitted)

The problematic SQL is ON COALESCE(('railway_' || planet_osm_line.railway), ('aeroway_' || planet_osm_line.aeroway)) = ordertable.feature
For a way with railway=foo aeroway=runway it wil compute the join as joining COALESCE('railway_foo','aeroway_runway'), which evaluates to railway_foo, which doesn't match, hence preventing the runway from rendering.

@matthijsmelissen
Copy link
Collaborator

Is this something that needs solving? I can imagine that ways with both a railway and an aeroway tag are nearly always bad tagging.

@matkoniecz
Copy link
Contributor

Gisborne Airport has just runway/railway crossing but even this is considered as unique.

@pnorman
Copy link
Collaborator Author

pnorman commented Sep 13, 2014

Is this something that needs solving? I can imagine that ways with both a railway and an aeroway tag are nearly always bad tagging.

Well, this is inconsistent with formation of a feature column elsewhere, where we do check that the take is one of a subset of values. As an example, see, landcover, which has

(SELECT 
    way, name, religion,
    COALESCE(..., amenity, landuse, ...) AS feature 
  FROM (SELECT 
      way, COALESCE(name,'') AS name, 
      ('amenity_' || (CASE WHEN amenity IN ('parking', 'university', 'college', 'school', 'hospital', 'kindergarten', 'grave_yard') THEN amenity ELSE NULL END)) AS amenity,
      ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'field', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'recreation_ground', 'conservation', 'village_green', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,
    FROM planet_osm_polygon
    WHERE landuse IS NOT NULL
      OR leisure IS NOT NULL
      OR amenity IN ('parking','university','college','school','hospital','kindergarten','grave_yard')
    ORDER BY z_order, way_area DESC
  ) AS landcover
) AS features

(Query simplified)

I see a few rewrites to the query to simplify the SQL that can at the same time fix this problem.

@lkernan
Copy link

lkernan commented Sep 15, 2014

While the rail line is closed now, there used to be a railway/runway crossing in Australia too.
http://www.airwaysmuseum.com/WYY%20rail%20crossing%201.htm

Uncommon, yes. Bad tagging, no.

@matthijsmelissen matthijsmelissen modified the milestones: 3.x - Needs upgrade to mapnik or openstreetmap-carto.style, Bugs and improvements Sep 26, 2014
@matkoniecz matkoniecz changed the title roads-fill railway ordering roads-fill railway ordering (affects ways with both railway and aeroway tag) Jul 21, 2015
@pnorman
Copy link
Collaborator Author

pnorman commented Jul 16, 2022

roads-fill no longer has aeroways

@pnorman pnorman closed this as completed Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants