hillshade hack

This commit is contained in:
Komzpa 2012-03-18 00:55:54 +03:00
parent fe500c3f88
commit b584d09c1c
3 changed files with 42 additions and 2 deletions

View file

@ -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
srtm_dem_path = /raid/srtm/srtmm.vrt
cleantopo_hs_path = /raid/srtm/Full/CleanTOPO2merchs.tif
srtm_hs_path = /raid/srtm/srtmhs.vrt

View file

@ -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

View file

@ -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):
</Layer>
""" % (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 """
<Style name="hillshade%s">
<Rule>%s
<RasterSymbolizer opacity="1" scaling="bilinear" mode="multiply">
<RasterColorizer default-mode="linear">
<stop value="0" color="rgba(0,0,0,0.2)" />
<stop value="255" color="rgba(255,255,255,0)" />
</RasterColorizer>
</RasterSymbolizer>
</Rule>
</Style>
<Layer name="ele-hsz%s">
<StyleName>hillshade%s</StyleName>
<Datasource>
<Parameter name="file">%s</Parameter>
<Parameter name="type">gdal</Parameter>
<Parameter name="band">1</Parameter>
<Parameter name="srid">3857</Parameter>
</Datasource>
</Layer>
""" % (zoom, x_scale, zoom, zoom, hs_path)
def xml_hardcoded_arrows():
return """
<LineSymbolizer>