def drawNodeList(self, nodes, colour): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for n in nodes: pointX = (n.longitude - self.minlon) * self.imgScaling pointY = y - (coordinate.lat2y(n.latitude) - y1) * self.imgScaling self.draw.point((pointX, pointY), colour)
def drawNodes(self, nodes, colour): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for id, n in nodes.items(): pointX = (n.longitude - self.minlon) * self.imgScaling pointY = y - (coordinate.lat2y(n.latitude) - y1) * self.imgScaling self.draw.point((pointX, pointY), colour) #pointCX = (stop.longitude - self.minlon) * self.imgScaling #pointCY = y - ((coordinate.lat2y(stop.latitude) - y1) * self.imgScaling) self.draw.text((pointX, pointY), str(id).encode('utf-8'), fill=(0,0,0,255))
def drawPath(self, path, colour): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling fromNode = 0 for pid in path: toNode = pid if fromNode == 0: fromNode = toNode else: self.drawLine(y, y1, fromNode[0], fromNode[1], toNode[0], toNode[1], self.imgScaling, colour) fromNode = toNode
def __init__(self, imageWidth, minlon, minlat, maxlon, maxlat): self.minlon = minlon self.maxlon = maxlon self.minlat = minlat self.maxlat = maxlat self.lonLength = (self.maxlon - self.minlon) self.imgScaling = (imageWidth / self.lonLength) imageHight = ((coordinate.lat2y(self.maxlat) - coordinate.lat2y(self.minlat)) * self.imgScaling) self.im = Image.new('RGBA', (imageWidth, int(imageHight)), 'white') self.draw = ImageDraw.Draw(self.im)
def __init__(self, imageWidth, minlon, minlat, maxlon, maxlat): self.minlon = minlon self.maxlon = maxlon self.minlat = minlat self.maxlat = maxlat self.lonLength = (self.maxlon - self.minlon) self.imgScaling = (imageWidth / self.lonLength) imageHight = ( (coordinate.lat2y(self.maxlat) - coordinate.lat2y(self.minlat)) * self.imgScaling) self.im = Image.new('RGBA', (imageWidth, int(imageHight)), 'white') self.draw = ImageDraw.Draw(self.im)
def drawNodes(self, nodes, colour): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for id, n in nodes.items(): pointX = (n.longitude - self.minlon) * self.imgScaling pointY = y - (coordinate.lat2y(n.latitude) - y1) * self.imgScaling self.draw.point((pointX, pointY), colour) #pointCX = (stop.longitude - self.minlon) * self.imgScaling #pointCY = y - ((coordinate.lat2y(stop.latitude) - y1) * self.imgScaling) self.draw.text((pointX, pointY), str(id).encode('utf-8'), fill=(0, 0, 0, 255))
def drawRoads(self, edges): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for fromCoord, n in edges.items(): #a = nodes[fromCoord].coordinates for toCoord, z, i, _ in n: #b = nodes[toCoord].coordinates colr = 255 - min(int(255 * (float(z) / 120)), 255) if int(z) < 31: colr = 220 self.drawLine(y, y1, fromCoord[0], fromCoord[1], toCoord[0], toCoord[1], self.imgScaling, (colr, colr, colr, 255))
def drawBusStops(self, busStops): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for stop in busStops: radius = 2 if stop.name == '': self.drawCircle(y, y1, stop.longitude, stop.latitude, radius, self.imgScaling, (110, 50, 200)) else: self.drawCircle(y, y1, stop.longitude, stop.latitude, radius, self.imgScaling, (254, 122, 85)) pointCX = (stop.longitude - self.minlon) * self.imgScaling pointCY = y - ((coordinate.lat2y(stop.latitude) - y1) * self.imgScaling) self.draw.text((pointCX, pointCY), stop.name.encode('utf-8'), fill=(0,0,0,255))
def drawBusStops(self, busStops): y1 = coordinate.lat2y(self.minlat) y2 = coordinate.lat2y(self.maxlat) y = (y2 - y1) * self.imgScaling for stop in busStops: radius = 2 if stop.name == '': self.drawCircle(y, y1, stop.longitude, stop.latitude, radius, self.imgScaling, (110, 50, 200)) else: self.drawCircle(y, y1, stop.longitude, stop.latitude, radius, self.imgScaling, (254, 122, 85)) pointCX = (stop.longitude - self.minlon) * self.imgScaling pointCY = y - ( (coordinate.lat2y(stop.latitude) - y1) * self.imgScaling) self.draw.text((pointCX, pointCY), stop.name.encode('utf-8'), fill=(0, 0, 0, 255))
def drawPoint(self, y, y1, lon, lat, scale, colour): pointPX = (lon - self.minlon) * scale pointPY = y - ((coordinate.lat2y(lat) - y1) * scale) self.draw.point((pointPX, int(pointPY)), colour)
def drawLine(self, y, y1, aLon, aLat, bLon, bLat, scale, colour): pointAX = (aLon - self.minlon) * scale pointAY = y - ((coordinate.lat2y(aLat) - y1) * scale) pointBX = (bLon - self.minlon) * scale pointBY = y - ((coordinate.lat2y(bLat) - y1) * scale) self.draw.line((pointAX, pointAY, pointBX, pointBY), colour)
def drawCircle(self, y, y1, lon, lat, r, scale, colour): pointCX = (lon - self.minlon) * scale pointCY = y - ((coordinate.lat2y(lat) - y1) * scale) self.draw.ellipse((pointCX - r, pointCY - r, pointCX + r, pointCY + r), fill=colour)