From baff011c211c0463b882986baaae18593333d870 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 1 Mar 2015 18:57:43 -0800 Subject: [PATCH 1/3] Reformat addr:housename SQL --- project.mml | 2 +- project.yaml | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/project.mml b/project.mml index cf6e65969b..f8f3cf5412 100644 --- a/project.mml +++ b/project.mml @@ -1820,7 +1820,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way,\"addr:housename\", way_area FROM planet_osm_polygon WHERE \"addr:housename\" IS NOT NULL AND building IS NOT NULL\n UNION\n SELECT way,\"addr:housename\", NULL AS way_area FROM planet_osm_point WHERE \"addr:housename\" IS NOT NULL\n ORDER BY way_area DESC\n ) AS housenames", + "table": "(SELECT\n way,\n \"addr:housename\",\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE \"addr:housename\" IS NOT NULL\n AND building IS NOT NULL\nUNION ALL\nSELECT\n way,\n \"addr:housename\",\n NULL AS way_pixels\n FROM planet_osm_point WHERE \"addr:housename\" IS NOT NULL\nORDER BY way_pixels DESC NULLS LAST\n) AS housenames", "geometry_field": "way", "type": "postgis", "key_field": "", diff --git a/project.yaml b/project.yaml index 33d6f09028..95846a6949 100644 --- a/project.yaml +++ b/project.yaml @@ -1749,12 +1749,22 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql - table: |2- - (SELECT way,"addr:housename", way_area FROM planet_osm_polygon WHERE "addr:housename" IS NOT NULL AND building IS NOT NULL - UNION - SELECT way,"addr:housename", NULL AS way_area FROM planet_osm_point WHERE "addr:housename" IS NOT NULL - ORDER BY way_area DESC - ) AS housenames + table: |- + (SELECT + way, + "addr:housename", + way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels + FROM planet_osm_polygon + WHERE "addr:housename" IS NOT NULL + AND building IS NOT NULL + UNION ALL + SELECT + way, + "addr:housename", + NULL AS way_pixels + FROM planet_osm_point WHERE "addr:housename" IS NOT NULL + ORDER BY way_pixels DESC NULLS LAST + ) AS housenames properties: minzoom: 17 advanced: {} From 4f5385de217fce6a0920e2c97c5639ed1586bd2d Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 1 Mar 2015 19:33:29 -0800 Subject: [PATCH 2/3] Reformat addr:housenumber SQL --- project.mml | 2 +- project.yaml | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/project.mml b/project.mml index f8f3cf5412..14d2cc8ba3 100644 --- a/project.mml +++ b/project.mml @@ -1794,7 +1794,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": " (SELECT way,\"addr:housenumber\", way_area FROM planet_osm_polygon WHERE \"addr:housenumber\" IS NOT NULL AND building IS NOT NULL\n UNION\n SELECT way,\"addr:housenumber\", NULL AS way_area FROM planet_osm_point WHERE \"addr:housenumber\" IS NOT NULL\n ORDER BY way_area DESC\n ) AS housenumbers", + "table": "(SELECT\n way,\n \"addr:housenumber\",\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE \"addr:housenumber\" IS NOT NULL\n AND building IS NOT NULL\nUNION ALL\nSELECT\n way,\n \"addr:housenumber\",\n NULL AS way_pixels\n FROM planet_osm_point\n WHERE \"addr:housenumber\" IS NOT NULL\n ORDER BY way_pixels DESC NULLS LAST\n) AS housenumbers", "geometry_field": "way", "type": "postgis", "key_field": "", diff --git a/project.yaml b/project.yaml index 95846a6949..ab57802374 100644 --- a/project.yaml +++ b/project.yaml @@ -1733,12 +1733,23 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql - table: |2- - (SELECT way,"addr:housenumber", way_area FROM planet_osm_polygon WHERE "addr:housenumber" IS NOT NULL AND building IS NOT NULL - UNION - SELECT way,"addr:housenumber", NULL AS way_area FROM planet_osm_point WHERE "addr:housenumber" IS NOT NULL - ORDER BY way_area DESC - ) AS housenumbers + table: |- + (SELECT + way, + "addr:housenumber", + way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels + FROM planet_osm_polygon + WHERE "addr:housenumber" IS NOT NULL + AND building IS NOT NULL + UNION ALL + SELECT + way, + "addr:housenumber", + NULL AS way_pixels + FROM planet_osm_point + WHERE "addr:housenumber" IS NOT NULL + ORDER BY way_pixels DESC NULLS LAST + ) AS housenumbers properties: minzoom: 17 advanced: {} From 11b3519cbe5b5065752c022de55f6cfceb6c05a8 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 1 Mar 2015 19:43:40 -0800 Subject: [PATCH 3/3] Reformat addr:interpolation SQL --- project.mml | 2 +- project.yaml | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/project.mml b/project.mml index 14d2cc8ba3..e319b68fd4 100644 --- a/project.mml +++ b/project.mml @@ -1768,7 +1768,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way\nFROM planet_osm_line\nWHERE \"addr:interpolation\" IS NOT NULL) AS interpolation", + "table": "(SELECT\n way\n FROM planet_osm_line\n WHERE \"addr:interpolation\" IS NOT NULL\n) AS interpolation", "geometry_field": "way", "type": "postgis", "key_field": "", diff --git a/project.yaml b/project.yaml index ab57802374..7ef3d7be8e 100644 --- a/project.yaml +++ b/project.yaml @@ -1719,10 +1719,12 @@ Layer: <<: *extents Datasource: <<: *osm2pgsql - table: |2- - (SELECT way - FROM planet_osm_line - WHERE "addr:interpolation" IS NOT NULL) AS interpolation + table: |- + (SELECT + way + FROM planet_osm_line + WHERE "addr:interpolation" IS NOT NULL + ) AS interpolation properties: minzoom: 17 advanced: {}