def test_positional_regions(): df = geodata.regions_city(request=['york', 'york'], within=[ geodata.regions_state(['New York']), geodata.regions_state(['Illinois']), ]).to_data_frame() assert ['New York City', 'Little York'] == df['found name'].tolist()
def test_name_columns(geometry_getter): request = 'boston' found_name = 'Boston' boston = geodata.regions_city(request) assert_row(boston.to_data_frame(), request=request, found_name=found_name) assert_row(geometry_getter(boston), request=request, found_name=found_name)
def test_case(): usa = geodata.regions_country(request=['usa']) states_48 = geodata.regions_state(['us-48']) states_list = ['NY', 'TX', 'louisiana'] states = geodata.regions_state(request=states_list, within=usa) cities_list = ['New york', 'boston', 'la'] t_cities = geodata.regions_city(request=cities_list, within=usa)
def test_ambiguity_near_boston_by_name(): r = geodata.regions_builder( level='city', request='Warwick' ) \ .where('Warwick', near=geodata.regions_city('boston')) \ .build() assert_row(r.to_data_frame(), id=WARWICK_ID, found_name='Warwick') assert_row(r.centroids(), lon=WARWICK_LON, lat=WARWICK_LAT)
def test_rows_order(): city_names = [ 'Boston', 'Phoenix', 'Tucson', 'Salt Lake City', 'Los Angeles', 'San Francisco' ] city_regions = geodata.regions_city(city_names, within='US') # create path preserving the order df = city_regions.centroids() df = df.set_index('request') df = df.reindex(city_names)
def test_ambiguity_near_boston_by_box(): boston = geodata.regions_city('boston').centroids().iloc[[0]] buffer = 0.6 boston_centroid = ShapelyPoint(boston.geometry.x, boston.geometry.y) r = geodata.regions_builder( level='city', request='Warwick' ) \ .where('Warwick', within=shapely.geometry.box( boston_centroid.x - buffer, boston_centroid.y - buffer, boston_centroid.x + buffer, boston_centroid.y + buffer )) \ .build() assert_row(r.to_data_frame(), id=WARWICK_ID, found_name='Warwick') assert_row(r.centroids(), lon=WARWICK_LON, lat=WARWICK_LAT)
def test_empty_request_centroid(): r = geodata.regions_city(within='orange county') df = r.centroids() assert set(['Chapel Hill', 'Town of Carrboro', 'Carrboro', 'Hillsborough', 'Town of Carrboro', 'City of Durham']) == \ set(df['request'].tolist())