Skip to content

Commit

Permalink
Avoid COALESCE in WHERE clauses
Browse files Browse the repository at this point in the history
  • Loading branch information
frafra committed Oct 19, 2024
1 parent 9f0752a commit 23696a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ Layer:
COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name
FROM planet_osm_polygon
WHERE way && !bbox!
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND boundary = 'administrative'
AND admin_level = '2'
AND way_area > 100*POW(!scale_denominator!*0.001*0.28,2)
Expand All @@ -1304,7 +1304,7 @@ Layer:
round(ascii(md5(osm_id::text)) / 55) AS dir -- base direction factor on geometry to be consistent across metatiles
FROM planet_osm_point
WHERE place IN ('city', 'town', 'village', 'hamlet')
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND tags @> 'capital=>yes'
ORDER BY population DESC
) AS capital_names
Expand All @@ -1325,7 +1325,7 @@ Layer:
ref
FROM planet_osm_polygon
WHERE ST_PointOnSurface(way) && !bbox!
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND boundary = 'administrative'
AND admin_level = '4'
AND way_area > 3000*POW(!scale_denominator!*0.001*0.28,2)
Expand Down Expand Up @@ -1371,7 +1371,7 @@ Layer:
) AS score
FROM planet_osm_point
WHERE place IN ('city', 'town')
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND NOT (tags @> 'capital=>yes')
) as p
ORDER BY score DESC, length(name) DESC, name
Expand All @@ -1392,10 +1392,10 @@ Layer:
COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name
FROM planet_osm_point
WHERE place IN ('village', 'hamlet')
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND NOT tags @> 'capital=>yes'
OR (place IN ('suburb', 'quarter', 'neighbourhood', 'isolated_dwelling', 'farm')
) AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
) AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
ORDER BY CASE
WHEN place = 'suburb' THEN 7
WHEN place = 'village' THEN 6
Expand Down Expand Up @@ -1507,7 +1507,7 @@ Layer:
COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name
FROM planet_osm_polygon
WHERE ST_PointOnSurface(way) && !bbox!
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND man_made = 'bridge'
AND way_area > 125*POW(!scale_denominator!*0.001*0.28,2)
AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2)
Expand All @@ -1528,7 +1528,7 @@ Layer:
admin_level
FROM planet_osm_polygon
WHERE ST_PointOnSurface(way) && !bbox!
AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL
AND name IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND (tags->('name:it')) IS NOT NULL
AND boundary = 'administrative'
AND admin_level IN ('5', '6')
AND way_area > 12000*POW(!scale_denominator!*0.001*0.28,2)
Expand Down

0 comments on commit 23696a2

Please sign in to comment.