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

Draw on Cesium map feature #2204

Merged
merged 25 commits into from
Nov 2, 2023
Merged

Draw on Cesium map feature #2204

merged 25 commits into from
Nov 2, 2023

Conversation

robyngit
Copy link
Member

This PR introduces the feature that allows a user to draw an arbitrary polygon on a map. While we don't yet have anything set up to use this custom polygon, the "save" button has the ability to send the coordinates a callback function. This will support us in developing upcoming features: 1) allow users to download a subset of geospatial data, and 2) allow users to plot a subset of the data.

In making these changes, I also did a little refactoring of some of the related models and collections to make them more modular & reusable.

- Create the initial DrawTool view and layout methods

Issue #2180
- Add listeners for when layers are added or removed from the MapAsset
  collection and update the layers rendered on the Cesium map and the layers
  displayed in the layer list.

Issue #2180, #1923, #1775
- Still a WIP
- Make draw tool work directly with Map model, independent of widget
- Rename DrawTool to DrawToolView

Issue #2180
- Add MapInteraction, GeoPoint and GeoBoundingBox models
- Make the CesiumWidgetView methods smaller and more modular
- Move Map model attributes to the MapInteraction model (selectedFeatures, currentPosition, currentScale, and currentViewExtent)
- In MapAsset models, listen for changes to cesiumOptions and update Cesium model
- In map connectors, don't use new models as defaults to avoid instantiating new models unnecessarily
- Pass GeoPoint and GeoScale models directly to the ScaleBarView

Issues #2189, #2180, #2187
- Still needs methods to clear the polygon and stop drawing; proper UI; testing

Issue #2180
- Add the GeoPoints collection, with methods for serializing to GeoJson
- Add a model that listens to a GeoPoints collection and updates a CesiumVectorData model with new geometry
- Use these in the DrawToolView
- Enable clearing a polygon
- Show on first click, line on second click, polygon on subsequent clicks

Issue #2180
- Switch from GeoJson to CZML (improves ability to draw around poles)
- Set up the DrawTool for actions like deleting & moving points, running a callback with user-created points as argument

Issue #2180
- Fix issues with drawing polygons, including drawing polygons over poles
- Allow drawn polygons to have properties set like other layers (color, opacity, etc)
- When drawing, draw both points and polygons
- Add CustomDataSource support
- Greatly reduce the number of re-renders Cesium must do (improve map performance)
- Add connectors between GeoPoints collection and polygons & points Entities

Issues #2180 and #2189
- In CesiumVectorData, in the new runVisualizers method, re-run in cases where visualizers are waiting for an async process to complete.
- Fixes issue with Cesium Geohashes not showing up
- Add some missing JSDocs to CesiumVectorData

Issue #2180
- Style draw tool buttons
- Hide edit & delete point buttons for now (not implemented)
- Enable configuring hiding a layer in the layer list
- Fix issue with removing entities in CesiumVectorData

Issue #2180
Add an ID to the polygon created when drawing on map so that it is updated when new points are added rather than creating a new one

Issue #2180
- Properly switch the maps "click action" back to original setting after draw tool turned off
- Fixed delayed rendering of datasources after update (esp. Geohashes)
- Fix zooming to features on click (issue with getting bounding sphere of a feature)

Issues #2180 and #2189
@robyngit
Copy link
Member Author

Findings from @artntek

  • Encountered a scenario where the map froze while loading results.
  • This freeze happened again when zooming out.
  • The issue hadn't been observed previously on the ADC Cesium map (though not much time spent exploring the ADC version)
  • The map tab did not crash, but the loading took longer than a minute.
  • On moving the browser tab, the expected results eventually displayed.

Screenshot 2023-10-18 at 1 52 27 PM
Screenshot 2023-10-18 at 1 47 56 PM
Screenshot 2023-10-18 at 1 55 47 PM

@robyngit
Copy link
Member Author

@rushirajnenuji, I am working on reproducing the problem described above. Other than that, I don't expect to make changes to this PR, so please feel free to start reviewing anytime!

@robyngit
Copy link
Member Author

@rushirajnenuji reported a behaviour he encountered where datasets and the catalog keep refreshing on the map (see video). He noted that no external triggers seem to cause it, and that he hadn't seen this happen before. This should be addressed before we release this feature.

- Wait to trigger catalog search until camera is moving has moved enough to be considered 'changed'
- Remove listeners in Map-Search-Filters connector
- Update some documentation
- Clean up some of the CesiumVectorData code

Issues #2180 and #2189
- Add min height to markdown sections with portals
- Also rename methods from postRender to what they do, because backbone calls these methods automatically even though this isn't documented!

fixes #2195
@robyngit
Copy link
Member Author

robyngit commented Nov 1, 2023

The issues observed by @rushirajnenuji and @artntek seemed to stem from the Cesium camera events triggering unpredictably (reported here and here). I added a work around so that instead of relying solely on Cesium's "moveStart" event, we trigger our own "moveStartAndCameraChanged" event that occurs after the camera starts moving and has moved enough to be considered a "changed" camera position. This seems to resolve the issue, although it's very difficult to reproduce so more testing will be needed. This branch at it's current state, which now also includes the develop changes, is deployed at http://metacatui.test.dataone.org/

@robyngit robyngit marked this pull request as ready for review November 1, 2023 18:27
@robyngit
Copy link
Member Author

robyngit commented Nov 2, 2023

Going to merge this into develop so that I can add a couple of features that depend on the changes made here. Review can be completed along with the main release PR.

@robyngit robyngit merged commit 48c9b2c into develop Nov 2, 2023
2 checks passed
@robyngit robyngit deleted the feature-2180-draw-on-map branch September 26, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant