def createStyleMap(): print "Drawing user rating maps of beers with a style of " + str(args.styleMap) dataPoints = files.readDataPoints() if len(dataPoints) > 0: style = args.styleMap points = [] for point in dataPoints: if style in point.style: points.append(point) print str(len(points)) + " points of data" PBAMap.drawMap(points, style) else: print "No data points found"
def createStyleMap(): print "Drawing user rating maps of beers with a style of " + str( args.styleMap) dataPoints = files.readDataPoints() if len(dataPoints) > 0: style = args.styleMap points = [] for point in dataPoints: if style in point.style: points.append(point) print str(len(points)) + " points of data" PBAMap.drawMap(points, style) else: print "No data points found"
def createABVMap(): """Make a color map of specific alcohol by volume.""" print "Drawing user rating maps of beers with an alcohol concentration of " + str(args.abvMap) + '%' dataPoints = files.readDataPoints() if len(dataPoints) > 0: abv = int(args.abvMap) points = [] for point in dataPoints: if int(point.abv) == abv: points.append(point) elif (abv in [1, 2, 3]) and (int(point.abv) in [1, 2, 3]): points.append(point) elif (abv > 11 and int(point.abv) > 11): points.append(point) print str(len(points)) + " points of data" PBAMap.drawMap(points, abv) else: print "No data points found"
def createABVMap(): """Make a color map of specific alcohol by volume.""" print "Drawing user rating maps of beers with an alcohol concentration of " + str( args.abvMap) + '%' dataPoints = files.readDataPoints() if len(dataPoints) > 0: abv = int(args.abvMap) points = [] for point in dataPoints: if int(point.abv) == abv: points.append(point) elif (abv in [1, 2, 3]) and (int(point.abv) in [1, 2, 3]): points.append(point) elif (abv > 11 and int(point.abv) > 11): points.append(point) print str(len(points)) + " points of data" PBAMap.drawMap(points, abv) else: print "No data points found"
def normalizeUsers(): """ Change the user ids so the information can be made public and use the googlemaps module to determine the user's location. """ usersList = files.readUsers() newUsersList = {} i = 1 newUid = 1 for hashId, user in usersList.iteritems(): uid = user.uid user.uid = str(newUid) location = user.location if location['name'] != "" and 'lat' not in location: if isinstance(location['name'], unicode): location = location['name'].encode('utf-8') else: location = location['name'] mapInfo = PBAMap.getLatLong(location, i) i += 1 if mapInfo == 'apiLimit': print str( i ) + " At daily API limit. Update script and repeat tomorrow" elif mapInfo != '': user.location = { 'name': location, 'lat': mapInfo['lat'], 'lng': mapInfo['lng'], } if 'country' in mapInfo: user.location['country'] = mapInfo['country'] print str(i), user.location else: print str(i), "checked: none" user.location = {'name': ''} newUid += 1 newUsersList[hash(str(uid))] = user writeJSONFile('../data/users.json', newUsersList) print "User ids, usernames, and locations updated\n"
def normalizeUsers(): """ Change the user ids so the information can be made public and use the googlemaps module to determine the user's location. """ usersList = files.readUsers() newUsersList = {} i = 1 newUid = 1 for hashId, user in usersList.iteritems(): uid = user.uid user.uid = str(newUid) location = user.location if location['name'] != "" and 'lat' not in location: if isinstance(location['name'], unicode): location = location['name'].encode('utf-8') else: location = location['name'] mapInfo = PBAMap.getLatLong(location, i) i += 1 if mapInfo == 'apiLimit': print str(i) + " At daily API limit. Update script and repeat tomorrow" elif mapInfo != '': user.location = { 'name': location, 'lat': mapInfo['lat'], 'lng': mapInfo['lng'], } if 'country' in mapInfo: user.location['country'] = mapInfo['country'] print str(i), user.location else: print str(i), "checked: none" user.location = {'name': ''} newUid += 1 newUsersList[hash(str(uid))] = user writeJSONFile('../data/users.json', newUsersList) print "User ids, usernames, and locations updated\n"