BGDIINF_SB-2890: better handling of zoom conversion#471
Conversation
2c9bd56 to
c78d5f1
Compare
ltshb
left a comment
There was a problem hiding this comment.
Ok after a call with @pakb here what we decided to make the code easier to understand and to enhanced with other coordinate systems:
- Add a mandatory abstract method in
CoordinateSystemclass that would translate the zoom level. The method could be then named for example:getZoomFromResolution(resolution, coordinate). I personally would provide the whole coordinate even if for the moment only the latitude is needed for mercator. - Use class inheritance for the coordinate system specialization
class Lv95 extends CoordinateSystem. This specialization would implement thegetZoomFromResolution - Add also a
getResolutionFromZoominCoordinateSystemthis would remove the gettersresolutionin position.store.js
It may be a good idea to first merge this PR with just some minor changes before this big refactoring, and do the big refactoring in separate PR.
src/store/plugins/reproject-everything-on-projection-change.plugin.js
Outdated
Show resolved
Hide resolved
We still have an issue with the zoom level, but this might be solved by #471
868522f to
34d2793
Compare
6b04f29 to
a056148
Compare
|
@pakb Passing to 3d view crash the application |
ltshb
left a comment
There was a problem hiding this comment.
You can (either by scrolling, clicking on zoom or entering in the url) go up to zoom 13, however you got only tiles up to zoom 9.4 above you have either empty tiles or failures from backend.
|
There was a missing resolution, I forgot one in the process of moving them from config.js to the dedicated projection file somehow 🙈 3D should be fixed too |
| -90.0, | ||
| 90.0, | ||
| // center of LV95's extent transformed with epsg.io website | ||
| [8.239436, 46.832259] |
There was a problem hiding this comment.
Might be better to use proj4 to dynamically re-project the LV95 extent here ?
There was a problem hiding this comment.
Or even better make this configurable in the config.js, this way if someone want to use our soft and want to center on france for example he only needs to change its config.js file and not the implementation.
There was a problem hiding this comment.
I think this needs some kind of startup rework, as proj4 is not yet configured when we instantiate these coordinate systems.
Plus it would not be super robust, as if I start the app with .../?sr=3857 without specifying a center, it would not reproject the default center automatically (so it needs some more thoughts)
But I like this idea!
| this.viewer.scene.postRender.addEventListener( | ||
| limitCameraCenter(LV95.getBoundsAs(WGS84).flatten) | ||
| ) |
There was a problem hiding this comment.
Similar comment as down below, would it make sense to have config value for the default bound/center ? To avoid hardcoding it here, so our default bounds and center is CH but for other it might something else. So could we have something like this
// CesiumMap.vue
limitCameraCenter(DEFAULT_PROJECTION.getBoundsAs(WGS84).flatten)Maybe then also add a comment in the config.js that the default projection is also used as default bound and center.
There was a problem hiding this comment.
maybe we should do that only when the DEFAULT_PROJECTION is a CustomCoordinateSystem, as it would normally be the case that such a system will shrink its size to fit some part of the World.
| const tileGridLV95 = new TileGrid({ | ||
| resolutions: TILEGRID_RESOLUTIONS, | ||
| extent: TILEGRID_EXTENT, | ||
| origin: TILEGRID_ORIGIN, | ||
| tileSize: WMS_TILE_SIZE, | ||
| }) | ||
| // If we are using LV95, we can constrain the WMS to only request tiles over Switzerland | ||
| if (this.projection.epsg === LV95.epsg) { | ||
| source.tileGrid = tileGridLV95 | ||
| } else if (this.gutter !== -1) { | ||
| // in WebMercator, the tile grid is reprojected analog to WMTS. | ||
| // This is to prevent that the layer appears twice, once in CH and once near New Zealand. | ||
| // see: https://github.com/geoadmin/web-mapviewer/commit/c689f9a650c546c6e52a91fc2086d7cbbf48faa2 | ||
| source.setTileGridForProjection( | ||
| WEBMERCATOR.epsg, | ||
| new TileGrid({ | ||
| resolutions: TILEGRID_RESOLUTIONS, | ||
| origin: proj4(LV95.epsg, WEBMERCATOR.epsg, TILEGRID_ORIGIN), | ||
| extent: transformExtent( | ||
| tileGridLV95.getExtent(), | ||
| LV95.epsg, | ||
| WEBMERCATOR.epsg | ||
| ), | ||
| }) | ||
| ) | ||
| if (this.projection instanceof CustomCoordinateSystem) { | ||
| source.tileGrid = new TileGrid({ | ||
| resolutions: this.projection.getResolutions(), | ||
| extent: this.projection.bounds.flatten, | ||
| origin: this.projection.getTileOrigin(), | ||
| tileSize: WMS_TILE_SIZE, | ||
| }) |
There was a problem hiding this comment.
Very nice code simplification 👍🏼
between Swiss and non-Swiss projections, fixing the Zoom to extent functionality in the process Most, if not all, zoom related utils function and constants have been moved to the zoomLevelUtils.js file
to better represents the different flavor of projection we use in our app. And also to gather all the transformation operations necessary to switch from one another directly within them (thus deleting the zoomUtils.js file)
as they are not "config" in a sense that they should not be changed, but are linked to how our application will function when having LV95 as its primary coordinate system
And simplify how we declare tile grids in our OpenLayers components Also fix an issue of number order in the LV95 bounds
There was one step missing while close to the ground, making all tiles past zoom level 10 failing to be correctly requested
and update proj4 definition (they were updated on the EPSG website)
f813240 to
8906261
Compare
use the default projection to constrain Cesium (instead of hard-coding LV95) fix some comments
between Swiss and non-Swiss projections, fixing the Zoom to extent functionality in the process
Most, if not all, zoom related utils function and constants have been moved to the zoomLevelUtils.js file
Test link