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 geoJSON source and layer #30

Merged
merged 22 commits into from
Jul 11, 2024
Merged

Add geoJSON source and layer #30

merged 22 commits into from
Jul 11, 2024

Conversation

brichet
Copy link
Collaborator

@brichet brichet commented Jul 3, 2024

This PR will add geoJSON sources and vector layers.

Peek 2024-07-09 12-33

  • Add a geoJSON file path as a source
  • Validate the geoJSON format before adding the source
  • Create a vector layer from the source (filled polygon and coordinate points for start)
  • Tests

Discussion:

Do we want to save the data in the shared document ?

Currently the file path is saved as a source in the shared document, and the data are read when creating the source in the map tool.
The main advantage of saving the data is to be more easily reactive to changes in the data (no need to manually reload the file).
The main drawback is probably the size of the shared document if several geoJSON data are used. Also other kind of data (not geoJSON) might need a parser to be correctly included in the shared document. To avoid this, we could add some kind of "listener" on data file, and update the source in the map tool automatically.

Follow up

  • add more options depending of the vector type (line width, circle radius...)
  • add more vector types

Copy link
Contributor

github-actions bot commented Jul 3, 2024

Binder 👈 Launch a Binder on branch brichet/jupytergis/geoJSON

@martinRenou
Copy link
Member

martinRenou commented Jul 3, 2024

Do we want to save the data in the shared document ?

I believe we'll have two cases:

  • the geojson is backed by an external file
  • the geojson is included in our jgis file

In the first case, your approach is good I think. We can also provide the ability to embed the JSON into our file, but we should probably not do it by default.

The second case will appear if the user tries to add a geojson from the Python API in the notebook, something like:

# in-memory JSON creation
geojson = {"features": [...]}

jgis_document.add_json_source(geojson)

@brichet brichet added the enhancement New feature or request label Jul 4, 2024
@brichet brichet force-pushed the geoJSON branch 2 times, most recently from f4c7c2b to b65a34e Compare July 8, 2024 20:11
@brichet
Copy link
Collaborator Author

brichet commented Jul 9, 2024

This PR also updates the toolbar to display some categories.
It can be removed if it overloads the toolbar.

@brichet brichet marked this pull request as ready for review July 9, 2024 10:38
@brichet brichet requested a review from martinRenou July 9, 2024 10:38
@martinRenou
Copy link
Member

Looks great! I will give a review.

Just a comment from your screencast, it seems you could use "ui:widget": "color" in the UI Schema to use a color picker widget for the fill color

packages/base/src/formdialog.tsx Outdated Show resolved Hide resolved
packages/base/src/formdialog.tsx Show resolved Hide resolved
@martinRenou
Copy link
Member

I think it looks great as-is. My comments can be resolved in follow-up PRs.

@martinRenou
Copy link
Member

It can be removed if it overloads the toolbar.

I feel like it overloads the toolbar indeed. Also, from a UX point of view it would feel better to create the source and the layer at the same time in one click, similar to what we've done for custom raster sources.

Copy link
Member

Choose a reason for hiding this comment

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

ezgif-3-3aca4e2c99.mp4

@martinRenou
Copy link
Member

I can help with the conflicts if needed

@brichet
Copy link
Collaborator Author

brichet commented Jul 10, 2024

@martinRenou I added commits to use only one form to create both the GeoJSON source and the vector layer.

@martinRenou
Copy link
Member

I preferred the GeoJSON icon you had here:

Screenshot from 2024-07-11 09-49-34

As your button is only for creating a vector layer out of a GeoJSON file/data.

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Let's merge and iterate! Thanks a lot

@martinRenou martinRenou merged commit ca09715 into geojupyter:main Jul 11, 2024
8 of 9 checks passed
@brichet
Copy link
Collaborator Author

brichet commented Jul 11, 2024

I preferred the GeoJSON icon you had here:

Screenshot from 2024-07-11 09-49-34

As your button is only for creating a vector layer out of a GeoJSON file/data.

Currently it only supports geoJSON, but maybe we'll be able to handle several data types source with the same form/button.

@brichet brichet deleted the geoJSON branch July 11, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants