Skip to content
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

2608 geo core initial settings #2651

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export function AddNewLayer(): JSX.Element {

const geoCoreGeoviewLayerInstance = new GeoCore(mapId, api.maps[mapId].getDisplayLanguage());
const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL);
if (layers.length === 1) {
if (layers.length >= 1) {
if (layers.length === 1) {
setLayerName(layers[0].geoviewLayerName!);
setLayerEntries(layers);
Expand Down Expand Up @@ -883,8 +883,15 @@ export function AddNewLayer(): JSX.Element {
});
} else if (layerEntries.length > 0) {
(layerEntries as TypeGeoviewLayerConfig[]).forEach((geoviewLayerConfig) => {
const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig);
if (addedLayer) addedLayers.push(addedLayer);
if (layerName !== geoviewLayerConfig.geoviewLayerName) {
const tempConfig = geoviewLayerConfig;
tempConfig.listOfLayerEntryConfig[0].layerName = layerName;
const addedLayer = api.maps[mapId].layer.addGeoviewLayer(tempConfig);
if (addedLayer) addedLayers.push(addedLayer);
} else {
const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig);
if (addedLayer) addedLayers.push(addedLayer);
}
});
}

Expand Down
5 changes: 4 additions & 1 deletion packages/geoview-core/src/geo/layer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
mapConfigLayerEntryIsGeoCore,
layerEntryIsGroupLayer,
TypeLayerStatus,
GeoCoreLayerConfig,
} from '@/geo/map/map-schema-types';
import { GeoJSON, layerConfigIsGeoJSON } from '@/geo/layer/geoview-layers/vector/geojson';
import { GeoPackage, layerConfigIsGeoPackage } from '@/geo/layer/geoview-layers/vector/geopackage';
Expand Down Expand Up @@ -449,7 +450,9 @@ export class LayerApi {
const geoCore = new GeoCore(this.getMapId(), this.mapViewer.getDisplayLanguage());

// Create the layers from the UUID
promisesOfGeoCoreGeoviewLayers.push(geoCore.createLayersFromUUID(geoviewLayerConfig.geoviewLayerId));
promisesOfGeoCoreGeoviewLayers.push(
geoCore.createLayersFromUUID(geoviewLayerConfig.geoviewLayerId, geoviewLayerConfig as GeoCoreLayerConfig)
);
} else {
// Add a resolved promise for a regular Geoview Layer Config
promisesOfGeoCoreGeoviewLayers.push(Promise.resolve([geoviewLayerConfig as TypeGeoviewLayerConfig]));
Expand Down
26 changes: 22 additions & 4 deletions packages/geoview-core/src/geo/layer/other/geocore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GeochartEventProcessor } from '@/api/event-processors/event-processor-c
import { logger } from '@/core/utils/logger';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';

import { TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types';
import { GeoCoreLayerConfig, TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types';
import { TypeJsonValue } from '@/core/types/global-types';
import { api } from '@/app';

Expand All @@ -32,11 +32,11 @@ export class GeoCore {

/**
* Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations.
*
* @param {GeoCoreLayerEntryConfig} geocoreLayerConfig the layer configuration
* @param {string} uuid the UUID of the layer
* @param {GeoCoreLayerConfig} layerConfig the layer configuration
* @returns {Promise<TypeGeoviewLayerConfig[]>} list of layer configurations to add to the map
*/
async createLayersFromUUID(uuid: string): Promise<TypeGeoviewLayerConfig[]> {
async createLayersFromUUID(uuid: string, layerConfig?: GeoCoreLayerConfig): Promise<TypeGeoviewLayerConfig[]> {
// Get the map config
const mapConfig = MapEventProcessor.getGeoViewMapConfig(this.#mapId);

Expand All @@ -50,6 +50,24 @@ export class GeoCore {
// Validate the generated Geoview Layer Config
ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers);

// Set the Layer Name for the main layer
if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName;

// Set the initialSettings parameter if present
if (layerConfig?.initialSettings) {
for (let i = 0; i < response.layers.length; i++) {
response.layers[i].initialSettings = { ...response.layers[i].initialSettings, ...layerConfig.initialSettings };
// Need to set the initial settings of the LayerConfigs. Only applies to top layers.
// Visibility is passed down to children, but other values may not.
for (let j = 0; j < response.layers[i].listOfLayerEntryConfig.length; j++) {
response.layers[i].listOfLayerEntryConfig[j].initialSettings = {
...response.layers[i].listOfLayerEntryConfig[j].initialSettings,
...layerConfig.initialSettings,
};
}
}
}

// For each found geochart associated with the Geocore UUIDs
response.geocharts?.forEach((geochartConfig) => {
// Add a GeoChart
Expand Down
3 changes: 3 additions & 0 deletions packages/geoview-core/src/geo/map/map-schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ export type GeoCoreLayerConfig = {
// TO.DOCONT: For this we will need a little trick because when we create the config the setting are set at the root level and in our config it will take it from the layerID.
// TO.DOCONT: There is refactor to do to make this work for all layer type. Global setting should be cascade to child of the root layer.
geoviewLayerName: string;

/** Initial settings to apply to the GeoCore layer at creation time. */
initialSettings?: TypeLayerInitialSettings;
};

/**
Expand Down
Loading