piste
changeset 17:fe803a3c8059
Lines with changing opacity
| author | Michael Neuling <mikey@neuling.org> |
|---|---|
| date | Mon, 14 Apr 2008 22:58:25 +0200 |
| parents | 599bb51aea9c |
| children | 0e64865fb61a |
| files | now.cgi now.tmpl |
| diffstat | 2 files changed, 25 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/now.cgi Mon Apr 14 22:34:53 2008 +0200 1.2 +++ b/now.cgi Mon Apr 14 22:58:25 2008 +0200 1.3 @@ -14,10 +14,27 @@ 1.4 centre = { 'maxlat' : -200, 'minlat' : 200, 'maxlon' : -200, 1.5 'minlon' : 200, 'lon' : 0, 'lat' : 0 } 1.6 1.7 +TIME=3600 1.8 +now=time.time() 1.9 + 1.10 m = [g.points[0]] 1.11 -p = g.lastin(3600) 1.12 +p = g.lastin(TIME) 1.13 +line = {} 1.14 +l = [] 1.15 if not p: 1.16 p = [g.points[0]] 1.17 +else: 1.18 + last = g.points[0] 1.19 + for i in p: 1.20 + line = {} 1.21 + line['lat0'] = last['lat'] 1.22 + line['lon0'] = last['lon'] 1.23 + line['lat1'] = i['lat'] 1.24 + line['lon1'] = i['lon'] 1.25 + line['opacity'] = (1 - (now-last['time'])/TIME) 1.26 + l.append(line) 1.27 + last = i 1.28 + 1.29 1.30 for i in p: 1.31 if centre['maxlat'] < i['lat']: 1.32 @@ -31,7 +48,7 @@ 1.33 centre['lat'] = (centre['maxlat'] + centre['minlat'])/2 1.34 centre['lon'] = (centre['maxlon'] + centre['minlon'])/2 1.35 1.36 -processor.set('Points', p) 1.37 +processor.set('Lines', l) 1.38 processor.set('Markers', m) 1.39 processor.set('Centre', [centre]) 1.40
2.1 --- a/now.tmpl Mon Apr 14 22:34:53 2008 +0200 2.2 +++ b/now.tmpl Mon Apr 14 22:58:25 2008 +0200 2.3 @@ -19,11 +19,14 @@ 2.4 map.addControl(new GOverviewMapControl()); 2.5 var point; 2.6 var points = []; 2.7 - <TMPL_LOOP Points> 2.8 - point = new GPoint(<TMPL_VAR lon ESCAPE="NONE">, <TMPL_VAR lat ESCAPE="NONE">); 2.9 + <TMPL_LOOP Lines> 2.10 + point = new GPoint(<TMPL_VAR lon0 ESCAPE="NONE">, <TMPL_VAR lat0 ESCAPE="NONE">); 2.11 points.push(point); 2.12 + point = new GPoint(<TMPL_VAR lon1 ESCAPE="NONE">, <TMPL_VAR lat1 ESCAPE="NONE">); 2.13 + points.push(point); 2.14 + map.addOverlay(new GPolyline(points, "#0000FF", 4, <TMPL_VAR opacity ESCAPE="NONE">)); 2.15 + points.length = 0; 2.16 </TMPL_LOOP> 2.17 - map.addOverlay(new GPolyline(points, "#0000FF", 4, 1)); 2.18 <TMPL_LOOP Centre> 2.19 map.setCenter(new GLatLng(<TMPL_VAR lat ESCAPE="NONE">, <TMPL_VAR lon ESCAPE="NONE">), 13); 2.20 map.setZoom(map.getBoundsZoomLevel(
