Skip to content

Commit

Permalink
Allow mask value to be passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Jul 29, 2024
1 parent c61e90f commit c6c5e3f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/earthengine/ee_worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expose } from 'comlink'
import { getBufferGeometry } from '../utils/buffers.js'
import ee from './ee_api_js_worker.js' // https://github.com/google/earthengine-api/pull/173
// import { ee } from '@google/earthengine/build/ee_api_js_debug' // Run "yarn add @google/earthengine"
import {
getInfo,
getScale,
Expand All @@ -28,6 +27,8 @@ const DEFAULT_FEATURE_STYLE = {
}
const DEFAULT_TILE_SCALE = 1

const DEFAULT_UNMASK_VALUE = 0

class EarthEngineWorker {
constructor(options = {}) {
this.options = options
Expand Down Expand Up @@ -294,8 +295,12 @@ class EarthEngineWorker {

// Used for "constrained" WorldPop layers
// We need to unmask the image to get the correct population density
if (unmaskAggregation) {
image = image.unmask(0)
if (unmaskAggregation || typeof unmaskAggregation === 'number') {
image = image.unmask(
typeof unmaskAggregation === number
? unmaskAggregation
: DEFAULT_UNMASK_VALUE
)
}

if (collection) {
Expand Down

0 comments on commit c6c5e3f

Please sign in to comment.