Skip to content

Commit

Permalink
Fix vector tile layers and improve style handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMuehlhauserNRCan committed Feb 21, 2025
1 parent 76174a8 commit 3f3f482
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export class VectorTilesLayerEntryConfig extends TileLayerEntryConfig {

if (!this.source) this.source = {};
if (!this.source.dataAccessPath) this.source.dataAccessPath = this.geoviewLayerConfig.metadataAccessPath;
if (!this.source.dataAccessPath!.toLowerCase().endsWith('.pbf'))
if (!this.source.dataAccessPath!.toLowerCase().endsWith('.pbf')) {
this.source.dataAccessPath = this.source.dataAccessPath!.endsWith('/')
? `${this.source.dataAccessPath}${this.layerId}`
: `${this.source.dataAccessPath}/${this.layerId}`;
? `${this.source.dataAccessPath}tile/{z}/{y}/{x}.pbf`
: `${this.source.dataAccessPath}/tile/{z}/{y}/{x}.pbf`;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,18 @@ export class VectorTiles extends AbstractGeoViewRaster {
// TODO: Refactor - Layers refactoring. What is this doing? See how we can do this in the new layers. Can it be done before?
const resolutions = sourceOptions.tileGrid.getResolutions();

if (this.metadata?.defaultStyles)
applyStyle(olLayer, `${this.metadataAccessPath}${this.metadata.defaultStyles}/root.json`, {
let appliedStyle = layerConfig.styleUrl || (this.metadata?.defaultStyles as string);

if (appliedStyle) {
if (!appliedStyle.endsWith('/root.json')) appliedStyle = `${appliedStyle}/root.json`;

applyStyle(olLayer, appliedStyle, {
resolutions: resolutions?.length ? resolutions : [],
}).catch((error) => {
// Log
logger.logPromiseFailed('applyStyle in processOneLayerEntry in VectorTiles', error);
});
}

return Promise.resolve(olLayer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { VectorTilesLayerEntryConfig } from '@/core/utils/config/validation-clas
import { featureInfoGetFieldType } from '@/geo/layer/gv-layers/utils';
import { AbstractGVVectorTile } from '@/geo/layer/gv-layers/vector/abstract-gv-vector-tile';
import { TypeOutfieldsType } from '@/api/config/types/map-schema-types';
import { logger } from '@/core/utils/logger';

/**
* Manages a Vector Tiles layer.
Expand All @@ -34,10 +33,6 @@ export class GVVectorTiles extends AbstractGVVectorTile {
// Create and set the OpenLayer layer
const declutter = true;
this.olLayer = new VectorTileLayer({ ...tileLayerOptions, declutter });

if (layerConfig.styleUrl) {
this.changeStyle(layerConfig.styleUrl).catch((err) => logger.logError(err));
}
}

/**
Expand Down

0 comments on commit 3f3f482

Please sign in to comment.