Example #1
0
def test_circle_geometries():
    """
    Test that correct geometry objects are returned and GeoDataMixin is working correctly
    """
    c_locs = [Circle(*vals) for vals in zip(lons, lats, radii, names)]
    geoms = CircleGeometries(c_locs)
    assert geoms.to_geojson() == geojson
Example #2
0
def test_circle_loc_creation():
    """
    Test that point attribute gets made correctly. Not sure whether I need to test this 
    class since it basicly just wraps up saome data...?
    """
    cl = Circle(lon=lons[0], lat=lats[0], radius=radii[0], name=names[0])
    assert cl.point_sql == "ST_GeomFromText('POINT (85.324 27.7172)',4326)::geography"
Example #3
0
def test_rastersum(get_dataframe):
    """
    Test that CircleRasterSum returns correct data 
    """
    c_locs = [Circle(84.038, 28.309, 500, "test")]
    geoms = CircleGeometries(c_locs)
    crs = geoms.raster_sum("population.small_nepal_raster")
    crs = get_dataframe(crs).set_index("name")

    assert crs.loc["test"]["statistic"] == 4610.0
Example #4
0
def test_rastersum(get_dataframe):
    """
    Test that CircleRasterSum returns correct data 
    """
    c_locs = [Circle(*vals) for vals in zip(lons, lats, radii, names)]
    geoms = CircleGeometries(c_locs)
    crs = geoms.raster_sum("population.worldpop_2015_un")
    crs = get_dataframe(crs).set_index("name")

    assert crs.loc["Kathmandu"]["statistic"] == 1_135_396.204_037_67
    assert crs.loc["Pokhara"]["statistic"] == 405_240.399_796_441_02
Example #5
0
def test_circle_string_rep():
    """Test that Circle objects have correct string representation."""
    lon, lat, radius, name = 2, 3, 4, "bob"
    cl = Circle(lon, lat, radius, name)
    assert f"Circle(lon={lon},lat={lat},radius={radius},name={name})" == str(
        cl)
Example #6
0
def test_circle_column_names():
    """Test that CircleGeometries has correct column_names property"""
    cl = Circle(2, 3, 4, "bob")
    c = CircleGeometries([cl])
    assert c.head(0).columns.tolist() == c.column_names