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

fix(details/table): No table for pyGeoApiProcess and CSV #2146

Merged
merged 3 commits into from
May 16, 2024
Merged
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
98 changes: 0 additions & 98 deletions packages/geoview-core/public/configs/layer-panel-zoom-config.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h4 id="HLYR5">GeoJSON Layer</h4>
'components': ['overview-map'],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details']
'core': ['legend', 'layers', 'details', 'data-table']
}
},
'corePackages': [],
Expand Down
10 changes: 0 additions & 10 deletions packages/geoview-core/public/templates/raw-add-layers.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h1><strong>Package - Layers Panel</strong></h1>
<td>
<a href="./index.html">Main</a><br />
<a href="#HUC1">Default Configuration</a><br />
<a href="#HUC2">With Layers in Config</a><br />
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -200,18 +199,9 @@ <h4>Add Layer Examples</h4>
<hr />
<button type="button" class="collapsible">Configuration Snippet</button>
<pre id="mapWMCS" class="panel"></pre>

<hr />

<div class="map-title-holder">
<h4 id="HUC2">2. Layer Panel with layers in config</h4>
<a class="ref-link" href="#top">Top</a>
</div>
<div id="mapWM2" class="geoview-map" data-lang="en" data-config-url="./configs/layer-panel-zoom-config.json"></div>
<pre id="mapWM2CS" class="panel"></pre>

<script src="codedoc.js"></script>

<script>
function addGeocore() {
// Precond
Expand Down
2 changes: 0 additions & 2 deletions packages/geoview-core/public/templates/sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ <h1><strong>Sandbox Configuration</strong></h1>
'map': {
'interaction': 'dynamic',
'viewSettings': {
'initialView': { 'zoomAndCenter': [2, [-110, 70]]},
'projection': 3978
},
'basemapOptions': {
Expand Down Expand Up @@ -331,7 +330,6 @@ <h4 id="HLCONF1">Sanbox Map</h4>
'map': {
'interaction': 'dynamic',
'viewSettings': {
'initialView': {'zoomAndCenter': [5, [-110, 70]]},
'projection': 3978
},
'basemapOptions': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,13 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
* @param {TypeOrderedLayerInfo[]} orderedLayerInfo - The ordered layer information.
*/
setOrderedLayerInfo: (orderedLayerInfo: TypeOrderedLayerInfo[]): void => {
// We need to explicitly define ... for the array. If not subscribe does not fired
// TODO: refactor - setterActions in setState will recreate array if needed. We need to implement the pattern in all setterActions
// TD.CONT: We should have a deep equality function to compare previous / current
set({
mapState: {
...get().mapState,
orderedLayerInfo,
orderedLayerInfo: [...orderedLayerInfo],
},
});
},
Expand All @@ -645,7 +648,7 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
layerInfo.hoverable = hoverable;

// Redirect
get().mapState.setterActions.setOrderedLayerInfo([...curLayerInfo]);
get().mapState.setterActions.setOrderedLayerInfo(curLayerInfo);
}
},

Expand All @@ -662,7 +665,7 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
if (queryable) layerInfo.hoverable = queryable;

// Redirect
get().mapState.setterActions.setOrderedLayerInfo([...curLayerInfo]);
get().mapState.setterActions.setOrderedLayerInfo(curLayerInfo);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { CsvLayerEntryConfig } from '@/core/utils/config/validation-classes/vect
import { VectorLayerEntryConfig } from '@/core/utils/config/validation-classes/vector-layer-entry-config';
import { AbstractBaseLayerEntryConfig } from '@/core/utils/config/validation-classes/abstract-base-layer-entry-config';
import { AppEventProcessor } from '@/api/event-processors/event-processor-children/app-event-processor';
import { Cast, TypeJsonObject } from '@/api/config/types/config-types';

// GV: CONFIG EXTRACTION
// GV: This section of code was extracted and copied to the geoview config section
Expand Down Expand Up @@ -157,6 +158,8 @@ export class CSV extends AbstractGeoViewVector {
* @returns {Promise<TypeLayerEntryConfig>} A promise that the vector layer configuration has its metadata processed.
*/
protected override processLayerMetadata(layerConfig: VectorLayerEntryConfig): Promise<TypeLayerEntryConfig> {
// process the feature info configuration and attach the config to the instance for access by parent class
this.layerMetadata[layerConfig.layerPath] = Cast<TypeJsonObject>(layerConfig);
return Promise.resolve(layerConfig);
}

Expand Down Expand Up @@ -258,6 +261,7 @@ export class CSV extends AbstractGeoViewVector {
if (latList.includes(headers[i].toLowerCase())) latIndex = i;
if (lonList.includes(headers[i].toLowerCase())) lonIndex = i;
}

if (latIndex === undefined || lonIndex === undefined) {
logger.logError(
`Could not find geographic data for ${getLocalizedValue(this.geoviewLayerName, AppEventProcessor.getDisplayLanguage(this.mapId))}`
Expand All @@ -269,7 +273,9 @@ export class CSV extends AbstractGeoViewVector {
layerConfig.layerStatus = 'error';
return null;
}

CSV.#processFeatureInfoConfig(headers, csvRows[1], [latIndex, lonIndex], layerConfig);

for (let i = 1; i < csvRows.length; i++) {
const currentRow = csvRows[i];
const properties: { [key: string]: string | number } = {};
Expand All @@ -278,6 +284,7 @@ export class CSV extends AbstractGeoViewVector {
properties[headers[j]] = currentRow[j] !== '' && Number(currentRow[j]) ? Number(currentRow[j]) : currentRow[j];
}
}

const lon = currentRow[lonIndex] ? Number(currentRow[lonIndex]) : Infinity;
const lat = currentRow[latIndex] ? Number(currentRow[latIndex]) : Infinity;
if (Number.isFinite(lon) && Number.isFinite(lat)) {
Expand All @@ -289,6 +296,7 @@ export class CSV extends AbstractGeoViewVector {
features.push(feature);
}
}

return features;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ConfigBaseClass } from '@/core/utils/config/validation-classes/config-b
import { TypeHoverLayerData } from './hover-feature-info-layer-set';
import { LayerApi } from '@/geo/layer/layer';
import { AppEventProcessor } from '@/api/event-processors/event-processor-children/app-event-processor';
import { Cast, TypeJsonObject } from '@/core/types/global-types';

/**
* A class to hold a set of layers associated with a value of any type.
Expand Down Expand Up @@ -88,6 +89,10 @@ export abstract class AbstractLayerSet {

// Synchronize the layer name property in the config and the layer set object when the geoview instance is ready.
if (!layerConfig.layerName) layerConfig.layerName = createLocalizedString(this.resultSet[layerPath].layerName!);

// There is a synch issue when layerName is not set on the layerConfig when layer is registered, it wil not appear in UI
if (this.resultSet[layerPath].data)
(Cast<TypeJsonObject>(this.resultSet[layerPath].data).layerName as string) = this.resultSet[layerPath].layerName!;
}

// Inform that the layer set has been updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class AllFeatureInfoLayerSet extends AbstractLayerSet {
// Log
logger.logTraceCore('ALL-FEATURE-INFO-LAYER-SET - onRegisterLayerCheck', layerConfig.layerPath, Object.keys(this.resultSet));

// TODO: Make a util function for this check
// TODO: Make a util function for this check - this can be done prior to layer creation in config section
// for some layer type, we know there is no data-table
if (
[
CONST_LAYER_TYPES.ESRI_IMAGE,
Expand All @@ -40,8 +41,10 @@ export class AllFeatureInfoLayerSet extends AbstractLayerSet {
)
return false;

// TODO: there is a synching issue, sometimes source is undefined when layer is registered. To overcome this,
// TD.CONT: if not specified to false by default, we will set it to true
const queryable = layerConfig?.source?.featureInfo?.queryable;
return !!queryable;
return !!(queryable || queryable === undefined);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logger } from '@/core/utils/logger';
import { getLocalizedValue } from '@/core/utils/utilities';
import { ConfigBaseClass } from '@/core/utils/config/validation-classes/config-base-class';
import { TypeLayerEntryConfig, TypeLayerStatus } from '@/geo/map/map-schema-types';
import { AbstractGeoViewLayer } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { AbstractGeoViewLayer, CONST_LAYER_TYPES } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { EventType, AbstractLayerSet, TypeFeatureInfoEntry, TypeLayerData, TypeResultSet } from './abstract-layer-set';
import { LayerApi } from '@/geo/layer/layer';
import { AppEventProcessor } from '@/api/event-processors/event-processor-children/app-event-processor';
Expand Down Expand Up @@ -62,8 +62,19 @@ export class FeatureInfoLayerSet extends AbstractLayerSet {
// Log
logger.logTraceCore('FEATURE-INFO-LAYER-SET - onRegisterLayerCheck', layerConfig.layerPath, Object.keys(this.resultSet));

// TODO: Make a util function for this check - this can be done prior to layer creation in config section
// for some layer type, we know there is no details
if (
[CONST_LAYER_TYPES.ESRI_IMAGE, CONST_LAYER_TYPES.IMAGE_STATIC, CONST_LAYER_TYPES.XYZ_TILES, CONST_LAYER_TYPES.VECTOR_TILES].includes(
geoviewLayer.type
)
)
return false;

// TODO: there is a synching issue, sometimes source is undefined when layer is registered. To overcome this,
// TD.CONT: if not specified to false by default, we will set it to true
const queryable = layerConfig?.source?.featureInfo?.queryable;
return !!queryable;
return !!(queryable || queryable === undefined);
}

/**
Expand Down
Loading