Skip to content

BGDIINF_SB-2958 : add cesium component #415

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

Merged
merged 6 commits into from
Jun 27, 2023

Conversation

vladyslav-tk
Copy link
Contributor

@vladyslav-tk vladyslav-tk commented Jun 20, 2023

  1. Added Cesium lib
  2. Updated vite.config to make cesium work
  3. Added CesiumMap component and made the switch between Ceium/OL components

Test link

@vladyslav-tk vladyslav-tk requested a review from pakb June 20, 2023 16:39
@gberaudo
Copy link
Contributor

@pakb, what is the failing "AWS CodeBuild eu-central-1 (web-mapviewer)" check?
How can we have access to it?

Copy link
Contributor

@gberaudo gberaudo left a comment

Choose a reason for hiding this comment

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

See my comments, otherwise looks like a good start to me.
I let @pakb handle the full review.

@pakb
Copy link
Contributor

pakb commented Jun 21, 2023

@pakb, what is the failing "AWS CodeBuild eu-central-1 (web-mapviewer)" check? How can we have access to it?

That's our CI hosted on Amazon, I'll check if we can give you read access to it. Here's the error it gave for this PR :

[vite:load-fallback] Could not load /codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils (imported by src/modules/map/components/cesium/CesiumMap.vue): ENOENT: no such file or directory, open '/codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils'

Error: Could not load /codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils (imported by src/modules/map/components/cesium/CesiumMap.vue): ENOENT: no such file or directory, open '/codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils'

You might want to add the .js to the import, maybe it would fix it. Try to run a npm run build or even better a npm run ci before pushing

@vladyslav-tk vladyslav-tk force-pushed the feat-BGDIINF_SB-2958_add-3d-modules branch from e2cb4a7 to f2d54e1 Compare June 21, 2023 10:02
Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

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

As you've clearly detected 3 steps in your work, would it be possible to have this 3 steps represented as commits?
That would make it much easier to review this PR, as it's already quite big

@vladyslav-tk vladyslav-tk force-pushed the feat-BGDIINF_SB-2958_add-3d-modules branch from f2d54e1 to c306c47 Compare June 21, 2023 10:23
@vladyslav-tk
Copy link
Contributor Author

@pakb, what is the failing "AWS CodeBuild eu-central-1 (web-mapviewer)" check? How can we have access to it?

That's our CI hosted on Amazon, I'll check if we can give you read access to it. Here's the error it gave for this PR :

[vite:load-fallback] Could not load /codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils (imported by src/modules/map/components/cesium/CesiumMap.vue): ENOENT: no such file or directory, open '/codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils'

Error: Could not load /codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils (imported by src/modules/map/components/cesium/CesiumMap.vue): ENOENT: no such file or directory, open '/codebuild/output/src788/src/github.com/geoadmin/web-mapviewer/src/modules/map/components/cesium/utils/navigationUtils'

You might want to add the .js to the import, maybe it would fix it. Try to run a npm run build or even better a npm run ci before pushing

I fixed the import and CI passed locally

@vladyslav-tk
Copy link
Contributor Author

As you've clearly detected 3 steps in your work, would it be possible to have this 3 steps represented as commits? That would make it much easier to review this PR, as it's already quite big

I split it into 3 commits, I will try to do smaller PRs in future

Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

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

Thanks a lot!
I would like to change a bit your approach to map component switching as I find your solution a bit too obfuscated.

Comment on lines 3 to 15
<KeepAlive>
<component :is="selectedMap">
<!-- So that external modules can have access to the map instance through the provided 'getMap' -->
<template #openlayers>
<slot name="openlayers" />
</template>
<template #cesium>
<slot name="cesium" />
</template>
<slot />
<LocationPopup v-if="!is3DActive" />
</component>
</KeepAlive>
Copy link
Contributor

Choose a reason for hiding this comment

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

would it not be possible to have something like

<CesiumMap v-if="is3DActive" />
<OpenLayersMap v-else>
    // ...
</OpenLayersMap>

I find your approach way too hard to understand and the implication it has (some slot down the lines are implicitly called this way, like the DrawingModule and Footer, but that is not clear here that this will be the case)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was my first solution but it is not really good in the case of performance when switching OL/cesium. With my solution with templates and keepAlive, OL/cesium component, map, and everything related creates and loads only one time when you switch it on the first time. With an if/else solution everything creates and loads each time when you switch between 2d/3d so it takes more time on the second switch and the same data loads again

Anyway, I reworked my solution with if/else so you can test and then we can keep it or back to a templates solution

@@ -357,17 +362,16 @@ export default {
this.map.on('pointerdown', this.onMapPointerDown)
// TODO: trigger a click after pointer is down at (roughly) the same spot
// for longer than 1sec (no need to wait for the user to stop the click)
this.map.on('pointerup', this.onMapPointerUp)
// this.map.on('pointerup', this.onMapPointerUp) todo onMapPointerUp undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch, but I would prefer we stick to the task at hand.
I'll create a ticket on our side to deal with this

@gberaudo
Copy link
Contributor

@vladyslav-tk, I propose we rely on https://www.npmjs.com/package/@cesium/engine

@vladyslav-tk
Copy link
Contributor Author

@vladyslav-tk, I propose we rely on https://www.npmjs.com/package/@cesium/engine

engine doesn't contain a viewer so we can't use the engine only

Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

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

That's much easier to understand what's going on with the component hierarchy this way, thanks!
The trade off is that it's a bit less efficient if you switch back and forth between 3D and 2D, but that's not something users should be doing too often.

Now a last little thing to add : some Cypress test that check that an intercepted (mockup) 3D tile is loaded after we've clicked on the 3D button (checking that Cesium was configured and loaded correctly)

Comment on lines 54 to 55
cy.get('#cesium canvas').should('be.visible')
cy.get('#ol-map canvas').should('not.exist')
Copy link
Contributor

Choose a reason for hiding this comment

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

if possible, it would be better to use custom data-cy="..." CSS selector (Cypress best practices), at least to grab the OL and Cesium map element (grabbing the canvas cannot be done any other way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Comment on lines +67 to +68
expect(cameraPosition.longitude).to.eq(0.13147292983909972)
expect(cameraPosition.latitude).to.eq(0.819968266410843)
Copy link
Contributor

Choose a reason for hiding this comment

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

is that expressed in radians?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, when using camera.positionCartographic, camera.position will be in Cartesian3

@vladyslav-tk vladyslav-tk force-pushed the feat-BGDIINF_SB-2958_add-3d-modules branch from 7cc71b0 to 195349b Compare June 26, 2023 15:26
@vladyslav-tk vladyslav-tk force-pushed the feat-BGDIINF_SB-2958_add-3d-modules branch from 195349b to 4dfb76b Compare June 27, 2023 07:11
@pakb pakb merged commit bedbd7c into develop Jun 27, 2023
@pakb pakb deleted the feat-BGDIINF_SB-2958_add-3d-modules branch June 27, 2023 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants