Exemplo n.º 1
0
def test_prepare_geocode_result_when_result_is(geocode_result):

    result = {0: geocode_result}
    expected_output = GeoDataFrame(
        {"geometry": [Point()], "address": [None]},
        crs="EPSG:4326",
    )

    output = _prepare_geocode_result(result)

    assert_geodataframe_equal(output, expected_output)
Exemplo n.º 2
0
def test_prepare_result_none():
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    d = {"a": ("address0", p0.coords[0]), "b": (None, None)}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert df.crs == "EPSG:4326"
    assert len(df) == 2
    assert "address" in df

    row = df.loc["b"]
    assert len(row["geometry"].coords) == 0
    assert np.isnan(row["address"])
Exemplo n.º 3
0
def test_prepare_result_none():
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    d = {'a': ('address0', p0.coords[0]), 'b': (None, None)}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert from_epsg(4326) == df.crs
    assert len(df) == 2
    assert 'address' in df

    row = df.loc['b']
    assert len(row['geometry'].coords) == 0
    assert np.isnan(row['address'])
Exemplo n.º 4
0
    def test_prepare_result_none(self):
        p0 = Point(12.3, -45.6)  # Treat these as lat/lon
        d = {'a': ('address0', p0.coords[0]), 'b': (None, None)}

        df = _prepare_geocode_result(d)
        assert type(df) is gpd.GeoDataFrame
        self.assertEqual(from_epsg(4326), df.crs)
        self.assertEqual(len(df), 2)
        self.assert_('address' in df)

        row = df.loc['b']
        self.assertEqual(len(row['geometry'].coords), 0)
        self.assert_(pd.np.isnan(row['address']))
Exemplo n.º 5
0
def test_prepare_result_none():
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    d = {'a': ('address0', p0.coords[0]),
         'b': (None, None)}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert from_epsg(4326) == df.crs
    assert len(df) == 2
    assert 'address' in df

    row = df.loc['b']
    assert len(row['geometry'].coords) == 0
    assert np.isnan(row['address'])
Exemplo n.º 6
0
    def test_prepare_result_none(self):
        p0 = Point(12.3, -45.6) # Treat these as lat/lon
        d = {'a': ('address0', p0.coords[0]),
             'b': (None, None)}

        df = _prepare_geocode_result(d)
        assert type(df) is gpd.GeoDataFrame
        self.assertEqual(from_epsg(4326), df.crs)
        self.assertEqual(len(df), 2)
        self.assert_('address' in df)

        row = df.loc['b']
        self.assertEqual(len(row['geometry'].coords), 0)
        self.assert_(pd.np.isnan(row['address']))
Exemplo n.º 7
0
def test_prepare_result_none():
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    d = {"a": ("address0", p0.coords[0]), "b": (None, None)}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert df.crs == "EPSG:4326"
    assert len(df) == 2
    assert "address" in df

    row = df.loc["b"]
    # The shapely.geometry.Point() is actually a GeometryCollection, and thus
    # gets converted to that in conversion to pygeos. When converting back
    # on access, you now get a GeometryCollection object instead of Point,
    # which has no coords
    # see https://github.com/Toblerity/Shapely/issues/742/#issuecomment-545296708
    # TODO we should probably replace this with a missing value instead of point?
    # assert len(row["geometry"].coords) == 0
    assert row["geometry"].is_empty
    assert row["address"] is None
Exemplo n.º 8
0
def test_prepare_result():
    # Calls _prepare_result with sample results from the geocoder call
    # loop
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    p1 = Point(-23.4, 56.7)
    d = {"a": ("address0", p0.coords[0]), "b": ("address1", p1.coords[0])}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert df.crs == "EPSG:4326"
    assert len(df) == 2
    assert "address" in df

    coords = df.loc["a"]["geometry"].coords[0]
    test = p0.coords[0]
    # Output from the df should be lon/lat
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])

    coords = df.loc["b"]["geometry"].coords[0]
    test = p1.coords[0]
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])
Exemplo n.º 9
0
def test_prepare_result():
    # Calls _prepare_result with sample results from the geocoder call
    # loop
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    p1 = Point(-23.4, 56.7)
    d = {'a': ('address0', p0.coords[0]), 'b': ('address1', p1.coords[0])}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert from_epsg(4326) == df.crs
    assert len(df) == 2
    assert 'address' in df

    coords = df.loc['a']['geometry'].coords[0]
    test = p0.coords[0]
    # Output from the df should be lon/lat
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])

    coords = df.loc['b']['geometry'].coords[0]
    test = p1.coords[0]
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])
Exemplo n.º 10
0
    def test_prepare_result(self):
        # Calls _prepare_result with sample results from the geocoder call
        # loop
        p0 = Point(12.3, -45.6)  # Treat these as lat/lon
        p1 = Point(-23.4, 56.7)
        d = {'a': ('address0', p0.coords[0]), 'b': ('address1', p1.coords[0])}

        df = _prepare_geocode_result(d)
        assert type(df) is gpd.GeoDataFrame
        self.assertEqual(from_epsg(4326), df.crs)
        self.assertEqual(len(df), 2)
        self.assert_('address' in df)

        coords = df.loc['a']['geometry'].coords[0]
        test = p0.coords[0]
        # Output from the df should be lon/lat
        self.assertAlmostEqual(coords[0], test[1])
        self.assertAlmostEqual(coords[1], test[0])

        coords = df.loc['b']['geometry'].coords[0]
        test = p1.coords[0]
        self.assertAlmostEqual(coords[0], test[1])
        self.assertAlmostEqual(coords[1], test[0])
Exemplo n.º 11
0
def test_prepare_result():
    # Calls _prepare_result with sample results from the geocoder call
    # loop
    p0 = Point(12.3, -45.6)  # Treat these as lat/lon
    p1 = Point(-23.4, 56.7)
    d = {'a': ('address0', p0.coords[0]),
         'b': ('address1', p1.coords[0])}

    df = _prepare_geocode_result(d)
    assert type(df) is GeoDataFrame
    assert from_epsg(4326) == df.crs
    assert len(df) == 2
    assert 'address' in df

    coords = df.loc['a']['geometry'].coords[0]
    test = p0.coords[0]
    # Output from the df should be lon/lat
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])

    coords = df.loc['b']['geometry'].coords[0]
    test = p1.coords[0]
    assert coords[0] == pytest.approx(test[1])
    assert coords[1] == pytest.approx(test[0])
Exemplo n.º 12
0
    def test_prepare_result(self):
        # Calls _prepare_result with sample results from the geocoder call
        # loop
        p0 = Point(12.3, -45.6) # Treat these as lat/lon
        p1 = Point(-23.4, 56.7)
        d = {'a': ('address0', p0.coords[0]),
             'b': ('address1', p1.coords[0])}

        df = _prepare_geocode_result(d)
        assert type(df) is gpd.GeoDataFrame
        self.assertEqual(from_epsg(4326), df.crs)
        self.assertEqual(len(df), 2)
        self.assert_('address' in df)

        coords = df.loc['a']['geometry'].coords[0]
        test = p0.coords[0]
        # Output from the df should be lon/lat
        self.assertAlmostEqual(coords[0], test[1])
        self.assertAlmostEqual(coords[1], test[0])

        coords = df.loc['b']['geometry'].coords[0]
        test = p1.coords[0]
        self.assertAlmostEqual(coords[0], test[1])
        self.assertAlmostEqual(coords[1], test[0])