Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Citytracking/toner
Browse files Browse the repository at this point in the history
  • Loading branch information
nvkelso committed Jun 27, 2012
2 parents dcf73e1 + f6327e1 commit 0fddec2
Show file tree
Hide file tree
Showing 13 changed files with 4,314 additions and 5,471 deletions.
140 changes: 25 additions & 115 deletions mapnik/datasources.ini
Expand Up @@ -29,6 +29,7 @@ user = nev
[postgis_toner_merc]
dbname = toner
estimate_extent = false
extent = -20037508,-20037508,20037508,20037508
host = localhost
layer_srs = %(srs3)s
password = None
Expand Down Expand Up @@ -111,34 +112,15 @@ template = postgis_toner_merc
table = airports_simple_0d29_less_merc

[buildings]
template = postgis_planet_osm
table = (SELECT way, ST_Area(way) AS area FROM planet_osm_polygon WHERE building IS NOT NULL ORDER BY z_order ASC, way_area DESC) AS footprints
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_buildings) AS areas

[buildings_stamen]
template = postgis_planet_osm
table = (SELECT way,
ST_Area(way) AS area,
osm_id
FROM planet_osm_polygon
WHERE building IS NOT NULL
AND osm_id in (45074542)
ORDER BY z_order ASC, way_area DESC
) AS footprints
[buildings_z13]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_buildings_z13) AS areas



[civic_areas]
template = postgis_planet_osm
table = (SELECT way,
name
FROM planet_osm_polygon
WHERE amenity IN ('school', 'college', 'university', 'bus_station',
'ferry_terminal', 'hospital', 'kindergarten',
'place_of_worship', 'public_building', 'townhall')
ORDER BY z_order ASC, way_area DESC

) AS civic

[coastline_10m__shore]
template = postgis_ne11_merc
table = coastline_10m
Expand Down Expand Up @@ -175,72 +157,17 @@ table = admin_0_countries_110m
template = postgis_ne11_merc
table = admin_0_countries_50m

[green_areas_hybrid_polygon_off]
template = postgis_planet_osm
table = (SELECT way,
name,
ST_Area(way) AS area,
(CASE WHEN leisure IN ('park', 'water_park', 'marina',
'playground',
'garden', 'common') THEN 'park'
WHEN amenity IN ('graveyard') THEN 'cemetery'
WHEN landuse IN ('cemetery') THEN 'cemetery'
WHEN leisure IN ('sports_centre', 'golf_course',
'stadium', 'track', 'pitch') THEN 'sport'
WHEN landuse IN ('recreation_ground') THEN 'sport'
WHEN landuse IN ('forest', 'wood') THEN 'forest'
ELSE '' END) AS kind
FROM planet_osm_polygon
WHERE leisure IN ('park', 'water_park', 'marina',
'playground', 'garden', 'common')
OR amenity IN ('graveyard')
OR landuse IN ('cemetery')
OR leisure IN ('sports_centre', 'golf_course', 'stadium',
'track', 'pitch')
OR landuse IN ('recreation_ground')
OR landuse IN ('forest', 'wood')
ORDER BY z_order ASC, way_area DESC

) AS greens
[green_areas]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_green_areas) AS areas

[green_areas_labels]
template = postgis_planet_osm
table = (SELECT way,
name,
ST_Area(way) AS area,
(CASE WHEN leisure IN ('park', 'water_park', 'marina',
'nature_reserve', 'playground',
'garden', 'common') THEN 'park'
WHEN amenity IN ('graveyard') THEN 'cemetery'
WHEN landuse IN ('cemetery') THEN 'cemetery'
WHEN leisure IN ('sports_centre', 'golf_course',
'stadium', 'track', 'pitch') THEN 'sport'
WHEN landuse IN ('recreation_ground') THEN 'sport'
WHEN landuse IN ('forest', 'wood') THEN 'forest'
ELSE '' END) AS kind
FROM planet_osm_polygon
WHERE leisure IN ('park', 'water_park', 'marina', 'nature_reserve',
'playground', 'garden', 'common')
OR amenity IN ('graveyard')
OR landuse IN ('cemetery')
OR leisure IN ('sports_centre', 'golf_course', 'stadium',
'track', 'pitch')
OR landuse IN ('recreation_ground')
OR landuse IN ('forest', 'wood')
ORDER BY z_order ASC, way_area DESC

) AS greens
[green_areas_z13]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_green_areas_z13) AS areas

[green_areas_transparent_hybrid_polygon_off]
template = postgis_planet_osm
table = (SELECT way,
name,
ST_Area(way) AS area
FROM planet_osm_polygon
WHERE "leisure" IN ('nature_reserve')
ORDER BY z_order ASC, way_area DESC

) AS greens
[green_areas_z10]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_green_areas_z10) AS areas

[lakes_10m__shore]
template = postgis_ne11_merc
Expand Down Expand Up @@ -400,34 +327,17 @@ table = (SELECT way,

) AS poi

[water_bodies]
template = postgis_planet_osm
table = (SELECT way,
ST_Area(way) AS area
FROM planet_osm_polygon
WHERE "natural" IN ('water', 'bay')
OR waterway IN ('riverbank')
OR landuse IN ('reservoir')
ORDER BY z_order ASC, way_area DESC

) AS water
[water_areas]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_water_areas) AS areas

