def compareTeams(team, data):
    starters = getStarters(data[team]["players"])
    hometowns = list(map(lambda x: x["hometown"], starters))

    geolocator = Nominatim(user_agent="CBBScraping")
    school = geolocator.geocode(searchfor(team), addressdetails=True, timeout=10)
    if school.raw["address"]["country_code"] != "us":
        print(school)
    locs = list(map(lambda x: geolocator.geocode(x, timeout=10), hometowns))
    avgLat = (
        reduce(
            lambda x, y: x + y,
            list(map(lambda x: x.latitude if x != None else 39.86, locs)),
        )
        / 5
    )
    avgLon = (
        reduce(
            lambda x, y: x + y,
            list(map(lambda x: x.longitude if x != None else -98.6, locs)),
        )
        / 5
    )
    avgLocation = (avgLat, avgLon)
    schoolLocation = (school.latitude, school.longitude)

    score = distance.distance(avgLocation, schoolLocation).miles
    return score
Exemple #2
0
def compareTeams(team, data):
    site = "Canada?"
    starters = getStarters(data[team]["players"])

    geolocator = Nominatim(user_agent="CBBScraping")
    school = geolocator.geocode(searchfor(team), addressdetails=True, timeout=10)
    if school.raw["address"]["country_code"] != "us":
        print(school)
    site_loc = geolocator.geocode(site, addressdetails=True, timeout=10)
    schoolLocation = (school.latitude, school.longitude)
    site_coords = (site_loc.latitude, site_loc.longitude)
    score = distance.distance(site_coords, schoolLocation).miles
    return score
Exemple #3
0
def compareTeams(team, data):
    starters = getStarters(data[team]["players"])
    weights = list(map(lambda x: x["weight"], starters))
    score = mean(weights)
    return score