From f555e1c13c7eab58ebd8e72f2d09af9115895b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kom=D1=8Fpa?= Date: Tue, 29 Jun 2010 13:33:00 +0300 Subject: [PATCH] fixed 1-pixel shift --- src/render.py | 4 +--- src/vtiles_backend.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/render.py b/src/render.py index 300ffec..cfafcaa 100644 --- a/src/render.py +++ b/src/render.py @@ -62,7 +62,7 @@ class RasterTile: if epsg4326: lon, lat = projections.from4326((lon,lat),self.proj) lo1, la1, lo2, la2 = self.bbox_p - return ((lon-lo1)*(self.w-1)/abs(lo2-lo1), ((la2-lat)*(self.h-1)/(la2-la1))) + return ((lon-lo1)*(self.w)/abs(lo2-lo1), ((la2-lat)*(self.h)/(la2-la1))) # return (lon - self.center_coord[0])*self.lcc*self.zoom + self.w/2, -(lat - self.center_coord[1])*self.zoom + self.h/2 def update_surface_by_center(self, lonlat, zoom, style, lock = None): self.zoom = zoom @@ -205,8 +205,6 @@ class RasterTile: if "text" in obj[1]: text = obj[1]["text"] - print obj[1].get("text-position", "cesdsdfgdfnter") - #cr.set_line_width (obj[1].get("width", 1)) cr.set_font_size(obj[1].get("font-size", 9)) if obj[1].get("text-position", "center") == "center": diff --git a/src/vtiles_backend.py b/src/vtiles_backend.py index fe39543..eef343c 100644 --- a/src/vtiles_backend.py +++ b/src/vtiles_backend.py @@ -49,7 +49,7 @@ class QuadTileBackend: self.lang = lang # map language to use self.tiles = {} # loaded vector tiles go here self.data_projection = proj # which projection used to cut map in tiles - self.keep_tiles = 90 # a number of tiles to cache in memory + self.keep_tiles = 190 # a number of tiles to cache in memory self.tile_load_log = [] # used when selecting which tile to unload def filename(self, (z,x,y)): @@ -90,13 +90,17 @@ class QuadTileBackend: a,d,c,b = [int(x) for x in projections.tile_by_bbox(bbox,zoom, self.data_projection)] resp = {} for tile in set([(zoom,i,j) for i in range(a, c+1) for j in range(b, d+1)]): - if tile not in self.tiles: - self.tiles[tile] = self.load_tile(tile) + try: + resp.update(self.tiles[tile]) + except KeyError: + ti = self.load_tile(tile) + self.tiles[tile] = ti + resp.update(ti) try: self.tile_load_log.remove(tile) except ValueError: pass self.tile_load_log.append(tile) - resp.update(self.tiles[tile]) + self.collect_garbage() return resp \ No newline at end of file