This commit is contained in:
2025-01-26 19:24:23 -08:00
parent 32cd60e92b
commit d1dde0dbc6
4155 changed files with 29170 additions and 216373 deletions

View File

@@ -3,13 +3,14 @@ import pandas as pd
from shapely.geometry import Point
from geopandas import GeoDataFrame, GeoSeries
from geopandas._compat import HAS_PYPROJ
from geopandas.tools import geocode, reverse_geocode
from geopandas.tools.geocoding import _prepare_geocode_result
import pytest
from geopandas.testing import assert_geodataframe_equal
from geopandas.tests.util import assert_geoseries_equal, mock
from pandas.testing import assert_series_equal
from geopandas.testing import assert_geodataframe_equal
import pytest
geopy = pytest.importorskip("geopy")
@@ -71,7 +72,8 @@ def test_prepare_result():
df = _prepare_geocode_result(d)
assert type(df) is GeoDataFrame
assert df.crs == "EPSG:4326"
if HAS_PYPROJ:
assert df.crs == "EPSG:4326"
assert len(df) == 2
assert "address" in df
@@ -93,18 +95,15 @@ def test_prepare_result_none():
df = _prepare_geocode_result(d)
assert type(df) is GeoDataFrame
assert df.crs == "EPSG:4326"
if HAS_PYPROJ:
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 len(row["geometry"].coords) == 0
assert row["geometry"].is_empty
assert row["address"] is None