diff --git a/maplibre/sources.py b/maplibre/sources.py index adc0c9a2..3ab3b3f8 100644 --- a/maplibre/sources.py +++ b/maplibre/sources.py @@ -146,6 +146,10 @@ def __init__(self, data: GeoDataFrame | str, source_id: str = None): self._data = data self._source_id = source_id or str(uuid4()) + @property + def crs(self): + return self._data.crs + @property def bounds(self) -> tuple: return self._data.total_bounds diff --git a/tests/test_sources.py b/tests/test_sources.py index 838bd7cc..2b1d72ee 100644 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -1,5 +1,6 @@ from __future__ import annotations +from geopandas import GeoDataFrame, read_file from maplibre.sources import * @@ -43,3 +44,16 @@ def test_vector_tile_source(): "tiles": tiles, "type": "vector", } + + +def test_simple_features(): + # Prepare + path = "https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_admin_1_states_provinces_shp.geojson" + + # Act + sf = SimpleFeatures(path) + + # Assert + assert isinstance(sf.to_source(), GeoJSONSource) + assert sf.crs == "EPSG:4326" + assert len(sf.bounds) == 4