Skip to content

Fix GISDocument not applying projection argument #732

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export class MainView extends React.Component<IProps, IStates> {
: [0, 0];
const zoom = options.zoom !== undefined ? options.zoom! : 1;
await this.generateScene(center, zoom);

this.addContextMenu();
this._mainViewModel.initSignal();
if (window.jupytergisMaps !== undefined && this._documentPath) {
Expand Down Expand Up @@ -304,7 +305,8 @@ export class MainView extends React.Component<IProps, IStates> {
const center = view.getCenter() || [0, 0];
const zoom = view.getZoom() || 0;

const projection = view.getProjection();
const projection =
getProjection(currentOptions.projection) ?? view.getProjection();
const latLng = toLonLat(center, projection);
const bearing = view.getRotation();
const resolution = view.getResolution();
Expand Down Expand Up @@ -360,12 +362,16 @@ export class MainView extends React.Component<IProps, IStates> {
this._contextMenu.open(event);
});

const projection =
getProjection(this._model.getOptions().projection) ??
view.getProjection();

this.setState(old => ({
...old,
loading: false,
viewProjection: {
code: view.getProjection().getCode(),
units: view.getProjection().getUnits(),
code: projection.getCode(),
units: projection.getUnits(),
},
}));
}
Expand Down Expand Up @@ -1566,13 +1572,23 @@ export class MainView extends React.Component<IProps, IStates> {
if (projection !== undefined && currentProjection !== projection) {
const newProjection = getProjection(projection);
if (newProjection) {
this.setState(old => ({
viewProjection: {
...old.viewProjection,
code: newProjection.getCode(),
units: newProjection.getUnits(),
},
}));
view = new View({ projection: newProjection });
} else {
console.warn(`Invalid projection: ${projection}`);
return;
}
}

view.setRotation(bearing || 0);
this._Map.setView(view);

// Use the extent only if explicitly requested (QGIS files).
if (useExtent && extent) {
view.fit(extent);
Expand All @@ -1590,10 +1606,6 @@ export class MainView extends React.Component<IProps, IStates> {
this._model.setOptions(options);
}
}

view.setRotation(bearing || 0);

this._Map.setView(view);
}

private _onViewChanged(
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,11 @@ __metadata:
shpjs: ^6.1.0
styled-components: ^5.3.6
three: ^0.135.0
three-mesh-bvh: ^0.5.17
ts-patch: ^3.3.0
typescript: ^5
typescript-transform-paths: ^3.5.5
uuid: ^11.0.3
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -11362,6 +11364,15 @@ __metadata:
languageName: node
linkType: hard

"three-mesh-bvh@npm:^0.5.17":
version: 0.5.24
resolution: "three-mesh-bvh@npm:0.5.24"
peerDependencies:
three: ">= 0.123.0"
checksum: 5a5e356111756869cfd00870bca2d881d3019b55e71142b5eee544a2e6bcc3546a340b0defa29c3ebe7ed4cfe99e7ee6addd5671bb89852841107189c0f98157
languageName: node
linkType: hard

"three@npm:^0.135.0":
version: 0.135.0
resolution: "three@npm:0.135.0"
Expand Down Expand Up @@ -11885,6 +11896,15 @@ __metadata:
languageName: node
linkType: hard

"uuid@npm:^11.0.3":
version: 11.1.0
resolution: "uuid@npm:11.1.0"
bin:
uuid: dist/esm/bin/uuid
checksum: 840f19758543c4631e58a29439e51b5b669d5f34b4dd2700b6a1d15c5708c7a6e0c3e2c8c4a2eae761a3a7caa7e9884d00c86c02622ba91137bd3deade6b4b4a
languageName: node
linkType: hard

"uuid@npm:^9.0.0":
version: 9.0.1
resolution: "uuid@npm:9.0.1"
Expand Down
Loading