diff --git a/src/models/layerMetadata/decorators/shp.decorator.ts b/src/models/layerMetadata/decorators/shp.decorator.ts index 1323023..0496690 100644 --- a/src/models/layerMetadata/decorators/shp.decorator.ts +++ b/src/models/layerMetadata/decorators/shp.decorator.ts @@ -3,9 +3,18 @@ import { LayerMetadata } from '../index'; const shpMappingMetadataKey = Symbol('shpmapping'); +export enum TsTypes { + STRING = 'string', + BOOLEAN = 'boolean', + DATE = 'Date', + NUMBER = 'number', + OBJECT = 'object', +} + export interface IShpMapping { shpFile: ShapeFileType; valuePath: string; + mappingType: TsTypes; } export enum ShapeFileType { diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index ce3e82b..2f64f24 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -1,5 +1,5 @@ export * from './layerMetadata'; export * from './layerMetadata-StatusFields'; -export { IShpMapping, ShapeFileType } from './decorators/shp.decorator'; +export { IShpMapping, ShapeFileType, TsTypes } from './decorators/shp.decorator'; export { IPYCSWMapping } from './decorators/csw.decorator'; diff --git a/src/models/layerMetadata/layerMetadata.ts b/src/models/layerMetadata/layerMetadata.ts index 41a3467..2e99b0d 100644 --- a/src/models/layerMetadata/layerMetadata.ts +++ b/src/models/layerMetadata/layerMetadata.ts @@ -1,6 +1,6 @@ import { GeoJSON } from 'geojson'; import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/csw.decorator'; -import { getShpMapping, IShpMapping, ShapeFileType, shpMapping } from './decorators/shp.decorator'; +import { getShpMapping, IShpMapping, ShapeFileType, shpMapping, TsTypes } from './decorators/shp.decorator'; import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/catalogDB.decorator'; export interface ILayerMetadata { @@ -57,6 +57,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Source', + mappingType: TsTypes.STRING, }) public source?: string = undefined; @@ -79,6 +80,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.SourceName', + mappingType: TsTypes.STRING, }) public sourceName?: string = undefined; @@ -101,6 +103,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.UpdateDate', + mappingType: TsTypes.DATE, }) public updateDate?: Date = undefined; @@ -123,6 +126,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Resolution', + mappingType: TsTypes.NUMBER, }) public resolution?: number = undefined; @@ -146,6 +150,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Ep90', + mappingType: TsTypes.NUMBER, }) public ep90?: number = undefined; @@ -168,6 +173,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.SensorType', + mappingType: TsTypes.STRING, }) public sensorType?: SensorType = undefined; @@ -191,6 +197,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Rms', + mappingType: TsTypes.NUMBER, }) public rms?: number = undefined; @@ -214,6 +221,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Scale', + mappingType: TsTypes.STRING, }) public scale?: string = undefined; @@ -237,6 +245,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].properties.Dsc', + mappingType: TsTypes.STRING, }) public dsc?: string = undefined; @@ -260,6 +269,7 @@ export class LayerMetadata implements ILayerMetadata { @shpMapping({ shpFile: ShapeFileType.SHAPE_METADATA, valuePath: 'features[0].geometry', + mappingType: TsTypes.OBJECT, }) public geometry?: GeoJSON = undefined; diff --git a/tests/unit/layerMetadata.spec.ts b/tests/unit/layerMetadata.spec.ts index d963934..a2eaa60 100644 --- a/tests/unit/layerMetadata.spec.ts +++ b/tests/unit/layerMetadata.spec.ts @@ -23,6 +23,7 @@ describe('LayerMetadata class static methods', () => { expect(shpMapping).toHaveProperty('shpFile'); expect(shpMapping).toHaveProperty('valuePath'); + expect(shpMapping).toHaveProperty('mappingType'); }); it('getShpMapping(): NOT mapped to SHAPE prop', () => { @@ -49,6 +50,7 @@ describe('LayerMetadata class static methods', () => { expect(shpMappings[0]).toHaveProperty('prop'); expect(shpMappings[0]).toHaveProperty('shpFile'); expect(shpMappings[0]).toHaveProperty('valuePath'); + expect(shpMappings[0]).toHaveProperty('mappingType'); }); it('getCatalogDbMapping(): mapped to DATABASE prop', () => {