draw.chord((x1,y1,x2,y2), 0, 360, fill=colorIn, outline=colorOut )
del draw
+latitude={'top':65.,
+ 'bottom': 35.5}
+longitude={'left':-11.,
+ 'right':58.}
+
+def render_site (site, image, sx, sy, cIn, cOut):
+ if site['longitude'] is not None and site['latitude'] is not None:
+ px=float(longitude['left']-site['longitude'])/float(longitude['left']-longitude['right'])
+ py=float(latitude['top']-site['latitude'])/float(latitude['top']-latitude['bottom'])
+ if (px<0 or py<0 or px>1 or py>1):
+ return
+
+ circle(image,px,py,sx,sy,cIn,cOut)
+
+
def main ():
path = '/var/www/html/'
# map characteristics, in degrees.
# latitude : positive is north
# longitude : positive is east
- latitude={'top':65.,
- 'bottom': 35.5}
- longitude={'left':-11.,
- 'right':58.}
-
+
# circle radius in pixels
- sx,sy=6,6
+ sxLocal,syLocal=7,7
# circle in and out colors
- cIn,cOut='#566b8a','#bbbbbb'
+ cInLocal , cOutLocal = '#566b8a','#bbbbbb'
+
+ # same for federating / foreign sites
+ sxForeign,syForeign=6,6
+ cInForeign , cOutForeign = '#acb3a4', '#444444'
image = Image.open(original)
- for site in GetSites():
- if site['longitude'] is not None and site['latitude'] is not None:
- px=float(longitude['left']-site['longitude'])/float(longitude['left']-longitude['right'])
- py=float(latitude['top']-site['latitude'])/float(latitude['top']-latitude['bottom'])
- if (px==0 or py==0 or px==1 or py==1)
- continue
+ for site in GetSites({'~peer_id':None}):
+ render_site (site, image, sxForeign, syForeign, cInForeign , cOutForeign)
+ # local sites go last to be more visible
+ for site in GetSites({'peer_id':None}):
+ render_site (site, image, sxLocal, syLocal, cInLocal , cOutLocal)
- circle(image,px,py,sx,sy,cIn,cOut)
-
image.save (live)
if __name__ == '__main__':