Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FlatGeobuf element #210

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

spwoodcock
Copy link

Issue

  • Currently there is no way to load FlatGeobuf data in this library.
  • It's pretty easy to load a FlatGeobuf using the official lib, deserialize to GeoJSON, then pass through to our GeoJSON component.

Solution

  • Made a FlatGeobuf component that essentially wraps GeoJSON.
  • It has a bit of additional logic there for:
    • Taking a bounding box array and only fetching the data within the BBOX (using RANGE requests). extent={bbox}
    • If a polygon GeoJSON is passed instead, then the BBOX is calculated for fetching data, and the final dataset is trimmed to the extent of the polygon. extent={polygonGeojson}
      • Of course, having a dynamic bbox is possible, via events such as clicking on bounding map geometries. I have tested this and it works nicely.
    • A extractGeomCols prop, when set to true will extract the first geometry from within a GeometryCollection. This is a bit of a hack required so that properties can be extracted alongside the geometry when working with PostGIS.
    • Accepts a function for prop metadataFunc={funcHere} to handle flatgeobuf metadata on fetch.
  • Child components can be passed through via a slot, to allow for styling in the same way as the GeoJSON component.
  • Also takes a few additional props used by the GeoJSON component that are passed directly through.

Note

This component uses Svelte 5 syntax, with the PR anticipating the merge of #197

I had some issues with the rendering orders that are hopefully fixed by the functions I used from context and source logic.
Please let me know if I should change anything here!

Screenshot

image

Copy link

changeset-bot bot commented Nov 6, 2024

🦋 Changeset detected

Latest commit: 24337a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte-maplibre Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 6, 2024

@spwoodcock is attempting to deploy a commit to the Daniel Imfeld's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Owner

@dimfeld dimfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Just FYI since this requires runes it's going to be a bit before this merges though.

The existing PR that you referenced only updates the docs site to use Svelte 5. I'm going to do a release at some point that is a breaking change to make this package only work with Svelte 5, but that's going to require an effort to at least update the slots/snippets and events handling to work with Svelte 5

I don't have a lot of time to work on that right now, but hope to create a next branch later this month to start the work, and I can merge this one into that branch when I do.

src/lib/FlatGeobuf.svelte Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this one

@dimfeld
Copy link
Owner

dimfeld commented Nov 9, 2024

The next branch now exists, so if you want to rebase this on to that branch I'm happy to merge it in there.

@spwoodcock
Copy link
Author

Nice! Happy to keep contributing to this lib 😄

Svelte 5 is fully backward compatible with Svelte 4 syntax, so the upgrade could still be done without migrating all the syntax. Of course this would be a breaking major version increment.

The upgrade should be done over time, but it could be gradual and community supported if time is limited 👍

I currently use this lib in a Svelte 5 project without issues

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.

2 participants