Skip to content

geojson: add generic property support to features and collections#176

Merged
paulmach merged 1 commit intomasterfrom
pm/generic-geojson
Mar 30, 2026
Merged

geojson: add generic property support to features and collections#176
paulmach merged 1 commit intomasterfrom
pm/generic-geojson

Conversation

@paulmach
Copy link
Copy Markdown
Owner

@paulmach paulmach commented Mar 27, 2026

This change adds generic variants of GeoJSON features and feature collections so callers can use typed property structs instead of the default map[string]interface{}.

It introduces FeatureOf[P] and FeatureCollectionOf[P].

This preserves all existing behavior

AI summary below.

What Changed

  • Added FeatureOf[P] and FeatureCollectionOf[P]
  • Kept Feature and FeatureCollection as aliases for backward compatibility
  • Updated JSON/BSON marshal and unmarshal logic to work with generic property types
  • Added tests covering generic JSON and BSON round-trips
  • Documented typed property usage in README.md and geojson/README.md

Why

  • Lets consumers deserialize GeoJSON into strongly typed property structs
  • Avoids repeated manual casting from map[string]interface{}
  • Preserves the existing default behavior for users who do not need typed properties

Tests

  • Added feature JSON round-trip coverage for typed properties
  • Added feature BSON round-trip coverage for typed properties
  • Added feature collection JSON round-trip coverage for typed properties

@paulmach paulmach force-pushed the pm/generic-geojson branch from d1e6cd7 to e76ee9d Compare March 30, 2026 05:33
@paulmach paulmach merged commit 9610ef0 into master Mar 30, 2026
2 checks passed
@paulmach paulmach deleted the pm/generic-geojson branch March 30, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant