Add GeoJSON vector data support, STAC layer support, and comprehensive tests#46
Merged
Conversation
…e tests - Add add_geojson() method to MapLibre Map class (addresses #4) - Supports GeoJSON dict, file path, URL, and GeoDataFrame input - Auto-detects geometry types and creates appropriate layers - Auto-fits map bounds to the data extent - Supports custom paint/layout properties, clustering options - Creates multiple filtered layers for mixed-geometry FeatureCollections - Add add_stac_layer() method for STAC item support (addresses #3) - Fetches STAC item JSON from URL, extracts asset COG href - Leverages existing COG protocol for raster rendering - Auto-fits map to STAC item's bounding box - Add corresponding JavaScript handlers (addGeoJSON, addStacLayer) - JS-side URL fetching for remote GeoJSON with auto-bounds - JS-side STAC item fetching with asset extraction - Helper for computing GeoJSON bounds on the JS side - Rewrite test suite with 33 comprehensive tests covering: - MapLibre Map initialization and basic methods - GeoJSON loading from dict, file, URL with various options - Bounds computation and geometry type detection - COG and STAC layer methods - Error handling for unsupported types and missing files
for more information, see https://pre-commit.ci
|
🚀 Deployed on https://697e196572d00e1245786360--opengeos.netlify.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds GeoJSON vector data loading support (issue #4), STAC raster layer support (issue #3), and rewrites the test suite from scratch.
GeoJSON Support (closes #4 — partial: GeoJSON for MapLibre)
Added
add_geojson()method to the MapLibreMapclass with the following features:Input formats supported:
.geojson,.json)fetch())__geo_interface__(e.g., GeoPandas GeoDataFrame)Capabilities:
circle,line,fill)fit_bounds=False)paint,layout,source_options(e.g., clustering),before_idExample usage:
STAC Layer Support (addresses #3)
Added
add_stac_layer()method that:"visual")maplibre-cog-protocolExample usage:
Test Suite
Rewrote
tests/test_mapwidget.pyfrom a single placeholder test to 33 comprehensive tests covering:TestMapLibreMap— initialization,add_call, navigation methods, source/layer/control managementTestAddGeoJSON— dict, file, URL, custom IDs, custom paint, error handling (TypeError, FileNotFoundError)TestComputeBounds— points, polygons, FeatureCollections, empty data, URL passthroughTestGetGeometryTypes— single type, mixed types, URL passthroughTestAddCogLayer— default and custom IDsTestAddStacLayer— default and custom IDsAll 33 tests pass.
Files Changed
mapwidget/maplibre.py— Addedadd_geojson(),add_stac_layer(), and helper methodsmapwidget/js/maplibre.js— AddedaddGeoJSONToMap(),addStacLayer(),computeGeoJSONBounds()JS handlerstests/test_mapwidget.py— Complete rewrite with 33 testsRefs: #3, #4