added 404 tile

git-svn-id: http://www.neo1973-germany.de/svn@11 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
josch 2008-03-02 22:00:30 +00:00
parent 56f46db575
commit 83b1a9a2f6
2 changed files with 23 additions and 13 deletions

BIN
pylgrim/404.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -44,7 +44,8 @@ class TestView(edje.Edje):
def download(self, x,y,z): def download(self, x,y,z):
import urllib import urllib
webFile = urllib.urlopen("http://a.tile.openstreetmap.org/%d/%d/%d.png"%(z,x,y)) try:
webFile = urllib.urlopen("http://a.tile.openstrzzeetmap.org/%d/%d/%d.png"%(z,x,y))
if not os.path.exists("%d"%z): if not os.path.exists("%d"%z):
os.mkdir("%d"%z) os.mkdir("%d"%z)
if not os.path.exists("%d/%d"%(z,x)): if not os.path.exists("%d/%d"%(z,x)):
@ -53,7 +54,8 @@ class TestView(edje.Edje):
localFile.write(webFile.read()) localFile.write(webFile.read())
webFile.close() webFile.close()
localFile.close() localFile.close()
except Exception, e:
print e
def __init__(self): def __init__(self):
self.options, self.args = myOptionParser(usage="usage: %prog [options]").parse_args() self.options, self.args = myOptionParser(usage="usage: %prog [options]").parse_args()
@ -167,6 +169,10 @@ class TestView(edje.Edje):
#if all tiles are downloaded #if all tiles are downloaded
for i in xrange(2*self.border+1): for i in xrange(2*self.border+1):
for j in xrange(2*self.border+1): for j in xrange(2*self.border+1):
#if some errors occurd replace with placeholder
if not os.path.exists("%d/%d/%d.png"%(self.z,self.x+i-self.border,self.y+j-self.border)):
self.icons[(2*self.border+1)*i+j].file_set("404.png")
else:
self.icons[(2*self.border+1)*i+j].file_set("%d/%d/%d.png"%(self.z,self.x+i-self.border,self.y+j-self.border)) self.icons[(2*self.border+1)*i+j].file_set("%d/%d/%d.png"%(self.z,self.x+i-self.border,self.y+j-self.border))
self.icons[(2*self.border+1)*i+j].set_position((i-self.border)*256+self.size[0]/2-self.offset_x,(j-self.border)*256+self.size[1]/2-self.offset_y) self.icons[(2*self.border+1)*i+j].set_position((i-self.border)*256+self.size[0]/2-self.offset_x,(j-self.border)*256+self.size[1]/2-self.offset_y)
self.icons[(2*self.border+1)*i+j].size = 256,256 self.icons[(2*self.border+1)*i+j].size = 256,256
@ -203,6 +209,7 @@ class TestView(edje.Edje):
def animate_zoom_in(self): def animate_zoom_in(self):
if self.z < 18: if self.z < 18:
self.animate = True
if self.zoom_step < 1.0: if self.zoom_step < 1.0:
self.zoom_in(self.zoom_step) self.zoom_in(self.zoom_step)
self.zoom_step+=0.125 self.zoom_step+=0.125
@ -211,10 +218,13 @@ class TestView(edje.Edje):
self.zoom_step = 0.0 self.zoom_step = 0.0
self.z+=1 self.z+=1
self.set_current_tile(self.lat, self.lon, self.z) self.set_current_tile(self.lat, self.lon, self.z)
else:
self.animate = False
return False return False
def animate_zoom_out(self): def animate_zoom_out(self):
if self.z > 5: if self.z > 5:
self.animate = True
if self.zoom_step < 1.0: if self.zoom_step < 1.0:
self.zoom_out(self.zoom_step) self.zoom_out(self.zoom_step)
self.zoom_step+=0.125 self.zoom_step+=0.125
@ -223,16 +233,16 @@ class TestView(edje.Edje):
self.zoom_step = 0.0 self.zoom_step = 0.0
self.z-=1 self.z-=1
self.set_current_tile(self.lat, self.lon, self.z) self.set_current_tile(self.lat, self.lon, self.z)
else:
self.animate = False
return False return False
@edje.decorators.signal_callback("mouse,down,1", "*") @edje.decorators.signal_callback("mouse,down,1", "*")
def on_mouse_down(self, emission, source): def on_mouse_down(self, emission, source):
if not self.animate: if not self.animate:
if source in "plus": if source in "plus":
self.animate = True
ecore.timer_add(0.05, self.animate_zoom_in) ecore.timer_add(0.05, self.animate_zoom_in)
if source in "minus": if source in "minus":
self.animate = True
ecore.timer_add(0.05, self.animate_zoom_out) ecore.timer_add(0.05, self.animate_zoom_out)
else: else:
self.x_pos, self.y_pos = self.evas_canvas.evas_obj.evas.pointer_canvas_xy self.x_pos, self.y_pos = self.evas_canvas.evas_obj.evas.pointer_canvas_xy