Skip to content

Commit 96cef85

Browse files
Fix bug when loading geojson layers in notebook and update notebook test (#305)
* Assign IDs to features when creating * Update notebook test * Update Playwright Snapshots * Upload geojson file in test * Update Playwright Snapshots --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 86abebb commit 96cef85

7 files changed

+15
-10
lines changed

packages/base/src/mainview/mainView.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
3030
import { User } from '@jupyterlab/services';
3131
import { JSONValue, UUID } from '@lumino/coreutils';
32-
import { Collection, MapBrowserEvent, Map as OlMap, View } from 'ol';
32+
import { Collection, MapBrowserEvent, Map as OlMap, View, getUid } from 'ol';
3333
import { ScaleLine } from 'ol/control';
3434
import { GeoJSON, MVT } from 'ol/format';
3535
import { DragAndDrop, Select } from 'ol/interaction';
@@ -489,6 +489,10 @@ export class MainView extends React.Component<IProps, IStates> {
489489

490490
const featureCollection = new Collection(featureArray);
491491

492+
featureCollection.forEach(feature => {
493+
feature.setId(getUid(feature));
494+
});
495+
492496
newSource = new VectorSource({
493497
features: featureCollection
494498
});

ui-tests/tests/notebook.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
22
import * as path from 'path';
33
const klaw = require('klaw-sync');
44

5+
const FILENAME = 'eq.json';
6+
57
const testCellOutputs = async (
68
page: IJupyterLabPageFixture,
79
tmpPath: string,
@@ -65,6 +67,10 @@ test.describe('Notebook API Visual Regression', () => {
6567
path.resolve(__dirname, './notebooks'),
6668
tmpPath
6769
);
70+
await page.contents.uploadFile(
71+
path.resolve(__dirname, `./gis-files/${FILENAME}`),
72+
`/${tmpPath}/${FILENAME}`
73+
);
6874
await page.filebrowser.openDirectory(tmpPath);
6975
});
7076

Loading
Loading
Loading
Loading

ui-tests/tests/notebooks/Notebook.ipynb

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"metadata": {},
2929
"outputs": [],
3030
"source": [
31-
"doc = GISDocument(latitude=40.775, longitude=-73.973, zoom=13)\n",
31+
"doc = GISDocument(latitude=20.718, longitude=129.940, zoom=4)\n",
3232
"\n",
3333
"doc.add_raster_layer(\n",
3434
" url=\"https://tile.openstreetmap.org/{z}/{x}/{y}.png\",\n",
@@ -46,7 +46,7 @@
4646
"metadata": {},
4747
"outputs": [],
4848
"source": [
49-
"doc = GISDocument(latitude=40.775, longitude=-73.973, zoom=13)\n",
49+
"doc = GISDocument(latitude=20.718, longitude=129.940, zoom=4)\n",
5050
"\n",
5151
"doc.add_raster_layer(\n",
5252
" url=\"https://tile.openstreetmap.org/{z}/{x}/{y}.png\",\n",
@@ -55,12 +55,7 @@
5555
" opacity=0.6,\n",
5656
")\n",
5757
"\n",
58-
"doc.add_vectortile_layer(\n",
59-
" url=\"https://planetarycomputer.microsoft.com/api/data/v1/vector/collections/ms-buildings/tilesets/global-footprints/tiles/{z}/{x}/{y}\",\n",
60-
" source_layer=\"bingmlbuildings\",\n",
61-
" max_zoom=13,\n",
62-
" min_zoom=13,\n",
63-
")\n",
58+
"doc.add_geojson_layer(path=\"./eq.json\")\n",
6459
"\n",
6560
"doc"
6661
]
@@ -82,7 +77,7 @@
8277
"name": "python",
8378
"nbconvert_exporter": "python",
8479
"pygments_lexer": "ipython3",
85-
"version": "3.12.4"
80+
"version": "3.12.8"
8681
}
8782
},
8883
"nbformat": 4,

0 commit comments

Comments
 (0)