3 import Image, ImageDraw
5 def circle (image, percentX, percentY, radiusX, radiusY, colorIn, colorOut):
7 imageX, imageY = image.size
8 centerX = int(imageX*percentX)
9 centerY = int(imageY*percentY)
10 x = max (0, min (centerX,imageX))
11 y = max (0, min (centerY,imageY))
18 draw = ImageDraw.Draw (image)
19 draw.chord((x1,y1,x2,y2), 0, 360, fill=colorIn, outline=colorOut )
24 longitude={'left':-11.,
27 def render_site (site, image, sx, sy, cIn, cOut):
28 if site['longitude'] is not None and site['latitude'] is not None:
29 px=float(longitude['left']-site['longitude'])/float(longitude['left']-longitude['right'])
30 py=float(latitude['top']-site['latitude'])/float(latitude['top']-latitude['bottom'])
31 if (px<0 or py<0 or px>1 or py>1):
34 circle(image,px,py,sx,sy,cIn,cOut)
39 path = '/var/www/html/'
40 original = path + 'map.png'
41 live = path + 'livemap.png'
43 # map characteristics, in degrees.
44 # latitude : positive is north
45 # longitude : positive is east
47 # circle radius in pixels
49 # circle in and out colors
50 cInLocal , cOutLocal = '#566b8a','#bbbbbb'
52 # same for federating / foreign sites
53 sxForeign,syForeign=6,6
54 cInForeign , cOutForeign = '#acb3a4', '#444444'
56 image = Image.open(original)
58 for site in GetSites({'~peer_id':None}):
59 render_site (site, image, sxForeign, syForeign, cInForeign , cOutForeign)
60 # local sites go last to be more visible
61 for site in GetSites({'peer_id':None}):
62 render_site (site, image, sxLocal, syLocal, cInLocal , cOutLocal)
66 if __name__ == '__main__':