Skip to content

Commit

Permalink
feat: run Earth Engine API in a web worker (DHIS2-12013) (#415)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Run all EE API code in a separate web worker
  • Loading branch information
turban authored Dec 20, 2021
1 parent 8d72e6c commit e3b9a46
Show file tree
Hide file tree
Showing 20 changed files with 46,705 additions and 550 deletions.
2 changes: 2 additions & 0 deletions jest.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ global.mockMapGL = {
global.mockMap = {
getMapGL: () => mockMapGL,
setHoverState: jest.fn(),
getBeforeLayerId: jest.fn(),
styleIsLoaded: () => true,
}

// https://stackoverflow.com/questions/57943736/how-to-fix-window-url-createobjecturl-is-not-a-function-when-testing-mapbox-gl
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@turf/center-of-mass": "^6.3.0",
"@turf/circle": "^6.3.0",
"@turf/length": "^6.3.0",
"comlink": "^4.3.1",
"fetch-jsonp": "^1.1.3",
"lodash.throttle": "^4.1.1",
"maplibre-gl": "^1.15.2",
Expand Down
4 changes: 1 addition & 3 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ export class MapGL extends Evented {
async removeLayer(layer) {
this._layers = this._layers.filter(l => l !== layer)

if (this._mapgl && layer.isOnMap()) {
await layer.removeFrom(this)
}
await layer.removeFrom(this)

this.fire('layerremove', this._layers)
}
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/Map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ jest.mock('maplibre-gl', () => ({
FullscreenControl: () => {},
}))

jest.mock('../earthengine/ee_worker_loader', () => ({
__esModule: true,
default: jest.fn(),
}))

describe('DHIS2 Maps-gl Map', () => {
it('should initialize correctly', () => {
const map = new Map('el')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasClasses, getHistogramStatistics } from '../earthengine'
import { hasClasses, getHistogramStatistics } from '../ee_worker_utils'

const scale = 1000

Expand Down
Loading

0 comments on commit e3b9a46

Please sign in to comment.