-
Notifications
You must be signed in to change notification settings - Fork 353
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
Thredds palettes #7059
base: main
Are you sure you want to change the base?
Thredds palettes #7059
Changes from 26 commits
e09266a
33e4694
ad99869
f00d68a
7e2b20e
1db060e
9eefa33
1a477f4
1227d07
ecabd69
dc1a2b5
3e23262
e9209ff
54b4420
1d22d63
843ab42
086f24b
edc06b2
38c8c9d
a14d46e
0fd38b8
9f91a7d
41892d2
722db12
2528d60
bacefe0
0dfd466
283bda1
f8d87f0
c07fb88
e8fc7b6
2ee6c8f
d8d11b6
2ddd71c
d06645c
545cf4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -38,7 +38,8 @@ import { | |||
} from "../../../Table/tableFeatureInfoContext"; | ||||
import WebMapServiceCatalogItemTraits, { | ||||
SUPPORTED_CRS_3857, | ||||
SUPPORTED_CRS_4326 | ||||
SUPPORTED_CRS_4326, | ||||
WebMapServiceAvailableLayerStylesTraits | ||||
} from "../../../Traits/TraitsClasses/WebMapServiceCatalogItemTraits"; | ||||
import CommonStrata from "../../Definition/CommonStrata"; | ||||
import CreateModel from "../../Definition/CreateModel"; | ||||
|
@@ -225,12 +226,16 @@ class WebMapServiceCatalogItem | |||
} | ||||
|
||||
protected async forceLoadMetadata(): Promise<void> { | ||||
if (this.palettes.length === 0) { | ||||
this.fetchPalettes(); | ||||
} | ||||
if ( | ||||
this.strata.get(GetCapabilitiesMixin.getCapabilitiesStratumName) !== | ||||
undefined | ||||
) | ||||
return; | ||||
const stratum = await WebMapServiceCapabilitiesStratum.load(this); | ||||
|
||||
runInAction(() => { | ||||
this.strata.set(GetCapabilitiesMixin.getCapabilitiesStratumName, stratum); | ||||
}); | ||||
|
@@ -380,6 +385,7 @@ class WebMapServiceCatalogItem | |||
if (time) { | ||||
uri.addQuery("time", time); | ||||
} | ||||
|
||||
return uri.toString(); | ||||
} | ||||
|
||||
|
@@ -518,8 +524,6 @@ class WebMapServiceCatalogItem | |||
return undefined; | ||||
} | ||||
|
||||
console.log(`Creating new ImageryProvider for time ${time}`); | ||||
|
||||
// Set dimensionParameters | ||||
const dimensionParameters = formatDimensionsForOws(this.dimensions); | ||||
if (time !== undefined) { | ||||
|
@@ -619,6 +623,104 @@ class WebMapServiceCatalogItem | |||
} | ||||
); | ||||
|
||||
fetchPalettes(): Promise<string[]> { | ||||
return new Promise((resolve, reject) => { | ||||
if (!this.isThredds) { | ||||
resolve([]); | ||||
} | ||||
|
||||
if (this.palettes.length > 0) { | ||||
resolve([...this.palettes]); | ||||
} | ||||
|
||||
const extractedUrl = this.uri!.clone() | ||||
.setSearch({ | ||||
service: "WMS", | ||||
version: this.useWmsVersion130 ? "1.3.0" : "1.1.1", | ||||
request: "GetMetadata", | ||||
item: "layerDetails", | ||||
layerName: this.layersArray[0] | ||||
}) | ||||
.toString(); | ||||
|
||||
if (!extractedUrl) { | ||||
resolve([]); | ||||
} | ||||
const proxiedUrl = proxyCatalogItemUrl(this, extractedUrl!); | ||||
|
||||
fetch(proxiedUrl, { method: "GET" }) | ||||
.then((response) => response.json()) | ||||
.then((data) => { | ||||
this.setTrait(CommonStrata.user, "palettes", data.palettes); | ||||
this.setTrait( | ||||
CommonStrata.user, | ||||
"colorScaleMinimum", | ||||
data.scaleRange[0] | ||||
); | ||||
this.setTrait( | ||||
CommonStrata.user, | ||||
"colorScaleMaximum", | ||||
data.scaleRange[1] | ||||
); | ||||
this.setTrait( | ||||
CommonStrata.user, | ||||
"defaultPalette", | ||||
data.defaultPalette | ||||
); | ||||
this.setTrait( | ||||
CommonStrata.user, | ||||
"noPaletteStyles", | ||||
data.noPaletteStyles | ||||
); | ||||
this.setTrait(CommonStrata.user, "showPalettes", true); | ||||
resolve(data.palettes); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Can you please move the |
||||
}) | ||||
.catch((error) => { | ||||
reject(error); | ||||
}); | ||||
}); | ||||
} | ||||
|
||||
@computed | ||||
get paletteDimensions(): SelectableDimensionEnum[] { | ||||
if (!this.isNcWMS || !this.showPalettes) { | ||||
return []; | ||||
} | ||||
|
||||
const options: { name: string; id: string }[] = []; | ||||
|
||||
this.palettes.map((palette) => { | ||||
options.push({ | ||||
name: palette, | ||||
id: palette | ||||
}); | ||||
}); | ||||
|
||||
return [ | ||||
{ | ||||
name: "Palettes", | ||||
id: `${this.uniqueId}-palettes`, | ||||
options, | ||||
selectedId: this.palette, | ||||
setDimensionValue: ( | ||||
stratumId: string, | ||||
newPalette: string | undefined | ||||
) => { | ||||
//if (this.stylesArray[0]) { | ||||
runInAction(() => { | ||||
this.setTrait(stratumId, "palette", newPalette); | ||||
const currentStyle = this.stylesArray[0] | ||||
? this.stylesArray[0] | ||||
: "default"; | ||||
const newStyles = currentStyle.split("/")[0] + "/" + newPalette; | ||||
this.setTrait(stratumId, "styles", newStyles); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are some issues with updating With the current implementation, You can apply the palette to the
|
||||
}); | ||||
//} | ||||
} | ||||
} | ||||
]; | ||||
} | ||||
|
||||
@computed | ||||
get styleSelectableDimensions(): SelectableDimensionEnum[] { | ||||
return this.availableStyles.map((layer, layerIndex) => { | ||||
|
@@ -665,12 +767,26 @@ class WebMapServiceCatalogItem | |||
newStyle: string | undefined | ||||
) => { | ||||
if (!newStyle) return; | ||||
|
||||
runInAction(() => { | ||||
const styles = this.styleSelectableDimensions.map( | ||||
(style) => style.selectedId || "" | ||||
); | ||||
styles[layerIndex] = newStyle; | ||||
this.setTrait(stratumId, "styles", styles.join(",")); | ||||
styles[layerIndex] = newStyle ? newStyle : ""; | ||||
|
||||
if (this.isNcWMS && this.palette) { | ||||
const currentStyle = newStyle.split("/")[0]; | ||||
const currentPalette = this.palette; | ||||
const newStyles = currentStyle + "/" + currentPalette; | ||||
this.setTrait(stratumId, "styles", newStyles); | ||||
if (this.noPaletteStyles.includes(newStyle)) { | ||||
this.setTrait(stratumId, "showPalettes", false); | ||||
} else { | ||||
this.setTrait(stratumId, "showPalettes", true); | ||||
} | ||||
} else { | ||||
this.setTrait(stratumId, "styles", styles.join(",")); | ||||
} | ||||
Comment on lines
+748
to
+767
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, I think you should keep |
||||
}); | ||||
}, | ||||
// There is no way of finding out default style if no style has been selected :( | ||||
|
@@ -755,10 +871,13 @@ class WebMapServiceCatalogItem | |||
return super.selectableDimensions; | ||||
} | ||||
|
||||
const paletteDimensions = this.showPalettes ? this.paletteDimensions : []; | ||||
|
||||
return filterOutUndefined([ | ||||
...super.selectableDimensions, | ||||
...this.wmsDimensionSelectableDimensions, | ||||
...this.styleSelectableDimensions | ||||
...this.styleSelectableDimensions, | ||||
...paletteDimensions | ||||
]); | ||||
} | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be loaded after
GetCapabilitiesStratum