Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…form/geoview into 2307-skelton
  • Loading branch information
kaminderpal committed Jun 28, 2024
2 parents 60681f6 + 91f4ad2 commit b9c7ccb
Show file tree
Hide file tree
Showing 14 changed files with 376 additions and 328 deletions.
619 changes: 343 additions & 276 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/geoview-basemap-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "Saleh Yassin",
"license": "MIT",
"dependencies": {
"geoview-core": "workspace:~0.1.0"
"geoview-core": "workspace:~1.0.0"
},
"devDependencies": {
"@babel/core": "^7.17.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/geoview-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geoview-core",
"version": "0.1.0",
"version": "1.0.0",
"description": "Lightweight viewer based on Open Layers and React for the Canadian Geospatial Platform",
"private": true,
"main": "src/app.tsx",
Expand Down Expand Up @@ -71,7 +71,7 @@
"linkifyjs": "^4.1.0",
"lodash": "^4.17.21",
"material-react-table": "^2.13.0",
"ol": "9.1.0",
"ol": "^9.2.4",
"ol-mapbox-style": "^12.2.1",
"proj4": "^2.7.5",
"prop-types": "^15.8.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/geoview-core/src/geo/layer/geometry/geometry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import VectorLayer from 'ol/layer/Vector';
import Feature, { FeatureLike } from 'ol/Feature';
import VectorSource, { Options as VectorSourceOptions } from 'ol/source/Vector';
import { Feature } from 'ol';
import { Geometry as OLGeometry, Circle, LineString, Point, Polygon } from 'ol/geom';
import { Coordinate } from 'ol/coordinate';
import { Fill, Stroke, Style, Icon } from 'ol/style';
Expand All @@ -22,7 +22,7 @@ import { TypeFeatureCircleStyle, TypeFeatureStyle, TypeIconStyle } from './geome
*/
interface FeatureCollection {
geometryGroupId: string;
vectorLayer: VectorLayer<VectorSource>;
vectorLayer: VectorLayer<Feature>;
vectorSource: VectorSource;
}

Expand Down Expand Up @@ -428,17 +428,17 @@ export class GeometryApi {
createGeometryGroup(
geometryGroupId: string,
options?: {
vectorLayerOptions?: VectorLayerOptions<VectorSource>;
vectorLayerOptions?: VectorLayerOptions<VectorSource<FeatureLike>>;
vectorSourceOptions?: VectorSourceOptions<Feature>;
}
): FeatureCollection {
const geometryGroupOptions = options || {};

let geometryGroup = this.getGeometryGroup(geometryGroupId);
if (!geometryGroup) {
const vectorSource = new VectorSource(geometryGroupOptions.vectorSourceOptions);
const vectorSource = new VectorSource<Feature>(geometryGroupOptions.vectorSourceOptions);

const vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer<Feature>({
...geometryGroupOptions.vectorLayerOptions,
source: vectorSource,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,16 @@ export class VectorTiles extends AbstractGeoViewRaster {
const requestResult = this.emitLayerRequesting({ config: layerConfig, source });

// If any response
let olLayer: VectorTileLayer | undefined;
let olLayer: VectorTileLayer<Feature> | undefined;
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as VectorTileLayer;
olLayer = requestResult[0] as VectorTileLayer<Feature>;
}

// If no olLayer was obtained
if (!olLayer) {
// We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
const tileLayerOptions: TileOptions<VectorTileSource> = { source };
const tileLayerOptions: TileOptions<VectorTileSource<Feature>> = { source };
// layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
if (layerConfig.initialSettings?.className !== undefined) tileLayerOptions.className = layerConfig.initialSettings.className;
if (layerConfig.initialSettings?.extent !== undefined) tileLayerOptions.extent = layerConfig.initialSettings.extent;
Expand Down Expand Up @@ -356,6 +356,6 @@ export class VectorTiles extends AbstractGeoViewRaster {
// GV Layers Refactoring - Obsolete (just should be removed?)
setVectorTileStyle(layerPath: string, styleUrl: string): Promise<unknown> {
// FIXME: Check if this should be removed or done somewhere else?
return applyStyle(this.getMapViewer().layer.getOLLayer(layerPath) as VectorTileLayer, styleUrl);
return applyStyle(this.getMapViewer().layer.getOLLayer(layerPath) as VectorTileLayer<Feature>, styleUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
* The layer entry configuration keeps a reference to the layer in the olLayer attribute.
*
* @param {VectorLayerEntryConfig} layerConfig The layer entry configuration used by the source.
* @param {VectorSource<Feature>} vectorSource The source configuration for the vector layer.
* @param {VectorSource} vectorSource The source configuration for the vector layer.
*
* @returns {VectorLayer<VectorSource>} The vector layer created.
* @returns {VectorLayer<Feature>} The vector layer created.
*/
// GV Layers Refactoring - Obsolete (this is bridging between config and layers, okay)
protected createVectorLayer(layerConfig: VectorLayerEntryConfig, vectorSource: VectorSource<Feature>): VectorLayer<VectorSource> {
protected createVectorLayer(layerConfig: VectorLayerEntryConfig, vectorSource: VectorSource): VectorLayer<Feature> {
// TODO: remove link to language, layer should be created in one language and recreated if needed to change
const language = AppEventProcessor.getDisplayLanguage(this.mapId);

Expand All @@ -322,10 +322,10 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
const requestResult = this.emitLayerRequesting({ config: layerConfig, source: vectorSource });

// If any response
let olLayer: VectorLayer<VectorSource> | undefined;
let olLayer: VectorLayer<Feature> | undefined;
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as VectorLayer<VectorSource>;
olLayer = requestResult[0] as VectorLayer<Feature>;
}

// If no olLayer was obtained
Expand Down Expand Up @@ -380,7 +380,7 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
try {
// Get the layer config in a loaded phase
const layerConfig = this.getLayerConfig(layerPath) as VectorLayerEntryConfig;
const layer = this.getOLLayer(layerPath) as VectorLayer<VectorSource>;
const layer = this.getOLLayer(layerPath) as VectorLayer<Feature>;
const features = layer.getSource()!.getFeatures();
const arrayOfFeatureInfoEntries = await this.formatFeatureInfoResult(features, layerConfig);
return arrayOfFeatureInfoEntries;
Expand Down Expand Up @@ -467,7 +467,7 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
*/
// GV Layers Refactoring - Obsolete (in layers)
override getBounds(layerPath: string): Extent | undefined {
const layer = this.getOLLayer(layerPath) as VectorLayer<VectorSource> | undefined;
const layer = this.getOLLayer(layerPath) as VectorLayer<Feature> | undefined;
const layerBounds = layer?.getSource()?.getExtent();

// Return the calculated layer bounds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import VectorTile from 'ol/source/VectorTile';
import BaseVectorLayer from 'ol/layer/BaseVector';
import VectorTileLayer from 'ol/layer/VectorTile';
import Feature from 'ol/Feature';
import { Extent } from 'ol/extent';

import { AbstractGVLayer } from '../abstract-gv-layer';
Expand All @@ -10,15 +11,15 @@ import { AbstractGVLayer } from '../abstract-gv-layer';
export abstract class AbstractGVVectorTile extends AbstractGVLayer {
/**
* Overrides the get of the OpenLayers Layer
* @returns {BaseVectorLayer} The OpenLayers Layer
* @returns {VectorTileLayer<Feature>} The OpenLayers Layer
*/
// Disabling 'any', because too many renderer types in OpenLayers
// eslint-disable-next-line @typescript-eslint/no-explicit-any
override getOLLayer(): BaseVectorLayer<VectorTile, any> {
override getOLLayer(): VectorTileLayer<Feature> {
// Call parent and cast
// Disabling 'any', because too many renderer types in OpenLayers
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return super.getOLLayer() as BaseVectorLayer<VectorTile, any>;
return super.getOLLayer() as VectorTileLayer<Feature>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import BaseLayer from 'ol/layer/Base';
import BaseVectorLayer from 'ol/layer/BaseVector';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import { Options as VectorLayerOptions } from 'ol/layer/VectorImage';
Expand Down Expand Up @@ -29,7 +28,7 @@ export abstract class AbstractGVVector extends AbstractGVLayer {
* Constructs a GeoView Vector layer to manage an OpenLayer layer.
* @param {string} mapId - The map id
* @param {VectorSource} olSource - The OpenLayer source.
* @param {AbstractBaseLayerEntryConfig} layerConfig - The layer configuration.
* @param {VectorLayerEntryConfig} layerConfig - The layer configuration.
*/
protected constructor(mapId: string, olSource: VectorSource, layerConfig: VectorLayerEntryConfig) {
super(mapId, olSource, layerConfig);
Expand Down Expand Up @@ -65,15 +64,15 @@ export abstract class AbstractGVVector extends AbstractGVLayer {

/**
* Overrides the get of the OpenLayers Layer
* @returns {BaseVectorLayer<VectorSource, any>} The OpenLayers Layer
* @returns {VectorLayer<Feature>} The OpenLayers Layer
*/
// Disabling 'any', because too many renderer types in OpenLayers
// eslint-disable-next-line @typescript-eslint/no-explicit-any
override getOLLayer(): BaseVectorLayer<VectorSource, any> {
override getOLLayer(): VectorLayer<Feature> {
// Call parent and cast
// Disabling 'any', because too many renderer types in OpenLayers
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return super.getOLLayer() as BaseVectorLayer<VectorSource, any>;
return super.getOLLayer() as VectorLayer<Feature>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { VectorImage } from 'ol/layer';
import VectorSource from 'ol/source/Vector';

import { EsriFeatureLayerEntryConfig } from '@/core/utils/config/validation-classes/vector-validation-classes/esri-feature-layer-entry-config';
Expand All @@ -23,15 +22,6 @@ export class GVEsriFeature extends AbstractGVVector {
super(mapId, olSource, layerConfig);
}

/**
* Overrides the get of the OpenLayers Layer
* @returns {VectorImage<VectorSource>} The OpenLayers Layer
*/
override getOLLayer(): VectorImage<VectorSource> {
// Call parent and cast
return super.getOLLayer() as VectorImage<VectorSource>;
}

/**
* Overrides the get of the layer configuration associated with the layer.
* @returns {EsriFeatureLayerEntryConfig} The layer configuration or undefined if not found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ export class GVVectorTiles extends AbstractGVVectorTile {
this.olLayer = new VectorTileLayer({ ...tileLayerOptions });
}

/**
* Overrides the get of the OpenLayers Layer
* @returns {VectorTileLayer} The OpenLayers Layer
*/
override getOLLayer(): VectorTileLayer {
// Call parent and cast
return super.getOLLayer() as VectorTileLayer;
}

/**
* Overrides the get of the layer configuration associated with the layer.
* @returns {VectorTilesLayerEntryConfig} The layer configuration or undefined if not found.
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/geo/map/feature-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FeatureHighlight {

/** The hidden layer to display animations. */
// GV It's public, to save an eslint warning, because even if it's not read in this class, it's actually important to instanciate per OpenLayer design.
overlayLayer: VectorLayer<VectorSource>;
overlayLayer: VectorLayer<Feature>;

/** The fill for the highlight */
#highlightColor = 'black';
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-geochart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"lodash": "^4.17.21",
"geoview-core": "workspace:~0.1.0",
"geoview-core": "workspace:~1.0.0",
"geochart": "Canadian-Geospatial-Platform/geochart#develop",
"@mui/material": "^5.15.11"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/geoview-swiper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"author": "Saleh Yassin",
"license": "MIT",
"dependencies": {
"geoview-core": "workspace:~0.1.0",
"geoview-core": "workspace:~1.0.0",
"lodash": "^4.17.21",
"ol": "9.1.0",
"ol": "^9.2.4",
"react-draggable": "^4.4.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-time-slider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "Damon Ulmi",
"license": "MIT",
"dependencies": {
"geoview-core": "workspace:~0.1.0",
"geoview-core": "workspace:~1.0.0",
"@mui/material": "^5.15.11"
},
"devDependencies": {
Expand Down

0 comments on commit b9c7ccb

Please sign in to comment.