Skip to content

Commit

Permalink
Add test for SimpleFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Jul 21, 2024
1 parent a1a080d commit 219151f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions maplibre/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/test_sources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from geopandas import GeoDataFrame, read_file
from maplibre.sources import *


Expand Down Expand Up @@ -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

0 comments on commit 219151f

Please sign in to comment.