Exemplo n.º 1
0
def calculate_census_block(address):
    '''
    Calculates the census block of a given address
    '''
    coords = cbt.addr_to_coords(ADDRESS_URL, address)
    rv = cbt.visit_pages(URL, coords)
    return coords, rv
Exemplo n.º 2
0
def find_building(building_dict, address, building_type, building_subtype):
    """
    LEGACY CODE -- Not used in final project. Some complications 
    emerged since it was difficult to find a single building using
    the above search. This code is incomplete.

    Given an address, building type, and building subtype,
    the appropriate row from the City of Chicago data is selected.
    """

    coords = coords_to_block.addr_to_coords(coords_to_block.address_url, address)   
    census_block = coords_to_block.visit_pages(coords_to_block.url,coords)

    matches = building_dict[str(census_block)]

    for match in matches:
        print(match)

        for key in match.keys():
            print(key)
            print(key == building_type)
            if key == building_type:
                value = match[key]
                print(value) 
                for key2 in value.keys():
                    if key2 == building_subtype:
                        ans = match[building_type][building_subtype]
                    else:
                        break

    return ans