[water_bodies_labels]
template = postgis_planet_osm
table = (SELECT way,
name,
ST_Area(way) AS area,
(CASE WHEN "natural" IN ('water', 'bay') THEN 'sea'
WHEN waterway IN ('riverbank') THEN 'river'
WHEN landuse IN ('reservoir') THEN 'lake'
ELSE '' END) AS kind
FROM planet_osm_polygon
WHERE "natural" IN ('water', 'bay')
OR waterway IN ('riverbank')
OR landuse IN ('reservoir')
ORDER BY z_order ASC, way_area DESC

) AS water
[water_areas_z13]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_water_areas_z13) AS areas

[water_areas_z10]
template = postgis_toner_merc
table = (SELECT osm_id, name, type, geometry, ST_Area(geometry) AS area FROM osm_water_areas_z10) AS areas

[z10_roads]
template = postgis_planet_osm
Expand Down
184 changes: 184 additions & 0 deletions mapnik/imposm/mapping.py
@@ -0,0 +1,184 @@
from imposm.mapping import Options, Polygons, LineStrings, PseudoArea, GeneralizedTable, meter_to_mapunit

def zoom_threshold(zoom):
return meter_to_mapunit(20037508.0 * 2 / (2**(8 + zoom)))

db_conf = Options(
db='toner',
host='localhost',
port=5432,
user='osm',
password='',
sslmode='allow',
prefix='osm_new_',
proj='epsg:900913',
)



# WHERE leisure IN ('park', 'water_park', 'marina', 'nature_reserve',
# 'playground', 'garden', 'common')
# OR amenity IN ('graveyard')
# OR landuse IN ('cemetery')
# OR leisure IN ('sports_centre', 'golf_course', 'stadium',
# 'track', 'pitch')
# OR landuse IN ('recreation_ground')
# OR landuse IN ('forest', 'wood')
#
# ORDER BY ST_Area(way) DESC

green_areas = Polygons(
name = 'green_areas',
fields = (
('area', PseudoArea()),
),
mapping = {
'leisure': ('park', 'water_park', 'marina', 'nature_reserve', 'playground', 'garden', 'common', 'sports_centre', 'golf_course', 'stadium', 'track', 'pitch'),
'landuse': ('cemetery', 'park', 'water_park', 'marina', 'nature_reserve', 'playground', 'garden', 'common', 'forest', 'wood'),
'amenity': ('graveyard')
}
)

green_areas_z13 = GeneralizedTable(
name = 'green_areas_z13',
tolerance = zoom_threshold(13),
origin = green_areas,
)

green_areas_z10 = GeneralizedTable(
name = 'green_areas_z10',
tolerance = zoom_threshold(10),
origin = green_areas_z13,
)



# WHERE amenity IN ('school', 'college', 'university', 'bus_station',
# 'ferry_terminal', 'hospital', 'kindergarten',
# 'place_of_worship', 'public_building', 'townhall')
# OR landuse IN ('industrial', 'commercial')

grey_areas = Polygons(
name = 'grey_areas',
fields = (
('area', PseudoArea()),
),
mapping = {
'amenity': ('school', 'college', 'university', 'bus_station', 'ferry_terminal', 'hospital', 'kindergarten', 'place_of_worship', 'public_building', 'townhall'),
'landuse': ('industrial', 'commercial')
}
)

grey_areas_z13 = GeneralizedTable(
name = 'grey_areas_z13',
tolerance = zoom_threshold(13),
origin = grey_areas,
)

grey_areas_z10 = GeneralizedTable(
name = 'grey_areas_z10',
tolerance = zoom_threshold(10),
origin = grey_areas_z13,
)



# WHERE building IS NOT NULL

buildings = Polygons(
name = 'buildings',
fields = (
('area', PseudoArea()),
),
mapping = {
'building': ('__any__',)
}
)

buildings_z13 = GeneralizedTable(
name = 'buildings_z13',
tolerance = zoom_threshold(13),
origin = buildings,
)

buildings_z10 = GeneralizedTable(
name = 'buildings_z10',
tolerance = zoom_threshold(10),
origin = buildings_z13,
)



# WHERE aeroway IS NOT NULL

aeroways = LineStrings(
name = 'aeroways',
mapping = {
'aeroway': ('__any__',)
}
)

aeroways_z13 = GeneralizedTable(
name = 'aeroways_z13',
tolerance = zoom_threshold(13),
origin = aeroways,
)

aeroways_z10 = GeneralizedTable(
name = 'aeroways_z10',
tolerance = zoom_threshold(10),
origin = aeroways_z13,
)



# WHERE waterway IS NOT NULL

waterways = LineStrings(
name = 'waterways',
mapping = {
'waterway': ('__any__',)
}
)

waterways_z13 = GeneralizedTable(
name = 'waterways_z13',
tolerance = zoom_threshold(13),
origin = waterways,
)

waterways_z10 = GeneralizedTable(
name = 'waterways_z10',
tolerance = zoom_threshold(10),
origin = waterways_z13,
)



# WHERE "natural" IN ('water', 'bay')
# OR waterway = 'riverbank'
# OR landuse = 'reservoir'

water_areas = Polygons(
name = 'water_areas',
fields = (
('area', PseudoArea()),
),
mapping = {
'natural': ('water', 'bay'),
'waterway': ('riverbank',),
'landuse': ('reservoir',)
}
)

water_areas_z13 = GeneralizedTable(
name = 'water_areas_z13',
tolerance = zoom_threshold(13),
origin = water_areas,
)

water_areas_z10 = GeneralizedTable(
name = 'water_areas_z10',
tolerance = zoom_threshold(10),
origin = water_areas_z13,
)

0 comments on commit 0fddec2

Please sign in to comment.