From b584d09c1cbbf9e3413388f550d017cbcfa5fbb4 Mon Sep 17 00:00:00 2001 From: Komzpa Date: Sun, 18 Mar 2012 00:55:54 +0300 Subject: [PATCH] hillshade hack --- src/komap.conf | 4 +++- src/komap.py | 8 ++++++++ src/libkomapnik.py | 32 +++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/komap.conf b/src/komap.conf index c0da9a0..796e311 100644 --- a/src/komap.conf +++ b/src/komap.conf @@ -8,4 +8,6 @@ db_srid = 900913 icons_path = /home/gis/mapnik/kosmo/icons/ world_bnd_path = /home/gis/mapnik/world_boundaries/ cleantopo_dem_path = /raid/srtm/Full/CleanTOPO2merc.tif -srtm_dem_path = /raid/srtm/srtmm.vrt \ No newline at end of file +srtm_dem_path = /raid/srtm/srtmm.vrt +cleantopo_hs_path = /raid/srtm/Full/CleanTOPO2merchs.tif +srtm_hs_path = /raid/srtm/srtmhs.vrt \ No newline at end of file diff --git a/src/komap.py b/src/komap.py index 5006e0a..56270c7 100644 --- a/src/komap.py +++ b/src/komap.py @@ -76,6 +76,9 @@ libkomapnik.icons_path = config.get("mapnik", "icons_path") libkomapnik.world_bnd_path = config.get("mapnik", "world_bnd_path") libkomapnik.cleantopo_dem_path = config.get("mapnik", "cleantopo_dem_path") libkomapnik.srtm_dem_path = config.get("mapnik", "srtm_dem_path") +libkomapnik.cleantopo_dem_path = config.get("mapnik", "cleantopo_hs_path") +libkomapnik.srtm_dem_path = config.get("mapnik", "srtm_hs_path") + from libkomapnik import * @@ -276,6 +279,7 @@ if options.renderer == "mapnik": bgcolor = style.get_style("canvas", {}, maxzoom)[0].get("fill-color", "") opacity = style.get_style("canvas", {}, maxzoom)[0].get("opacity", 1) demhack = style.get_style("canvas", {}, maxzoom)[0].get("-x-mapnik-dem-hack", False) + hshack = style.get_style("canvas", {}, maxzoom)[0].get("-x-mapnik-hs-hack", False) if (opacity == 1) and bgcolor: mfile.write(xml_start(bgcolor)) @@ -357,6 +361,10 @@ if options.renderer == "mapnik": mfile.write(xml_layer("postgis", "polygon", itags, sql, zoom=zoom )) else: xml_nolayer() + + if hshack: + xml = xml_hillshade(zoom, x_scale) + mfile.write(xml) index_range = range(-6,7) full_layering = conf_full_layering diff --git a/src/libkomapnik.py b/src/libkomapnik.py index 2a47057..9f8aad9 100644 --- a/src/libkomapnik.py +++ b/src/libkomapnik.py @@ -32,7 +32,8 @@ icons_path = "" world_bnd_path = "" cleantopo_dem_path = "" srtm_dem_path = "" - +cleantopo_hs_path = "" +srtm_hs_path = "" substyles = [] @@ -288,6 +289,35 @@ def xml_srtm(zoom, x_scale): """ % (zoom, x_scale, zoom, zoom, srtm_dem_path) + +def xml_hillshade(zoom, x_scale): + hs_path = cleantopo_hs_path + if zoom>6: + hs_path = srtm_hs_path + return """ + + + + hillshade%s + + %s + gdal + 1 + 3857 + + + """ % (zoom, x_scale, zoom, zoom, hs_path) + + def xml_hardcoded_arrows(): return """