Skip to content

Conversation

@nf-s
Copy link
Member

@nf-s nf-s commented Mar 26, 2025

This is an experiment to see what would be needed in order to lock down the use of "loadable" strata.

It also just an exercise for me to go through and review how loadable strata are used.

In my mind strata should only be used to populate trait values. From the docs:

Strata that provide values for a subset of the properties defined on model's traits class, usually by loading them from an external source such as WMS GetCapabilities service

In many cases, we also access loadable stratum properties that don't apply to traits (for example - WebMapServiceCatalogItem.validLayers -

/** LAYERS which are valid (i.e. exist in GetCapabilities).
* These can be fetched from the server (eg GetMap request)
*/
@computed get validLayers() {
const gcStratum: WebMapServiceCapabilitiesStratum | undefined =
this.strata.get(
GetCapabilitiesMixin.getCapabilitiesStratumName
) as WebMapServiceCapabilitiesStratum;
if (gcStratum)
return this.layersArray
.map((layer) => gcStratum.capabilities.findLayer(layer)?.Name)
.filter(isDefined);
return [];
}
)

Most usage of loadable strata like this can be easily refactored by creating extra traits - for example

@objectArrayTrait({
type: WebMapServiceAvailableLayersTraits,
name: "Available Layers",
description: "The available layers.",
idProperty: "name"
})
availableLayers?: WebMapServiceAvailableLayersTraits[];

Which means we can now avoid using the stratum directly

/** LAYERS which are valid (i.e. exist in GetCapabilities).
* These can be fetched from the server (eg GetMap request)
*/
@computed get validLayers() {
return this.layersArray.map((layer) =>
this.availableLayers.find(
(l) =>
l.name === layer ||
l.title === layer ||
l.name === layer.split(":").pop()
)
);
}

There are also a number of patterns that end up using these lodable strata properties directly

  • A lot of "dynamic" groups (eg CKAN or OpenDataSoft or WMS group) have a createMembers function that sits in a loadable stratum
  • Use of discreteTimes is also usually from within a loadable stratum

Future work

  • I would also be interesting in seeing if we could create a "cachable" loadable stratum - that is - a loadable stratum that has no reactivity.
    • This could then be used to cache expensive operations - for example, loading and parsing WMS GetCapabilities on a server with many layers - or loading CKAN datasets

Todo

  • Fix WebMapTileServiceCatalogItem
  • Fix tests that inspect strata values directly
  • Test everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants