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

feat: added type to shape mapping #52

Merged
merged 3 commits into from
Apr 11, 2021
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
9 changes: 9 additions & 0 deletions src/models/layerMetadata/decorators/shp.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/models/layerMetadata/index.ts
Original file line number Diff line number Diff line change
@@ -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';
12 changes: 11 additions & 1 deletion src/models/layerMetadata/layerMetadata.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/layerMetadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down