diff --git a/src/backend/vtile/__init__.py b/src/backend/vtile/__init__.py
index 790c94d..8b51296 100644
--- a/src/backend/vtile/__init__.py
+++ b/src/backend/vtile/__init__.py
@@ -75,13 +75,14 @@ class QuadTileBackend:
def filename(self, (z,x,y)):
+
return "%s/z%s/%s/x%s/%s/y%s.vtile"%(self.path, z, x/1024, x, y/1024, y)
def load_tile(self, k):
#debug("loading tile: %s"% (k,))
try:
f = open(self.filename(k))
except IOError:
- #print ( "Failed open: '%s'" % self.filename(k) )
+ print ( "Failed open: '%s'" % self.filename(k) )
return {}
t = {}
for line in f:
@@ -112,7 +113,10 @@ class QuadTileBackend:
zoom = max(zoom, 0) ## Negative zooms are nonsense
a,d,c,b = [int(x) for x in projections.tile_by_bbox(bbox,zoom, self.proj)]
resp = {}
- hint = [x[0] for x in sql_hint]
+
+ hint = set()
+ for j in [x[0] for x in sql_hint]:
+ hint.update(j)
for tile in set([(zoom,i,j) for i in range(a, c+1) for j in range(b, d+1)]):
# Loading current vector tile
@@ -131,7 +135,7 @@ class QuadTileBackend:
"filling response with interesting-tagged objects"
need = False
for tag in ti[obj].tags:
- if tag in hint:
+ #if tag in hint:
need = True
break
if need:
diff --git a/src/gtk-app.py b/src/gtk-app.py
index 70ace7c..d93fa0f 100644
--- a/src/gtk-app.py
+++ b/src/gtk-app.py
@@ -38,7 +38,8 @@ try:
import psyco
psyco.full()
except ImportError:
- debug("Psyco import failed. Program may run slower. Ir you run it on i386 machine, please install Psyco to get best performance.")
+ pass
+# debug("Psyco import failed. Program may run slower. Ir you run it on i386 machine, please install Psyco to get best performance.")
class KothicApp:
@@ -104,7 +105,7 @@ class KothicApp:
def load_style(self):
self.style = Styling(0,25)
- self.style.parse(open("styles/default.mapcss","r").read())
+ self.style.parse(open("styles/osmosnimki-maps.mapcss","r").read())
def reload_style(self,w):
self.style = Styling(0,25)
self.style.parse(open("styles/%s"%w.StyleName,"r").read())
diff --git a/src/komap.py b/src/komap.py
index 8037286..9be1944 100644
--- a/src/komap.py
+++ b/src/komap.py
@@ -17,6 +17,8 @@
from debug import debug, Timer
from mapcss import MapCSS
+import mapcss.webcolors
+whatever_to_hex = mapcss.webcolors.webcolors.whatever_to_hex
import sys
reload(sys)
@@ -234,6 +236,7 @@ if options.renderer == "mapnik":
# {zoom: {z-index: [{sql:sql_hint, cond: mapnikfiltercondition, subject: subj, style: {a:b,c:d..}},{r2}...]...}...}
coast = {}
fonts = set()
+ demhack = False
for zoom in range (minzoom, maxzoom):
mapniksheet[zoom] = {}
zsheet = mapniksheet[zoom]
@@ -268,8 +271,10 @@ if options.renderer == "mapnik":
#print chooser_entry["rule"]
chooser_entry["rulestring"] = " or ".join([ "("+ " and ".join([i.get_mapnik_filter() for i in rule if i.get_mapnik_filter()]) + ")" for rule in chooser_entry["rule"]])
chooser_entry["chooser"] = chooser
+ if chooser_entry["type"] == "ele":
+ demhack = True
if chooser_entry["type"] == "area" and "[natural] = 'coastline'" in chooser_entry["rulestring"]:
- coast[zoom] = chooser_entry["style"]
+ coast[zoom] = chooser_entry["style"]
else:
zsheet[zindex].append(chooser_entry)
@@ -298,7 +303,6 @@ 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:
@@ -317,8 +321,26 @@ if options.renderer == "mapnik":
x_scale = xml_scaledenominator(zoom)
ta = zsheet.keys()
ta.sort(key=float)
+ demcolors = {}
+ demramp = {"ground":"", "ocean":""}
+
+ if demhack:
+ for zindex in ta:
+ for entry in zsheet[zindex]:
+ if entry["type"] in ("ele",):
+ ele = int(entry["rule"][0][0].params[0])
+ demcolors[ele] = (whatever_to_hex(entry["style"].get('fill-color', '#ffffff')), entry["style"].get('fill-opacity', '1'))
+ dk = demcolors.keys()
+ dk.sort()
+ for ele in dk:
+ (color, opacity) = demcolors[ele]
+ demramp["ocean"] += '' %(ele, int(color[1:3],16), int(color[3:5],16), int(color[5:7],16), opacity)
+ demramp["ground"] += '' %(ele-11701, int(color[1:3],16), int(color[3:5],16), int(color[5:7],16), opacity)
+
+
+
if demhack and zoom >= 7:
- xml = xml_cleantopo(zoom, x_scale)
+ xml = xml_cleantopo(zoom, x_scale, demramp["ocean"])
mfile.write(xml)
if zoom in coast:
xml = xml_style_start()
@@ -334,11 +356,11 @@ if options.renderer == "mapnik":
mfile.write(xml)
if demhack and zoom < 7:
- xml = xml_cleantopo(zoom, x_scale)
+ xml = xml_cleantopo(zoom, x_scale, demramp["ocean"])
mfile.write(xml)
if demhack and zoom >= 7:
- xml = xml_srtm(zoom, x_scale)
+ xml = xml_srtm(zoom, x_scale, demramp["ground"])
mfile.write(xml)
sql_g = set()
@@ -355,7 +377,6 @@ if options.renderer == "mapnik":
if ("fill-color" in entry["style"] or "fill-image" in entry["style"]) and (entry["style"].get("fill-position", "foreground")=="background"):
xml += xml_rule_start()
xml += x_scale
-
xml += xml_filter(entry["rulestring"])
if "fill-color" in entry["style"]:
xml += xml_polygonsymbolizer(entry["style"].get("fill-color", "black"), entry["style"].get("fill-opacity", "1"))
diff --git a/src/libkomapnik.py b/src/libkomapnik.py
index 7e7967c..6eba665 100644
--- a/src/libkomapnik.py
+++ b/src/libkomapnik.py
@@ -209,38 +209,14 @@ def xml_rule_end():
return """
"""
-def xml_cleantopo(zoom, x_scale):
+def xml_cleantopo(zoom, x_scale, demramp):
return """
@@ -254,7 +230,7 @@ def xml_cleantopo(zoom, x_scale):
3857
- """ % (zoom, x_scale, zoom, zoom, cleantopo_dem_path)
+""" % (zoom, x_scale, demramp, zoom, zoom, cleantopo_dem_path)
def xml_srtm(zoom, x_scale):
return """
@@ -262,17 +238,7 @@ def xml_srtm(zoom, x_scale):
%s
-
-
-
-
-
-
-
-
-
-
-
+ %s
@@ -287,7 +253,7 @@ def xml_srtm(zoom, x_scale):
3857
- """ % (zoom, x_scale, zoom, zoom, srtm_dem_path)
+ """ % (zoom, x_scale, demramp, zoom, zoom, srtm_dem_path)
def xml_hillshade(zoom, x_scale):
diff --git a/src/mapcss/__init__.py b/src/mapcss/__init__.py
index 1b7945a..4b7489d 100644
--- a/src/mapcss/__init__.py
+++ b/src/mapcss/__init__.py
@@ -45,7 +45,7 @@ ZOOM_SINGLE = re.compile(r'^ (\d+) $', re.S | re.X)
CONDITION_TRUE = re.compile(r'^ \s* ([:\w]+) \s* [?] \s* $', re.I | re.S | re.X)
CONDITION_invTRUE = re.compile(r'^ \s* [!] \s* ([:\w]+) \s* [?] \s* $', re.I | re.S | re.X)
CONDITION_FALSE = re.compile(r'^ \s* ([:\w]+) \s* = \s* no \s* $', re.I | re.S | re.X)
-CONDITION_SET = re.compile(r'^ \s* ([:\w]+) \s* $', re.S | re.X)
+CONDITION_SET = re.compile(r'^ \s* ([-:\w]+) \s* $', re.S | re.X)
CONDITION_UNSET = re.compile(r'^ \s* !([:\w]+) \s* $', re.S | re.X)
CONDITION_EQ = re.compile(r'^ \s* ([:\w]+) \s* = \s* (.+) \s* $', re.S | re.X)
CONDITION_NE = re.compile(r'^ \s* ([:\w]+) \s* != \s* (.+) \s* $', re.S | re.X)
diff --git a/src/mapcss/webcolors/webcolors.py b/src/mapcss/webcolors/webcolors.py
index d162614..7b7a47b 100644
--- a/src/mapcss/webcolors/webcolors.py
+++ b/src/mapcss/webcolors/webcolors.py
@@ -839,21 +839,24 @@ def whatever_to_rgb(string):
"""
Converts CSS3 color or a hex into rgb triplet; hash of string if fails.
"""
+ string = string.strip().lower()
try:
return name_to_rgb(string)
except ValueError:
try:
return hex_to_rgb(string)
except ValueError:
- #a = md5.new(string)
- return hex_to_rgb("#"+md5(string).hexdigest()[:6])
+ try:
+ if string[:3] == "rgb":
+ return tuple([float(i) for i in string[4:-1].split(",")][0:3])
+
+ except:
+ return hex_to_rgb("#"+md5(string).hexdigest()[:6])
def whatever_to_hex(string):
if type(string) == tuple:
return cairo_to_hex(string)
return rgb_to_hex(whatever_to_rgb(string))
-
-
def whatever_to_cairo(string):
a = whatever_to_rgb(string)
return a[0]/255.,a[1]/255.,a[2]/255.,
@@ -863,11 +866,6 @@ def cairo_to_hex (cairo):
-
-
-
-
-
if __name__ == '__main__':
import doctest
doctest.testmod()
diff --git a/src/render.py b/src/render.py
index 60bddaa..ca9ff33 100644
--- a/src/render.py
+++ b/src/render.py
@@ -151,8 +151,10 @@ class RasterTile:
ww = []
for way in vectors:
-
- st = style.get_style("way", way.tags, self.zoom, scale, zscale)
+ type = "line"
+ if way.coords[0] == way.coords[-1]:
+ type == "area"
+ st = style.get_style("area", way.tags, self.zoom, scale, zscale)
if st:
for fpt in st:
#debug(fpt)
diff --git a/src/styles/osmosnimki-maps.mapcss b/src/styles/osmosnimki-maps.mapcss
index 9df3cdc..4d67858 100644
--- a/src/styles/osmosnimki-maps.mapcss
+++ b/src/styles/osmosnimki-maps.mapcss
@@ -3,6 +3,8 @@ meta {
}
+
+
/*
Deja Vu MapCSS styles
Osmosnimki maps style
@@ -10,6 +12,40 @@ meta {
/* коментарии отделяются так и могут встречаться везде, где можно поставить пробел */
+
+
+
+
+ ele[-11000]{fill-color:#98b7f5}
+ ele[-10000]{fill-color:#9fbcf5}
+ ele[-9000] {fill-color:#a6c1f5}
+ ele[-8000] {fill-color:#abc4f5}
+ ele[-7000] {fill-color:#b0c7f5}
+ ele[-6000] {fill-color:#b5caf5}
+ ele[-5000] {fill-color:#bacef5}
+ ele[-4000] {fill-color:#bfd1f5}
+ ele[-3000] {fill-color:#c4d4f5}
+ ele[-2000] {fill-color:#c6d6f5}
+ ele[-500] {fill-color:#c9d7f5}
+ ele[-200] {fill-color:rgb(231, 209, 175); fill-opacity: 0.1}
+ ele[200] {fill-color:rgb(231, 209, 175); fill-opacity: 0.2}
+ ele[500] {fill-color:rgb(226, 203, 170); fill-opacity: 0.2}
+ ele[1000] {fill-color:rgb(217, 194, 159); fill-opacity: 0.3}
+ ele[2000] {fill-color:rgb(208, 184, 147); fill-opacity: 0.4}
+ ele[3000] {fill-color:rgb(197, 172, 136); fill-opacity: 0.5}
+ ele[4000] {fill-color:rgb(188, 158, 120); fill-opacity: 0.55}
+ ele[5000] {fill-color:rgb(179, 139, 102); fill-opacity: 0.6}
+ ele[6000] {fill-color:rgb(157, 121, 87); fill-opacity: 0.7}
+ ele[7000] {fill-color:rgb(157, 121, 87); fill-opacity: 0.8}
+ ele[8000] {fill-color:rgb(144, 109, 77); fill-opacity: 0.9}
+
+
+
+
+
+
+
+
canvas {
fill-color: #C4D4F5;
-x-mapnik-dem-hack: true;
@@ -1532,7 +1568,7 @@ max-width:30; z-index:15}
node|z17-[sport=10pin] {icon-image:"9pin.png"; text-offset:10; text:name; font-size:8;
font-family: "DejaVu Sans Book"; text-color:#2D1A2D; text-halo-radius: 1;
text-halo-color: #ffffff; text-allow-overlap: false; -x-mapnik-min-distance:0; text-placement:any;
-max-width:30; z-index:15
+max-width:30; z-index:15}
node|z17-[sport=equestrian] {icon-image:"equestrian.png"; text-offset:10; text:name; font-size:8;
font-family: "DejaVu Sans Book"; text-color:#2D1A2D; text-halo-radius: 1;
text-halo-color: #ffffff; text-allow-overlap: false; -x-mapnik-min-distance:0; text-placement:any;