diff --git a/src/komap.conf b/src/komap.conf
new file mode 100644
index 0000000..63dbca1
--- /dev/null
+++ b/src/komap.conf
@@ -0,0 +1,9 @@
+[mapnik]
+map_proj = +init=epsg:3857
+db_proj = +init=epsg:3857
+table_prefix = planet_osm_
+db_user = gis
+db_name = gis
+db_srid = 900913
+icons_path = /home/gis/mapnik/kosmo/icons/
+world_bnd_path = /home/gis/mapnik/world_boundaries/
diff --git a/src/komap.py b/src/komap.py
index 0a8eb36..8c17eda 100644
--- a/src/komap.py
+++ b/src/komap.py
@@ -20,8 +20,11 @@ from mapcss import MapCSS
import sys
import os
import Image
-from libkomapnik import *
from optparse import OptionParser
+import ConfigParser
+
+config = ConfigParser.ConfigParser()
+
try:
import psyco
@@ -52,15 +55,34 @@ parser.add_option("-o", "--output-file", dest="outfile", default="-",
help="output filename (defaults to stdout)", metavar="FILE")
parser.add_option("-p", "--osm2pgsql-style", dest="osm2pgsqlstyle", default="-",
help="osm2pgsql stylesheet filename", metavar="FILE")
-
parser.add_option("-b", "--background-only", dest="bgonly", action="store_true", default=False,
help="Skip rendering of icons and labels", metavar="BOOL")
-
+parser.add_option("-c", "--config", dest="conffile", default="komap.conf",
+ help="config file name", metavar="FILE")
(options, args) = parser.parse_args()
#print (options, args)
+import libkomapnik
+config.read(['komap.conf', os.path.expanduser('~/.komap/komap.conf'), options.conffile])
+libkomapnik.map_proj = config.get("mapnik", "map_proj")
+libkomapnik.db_proj = config.get("mapnik", "db_proj")
+libkomapnik.table_prefix = config.get("mapnik", "table_prefix")
+libkomapnik.db_user = config.get("mapnik", "db_user")
+libkomapnik.db_name = config.get("mapnik", "db_name")
+libkomapnik.db_srid = config.get("mapnik", "db_srid")
+libkomapnik.icons_path = config.get("mapnik", "icons_path")
+libkomapnik.world_bnd_path = config.get("mapnik", "world_bnd_path")
+
+from libkomapnik import *
+
+
+
+
+
+
+
minzoom = options.minzoom
maxzoom = options.maxzoom+1
@@ -274,52 +296,7 @@ if options.renderer == "mapnik":
ta = zsheet.keys()
ta.sort(key=float)
if demhack and zoom >= 7:
- xml="""
-
-
-
- elevation1z%s
-
- /raid/srtm/Full/CleanTOPO2merc.tif
- gdal
- 1
- 4326
-
-
- """
- xml = xml%(zoom, x_scale, zoom, zoom)
+ xml = xml_cleantopo(zoom, x_scale)
mfile.write(xml)
if zoom in coast:
xml = xml_style_start()
@@ -335,88 +312,11 @@ if options.renderer == "mapnik":
mfile.write(xml)
if demhack and zoom < 7:
- xml="""
-
-
-
- elevationz%s
-
- /raid/srtm/Full/CleanTOPO2merc.tif
- gdal
- 1
- 4326
-
-
- """
- xml = xml%(zoom, x_scale, zoom, zoom)
+ xml = xml_cleantopo(zoom, x_scale)
mfile.write(xml)
-
if demhack and zoom >= 7:
- xml="""
-
-
-
- elevationz%s
-
- /raid/srtm/srtmm.vrt
- gdal
- 1
- 4326
-
-
- """
- xml = xml%(zoom, x_scale, zoom, zoom)
+ xml = xml_srtm(zoom, x_scale)
mfile.write(xml)
sql_g = set()
@@ -459,32 +359,7 @@ if options.renderer == "mapnik":
mfile.write(xml_layer("postgis", "polygon", itags, sql, zoom=zoom ))
else:
xml_nolayer()
-
- if demhack and zoom<6:
- xml = """
-
-
- hillshadez%s
-
- /raid/srtm/Full/CleanTOPO2merchs.tif
- gdal
- 1
-
-
- """
- xml = xml%(zoom, x_scale, zoom, zoom)
- mfile.write(xml)
-
+
index_range = range(-6,7)
full_layering = conf_full_layering
if (zoom < 9) or not conf_full_layering :
diff --git a/src/libkomapnik.py b/src/libkomapnik.py
index 761b6da..bdc8045 100644
--- a/src/libkomapnik.py
+++ b/src/libkomapnik.py
@@ -21,14 +21,14 @@ from debug import debug, Timer
from mapcss.webcolors.webcolors import whatever_to_hex as nicecolor
-map_proj = "+init=epsg:3857"
-db_proj = "+init=epsg:3857"
-table_prefix = "planet_osm_"
-db_user = "gis"
-db_name = "gis"
-db_srid = 900913
-icons_path = "/home/gis/mapnik/kosmo/icons/"
-world_bnd_path = "/home/gis/mapnik/world_boundaries/"
+map_proj = ""
+db_proj = ""
+table_prefix = ""
+db_user = ""
+db_name = ""
+db_srid = ""
+icons_path = ""
+world_bnd_path = ""
@@ -206,6 +206,86 @@ def xml_rule_end():
return """
"""
+def xml_cleantopo(zoom, x_scale):
+ return """
+
+
+
+ elevation1z%s
+
+ /raid/srtm/Full/CleanTOPO2merc.tif
+ gdal
+ 1
+ 4326
+
+
+ """ % (zoom, x_scale, zoom, zoom)
+
+def xml_srtm(zoom, x_scale):
+ return """
+
+
+
+ elevationz%s
+
+ /raid/srtm/srtmm.vrt
+ gdal
+ 1
+ 4326
+
+
+ """ % (zoom, x_scale, zoom, zoom)
+
def xml_hardcoded_arrows():
return """