From bcc85923023c851f8019cbff8d67baccc7f07bd4 Mon Sep 17 00:00:00 2001 From: Alex Lebinson Date: Thu, 2 Dec 2021 10:31:36 +0200 Subject: [PATCH] feat: dem full entity defs (#108) * feat: dem full entity defs * chore: lint super call --- .../decorators/property/tsTypes.decorator.ts | 25 + src/models/layerMetadata/layerDEMMetadata.ts | 1014 +++++++++++++++++ .../layerMetadata/pycswDEMCatalogRecord.ts | 306 +++++ .../layerMetadata/pycswLayerCatalogRecord.ts | 4 - src/models/pycsw/coreEnums.ts | 42 + 5 files changed, 1387 insertions(+), 4 deletions(-) create mode 100644 src/models/layerMetadata/layerDEMMetadata.ts create mode 100644 src/models/layerMetadata/pycswDEMCatalogRecord.ts diff --git a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts index 8fdff5f..bb24a53 100644 --- a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts +++ b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts @@ -65,6 +65,31 @@ export const TsTypes: Record = { type: PropertiesTypes.ENUM, importFromPackage: '@map-colonies/mc-model-types', }, + VERTICAL_DATUM: { + value: 'VerticalDatum', + type: PropertiesTypes.ENUM, + importFromPackage: '@map-colonies/mc-model-types', + }, + UNITS: { + value: 'Units', + type: PropertiesTypes.ENUM, + importFromPackage: '@map-colonies/mc-model-types', + }, + UNDULATION_MODEL: { + value: 'UndulationModel', + type: PropertiesTypes.ENUM, + importFromPackage: '@map-colonies/mc-model-types', + }, + DATATYPE: { + value: 'DataType', + type: PropertiesTypes.ENUM, + importFromPackage: '@map-colonies/mc-model-types', + }, + NO_DATA_VALUE: { + value: 'NoDataValue', + type: PropertiesTypes.ENUM, + importFromPackage: '@map-colonies/mc-model-types', + }, FIELDCATEGORY: { value: 'FieldCategory', type: PropertiesTypes.ENUM, diff --git a/src/models/layerMetadata/layerDEMMetadata.ts b/src/models/layerMetadata/layerDEMMetadata.ts new file mode 100644 index 0000000..dc24c9e --- /dev/null +++ b/src/models/layerMetadata/layerDEMMetadata.ts @@ -0,0 +1,1014 @@ +import { GeoJSON } from 'geojson'; +import { IPropCatalogDBMapping } from '../common/interfaces/propCatalogDBMapping.interface'; +import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { + FieldCategory, + fieldConfig, + getFieldConfig, + IFieldConfigInfo, + IPropFieldConfigInfo, +} from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { DataType, NoDataValue, RecordType, UndulationModel, Units, VerticalDatum } from '../pycsw/coreEnums'; +import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; +import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { getCatalogDBMapping, ICatalogDBMapping, catalogDB } from './decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; +import { ProductType, SensorType } from './enums'; + +export interface ILayerMetadata { + resolutionDegree: number | undefined; + resolutionMeter: number | undefined; + absoluteAccuracyLEP90: number | undefined; + relativeAccuracyLEP90: number | undefined; + layerPolygonParts: GeoJSON | undefined; + productBoundingBox: string | undefined; + heightRangeFrom: number | undefined; + heightRangeTo: number | undefined; + verticalDatum: VerticalDatum | undefined; + geographicArea: string | undefined; + undulationModel: UndulationModel | undefined; + dataType: DataType | undefined; + noDataValue: NoDataValue | undefined; +} + +export interface IPropPYCSWMapping extends IPYCSWMapping { + prop: string; +} + +export class LayerDEMMetadata implements ILayerMetadata, IMetadataCommonModel { + //#region COMMON FIELDS + //#region COMMON: type + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:type', + queryableField: 'mc:type', + pycswField: 'pycsw:Type', + }) + @catalogDB({ + column: { + name: 'type', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.RECORDTYPE, + }) + @graphql({ + nullable: true, + }) + //#endregion + public type: RecordType | undefined = RecordType.RECORD_DEM; + + //#region COMMON: classification + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:classification', + queryableField: 'mc:classification', + pycswField: 'pycsw:Classification', + }) + @catalogDB({ + column: { + name: 'classification', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public classification: string | undefined = undefined; + + //#region COMMON: productName + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:productName', + queryableField: 'mc:productName', + pycswField: 'pycsw:Title', + }) + @catalogDB({ + column: { + name: 'product_name', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public productName: string | undefined = undefined; + + //#region COMMON: description + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:description', + queryableField: 'mc:description', + pycswField: 'pycsw:Abstract', + }) + @catalogDB({ + column: { + name: 'description', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public description: string | undefined = undefined; + + //#region COMMON: srsId + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:SRS', + queryableField: 'mc:SRS', + pycswField: 'pycsw:CRS', + }) + @catalogDB({ + column: { + name: 'srs', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + }) + //#endregion + public srsId: string | undefined = undefined; + + //#region COMMON: srsName + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:SRSName', + queryableField: 'mc:SRSName', + pycswField: 'pycsw:CRSName', + }) + @catalogDB({ + column: { + name: 'srs_name', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public srsName: string | undefined = undefined; + + //#region COMMON: producerName + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:producerName', + queryableField: 'mc:producerName', + pycswField: 'pycsw:Creator', + }) + @catalogDB({ + column: { + name: 'producer_name', + type: 'text', + default: 'IDFMU', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public producerName: string | undefined = undefined; + + //#region COMMON: updateDate + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:updateDateUTC', + queryableField: 'mc:updateDateUTC', + pycswField: 'pycsw:UpdateDate', + }) + @catalogDB({ + column: { + name: 'update_date', + type: 'timestamp without time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public updateDate: Date | undefined = undefined; + + //#region COMMON: sourceDateStart + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:imagingTimeBeginUTC', + queryableField: 'mc:imagingTimeBeginUTC', + pycswField: 'pycsw:TempExtent_begin', + }) + @catalogDB({ + column: { + name: 'source_start_date', + type: 'timestamp without time zone', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.sourceDateStart.max'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.sourceDateStart.max', + valueType: 'field', + max: 'sourceDateEnd', + }, + ], + }) + //#endregion + public sourceDateStart: Date | undefined = undefined; + + //#region COMMON: sourceDateEnd + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:imagingTimeEndUTC', + queryableField: 'mc:imagingTimeEndUTC', + pycswField: 'pycsw:TempExtent_end', + }) + @catalogDB({ + column: { + name: 'source_end_date', + type: 'timestamp without time zone', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public sourceDateEnd: Date | undefined = undefined; + + //#region COMMON: sensorType //sensors + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:sensors', + queryableField: 'mc:sensors', + pycswField: 'pycsw:sensorType', + }) + @catalogDB({ + column: { + name: 'sensor_type', + type: 'text', + nullable: true, + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @tsTypes({ + mappingType: TsTypes.SENSORTYPE_ARRAY, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public sensorType: SensorType[] | undefined = undefined; + + //#region COMMON: region + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:region', + queryableField: 'mc:region', + pycswField: 'pycsw:Region', + }) + @catalogDB({ + column: { + name: 'region', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public region: string | undefined = undefined; + + //#region COMMON: productId + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:productId', + queryableField: 'mc:productId', + pycswField: 'pycsw:ProductId', + }) + @catalogDB({ + column: { + name: 'product_id', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public productId: string | undefined = 'UNKNOWN'; + + //#region COMMON: productType + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:productType', + queryableField: 'mc:productType', + pycswField: 'pycsw:ProductType', + }) + @catalogDB({ + column: { + name: 'product_type', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.PRODUCTTYPE, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public productType: ProductType | undefined = undefined; + + //#region COMMON: footprint + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:footprint', + queryableField: 'mc:footprint', + pycswField: 'pycsw:footprint', + }) + @catalogDB({ + column: { + name: 'footprint_geojson', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.OBJECT, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + isCreationEssential: true, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.footprint.json', + json: true, + }, + ], + }) + //#endregion + public footprint: GeoJSON | undefined = undefined; + //#endregion + + //#region DEM SPECIFIC FIELDS + //#region DEM: absoluteAccuracyLEP90 + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:absoluteAccuracyLEP90', + queryableField: 'mc:absoluteAccuracyLEP90', + pycswField: 'pycsw:absoluteAccuracyLEP90', + }) + @catalogDB({ + column: { + name: 'absolute_accuracy_lep_90', + type: 'real', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public absoluteAccuracyLEP90: number | undefined = undefined; + + //#region DEM: relativeAccuracyLEP90 + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:relativeAccuracyLEP90', + queryableField: 'mc:relativeAccuracyLEP90', + pycswField: 'pycsw:relativeAccuracyLEP90', + }) + @catalogDB({ + column: { + name: 'relative_accuracy_lep_90', + type: 'real', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public relativeAccuracyLEP90: number | undefined = undefined; + + //#region DEM: resolutionDegree + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:resolutionDeg', + queryableField: 'mc:resolutionDeg', + pycswField: 'pycsw:resolutionDeg', + }) + @catalogDB({ + column: { + name: 'resolution_degree', + type: 'real', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-field-tooltip.resolutionDegree.min', 'info-field-tooltip.resolutionDegree.max'], + validation: [ + { + errorMsgCode: 'validation-field.resolutionDegree.min', + valueType: 'value', + min: 0.00000009, + }, + { + errorMsgCode: 'validation-field.resolutionDegree.max', + valueType: 'value', + max: 0.072, + }, + ], + }) + //#endregion + public resolutionDegree: number | undefined = undefined; + + //#region DEM: resolutionMeter + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:resolutionMeter', + queryableField: 'mc:resolutionMeter', + pycswField: 'pycsw:resolutionMeter', + }) + @catalogDB({ + column: { + name: 'resolution_meter', + type: 'real', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.MAIN, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.resolutionMeter.min', 'info-field-tooltip.resolutionMeter.max'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.resolutionMeter.min', + valueType: 'value', + min: 0.01, + }, + { + errorMsgCode: 'validation-field.resolutionMeter.max', + valueType: 'value', + max: 8000, + }, + ], + }) + //#endregion + public resolutionMeter: number | undefined = undefined; + + //#region DEM: layerPolygonParts + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:layerPolygonParts', + queryableField: 'mc:layerPolygonParts', + pycswField: 'pycsw:layerPolygonParts', + }) + @catalogDB({ + column: { + name: 'layer_polygon_parts', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.OBJECT, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + isCreationEssential: true, + validation: [ + { + errorMsgCode: 'validation-field.layerPolygonParts.json', + json: true, + }, + ], + }) + //#endregion + public layerPolygonParts: GeoJSON | undefined = undefined; + + //#region DEM: productBoundingBox + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:productBBox', + queryableField: 'mc:productBBox', + pycswField: 'pycsw:productBBox', + }) + @catalogDB({ + column: { + name: 'product_bbox', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + isAutoGenerated: true, + }) + //#endregion + public productBoundingBox: string | undefined = undefined; + + //#region DEM: heightRangeFrom + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:heightRangeFrom', + queryableField: 'mc:heightRangeFrom', + pycswField: 'pycsw:heightRangeFrom', + }) + @catalogDB({ + column: { + name: 'height_range_from', + type: 'real', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.heightRangeFrom.max', 'info-field-tooltip.heightRangeFrom.min'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.heightRangeFrom.max', + valueType: 'field', + max: 'heightRangeTo', + }, + { + errorMsgCode: 'validation-field.heightRangeFrom.min', + valueType: 'value', + min: -500, + }, + { + errorMsgCode: 'validation-field.heightRangeFrom.max', + valueType: 'value', + max: 9000, + }, + ], + }) + //#endregion + public heightRangeFrom: number | undefined = undefined; + + //#region DEM: heightRangeTo + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:heightRangeTo', + queryableField: 'mc:heightRangeTo', + pycswField: 'pycsw:heightRangeTo', + }) + @catalogDB({ + column: { + name: 'height_range_to', + type: 'real', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NUMBER, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.heightRangeTo.max', 'info-field-tooltip.heightRangeTo.min'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + { + errorMsgCode: 'validation-field.heightRangeTo.min', + valueType: 'value', + min: -500, + }, + { + errorMsgCode: 'validation-field.heightRangeTo.max', + valueType: 'value', + max: 9000, + }, + ], + }) + //#endregion + public heightRangeTo: number | undefined = undefined; + + //#region DEM: verticalDatum + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:verticalDatum', + queryableField: 'mc:verticalDatum', + pycswField: 'pycsw:verticalDatum', + }) + @catalogDB({ + column: { + name: 'vertical_datum', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.VERTICAL_DATUM, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + infoMsgCode: ['info-general-tooltip.required'], + validation: [ + { + errorMsgCode: 'validation-general.required', + required: true, + }, + ], + }) + //#endregion + public verticalDatum: VerticalDatum | undefined; + + //#region DEM: units + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:units', + queryableField: 'mc:units', + pycswField: 'pycsw:units', + }) + @catalogDB({ + column: { + name: 'units', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.UNITS, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + }) + //#endregion + public units: Units | undefined; + + //#region DEM: geographicArea + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:geographicArea', + queryableField: 'mc:geographicArea', + pycswField: 'pycsw:geographicArea', + }) + @catalogDB({ + column: { + name: 'geographic_area', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + //#endregion + public geographicArea: string | undefined = undefined; + + //#region DEM: undulationModel + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:undulationModel', + queryableField: 'mc:undulationModel', + pycswField: 'pycsw:undulationModel', + }) + @catalogDB({ + column: { + name: 'undulation_model', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.UNDULATION_MODEL, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + }) + //#endregion + public undulationModel: UndulationModel | undefined; + + //#region DEM: dataType + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:dataType', + queryableField: 'mc:dataType', + pycswField: 'pycsw:dataType', + }) + @catalogDB({ + column: { + name: 'data_type', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.DATATYPE, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public dataType: DataType | undefined; + + //#region DEM: noDataValue + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:noDataValue', + queryableField: 'mc:noDataValue', + pycswField: 'pycsw:noDataValue', + }) + @catalogDB({ + column: { + name: 'no_data_value', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.NO_DATA_VALUE, + }) + @graphql({ + nullable: false, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + }) + //#endregion + public noDataValue: NoDataValue | undefined; + //#endregion + + public static getPyCSWMapping(prop: string): IPYCSWMapping | undefined { + return getPyCSWMapping(new LayerDEMMetadata(), prop); + } + + public static getCatalogDBMapping(prop: string): ICatalogDBMapping | undefined { + return getCatalogDBMapping(new LayerDEMMetadata(), prop); + } + + public static getFieldConfig(prop: string): IFieldConfigInfo | undefined { + return getFieldConfig(new LayerDEMMetadata(), prop); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + const ret = []; + const layer = new LayerDEMMetadata(); + for (const prop in layer) { + const pycswMap = getPyCSWMapping(layer, prop); + if (pycswMap) { + ret.push({ + prop: prop, + ...pycswMap, + }); + } + } + return ret; + } + + public static getCatalogDBMappings(): IPropCatalogDBMapping[] { + const ret = []; + const layer = new LayerDEMMetadata(); + for (const prop in layer) { + const catalogDbMap = getCatalogDBMapping(layer, prop); + const tsTypesMap = getTsTypesMapping(layer, prop); + if (catalogDbMap && tsTypesMap) { + ret.push({ + prop: prop, + ...catalogDbMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public static getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new LayerDEMMetadata(); + for (const prop in layer) { + const fieldConfigMap = getFieldConfig(layer, prop); + if (fieldConfigMap) { + ret.push({ + prop: prop, + ...fieldConfigMap, + }); + } + } + return ret; + } +} diff --git a/src/models/layerMetadata/pycswDEMCatalogRecord.ts b/src/models/layerMetadata/pycswDEMCatalogRecord.ts new file mode 100644 index 0000000..5e8714e --- /dev/null +++ b/src/models/layerMetadata/pycswDEMCatalogRecord.ts @@ -0,0 +1,306 @@ +import { IPycswCoreModel } from '../pycsw/interfaces/pycswCoreModel'; +import { IPropCatalogDBMapping } from '../common/interfaces/propCatalogDBMapping.interface'; +import { IOrmCatalog } from '../common/interfaces/ormCatalog.interface'; +import { graphql } from '../common/decorators/graphQL/graphql.decorator'; +import { graphqlClass } from '../common/decorators/graphQL/classGraphql.decorator'; +import { getFieldConfigClassInfo } from '../common/decorators/fieldConfig/classFieldConfig.decorator'; +import { FieldCategory, fieldConfig, getFieldConfig, IPropFieldConfigInfo } from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { catalogDB, getCatalogDBMapping } from './decorators/property/catalogDB.decorator'; +import { getTsTypesMapping, TsTypes, tsTypes } from './decorators/property/tsTypes.decorator'; +import { getCatalogDBEntityMapping, catalogDBEntity, ICatalogDBEntityMapping } from './decorators/class/catalogDBEntity.decorator'; +import { getPyCSWMapping, pycsw } from './decorators/property/csw.decorator'; +import { LayerDEMMetadata, IPropPYCSWMapping } from './LayerDEMMetadata'; +import { Link } from './link'; + +@catalogDBEntity({ + table: 'records', + className: 'Metadata', +}) +@graphqlClass({ alias: 'LayerDEMRecord' }) +export class PycswDEMCatalogRecord extends LayerDEMMetadata implements IPycswCoreModel, IOrmCatalog { + //#region CORE: id + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:id', + queryableField: 'mc:id', + pycswField: 'pycsw:Identifier', + }) + @catalogDB({ + column: { + name: 'identifier', + type: 'text', + nullable: false, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql() + @fieldConfig({ + category: FieldCategory.MAIN, + isAutoGenerated: true, + }) + //#endregion + public id: string | undefined = 'UNKNOWN'; + + //#region CORE: typename + @catalogDB({ + column: { + name: 'typename', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public typeName: string | undefined = 'mc:MCDEMRecord'; + + //#region CORE: schema + @catalogDB({ + column: { + name: 'schema', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public schema: string | undefined = 'mc_dem'; + + //#region CORE: mdsource + @catalogDB({ + column: { + name: 'mdsource', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public mdSource: string | undefined = undefined; + + //#region CORE: xml + @catalogDB({ + column: { + name: 'xml', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public xml: string | undefined = undefined; + + //#region CORE: anyText + @catalogDB({ + column: { + name: 'anytext', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public anyText: string | undefined = undefined; + + //#region CORE: insertDate + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:insertDate', + queryableField: 'mc:insertDate', + pycswField: 'pycsw:InsertDate', + }) + @catalogDB({ + column: { + name: 'insert_date', + type: 'timestamp without time zone', + }, + }) + @tsTypes({ + mappingType: TsTypes.DATE, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isAutoGenerated: true, + }) + //#endregion + public insertDate: Date | undefined = undefined; + + //#region CORE: wktGeometry + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:boundingBox', + queryableField: 'mc:boundingBox', + pycswField: 'pycsw:BoundingBox', + }) + @catalogDB({ + column: { + name: 'wkt_geometry', + type: 'text', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @fieldConfig({ + category: FieldCategory.GEO_INFO, + }) + @graphql({ + nullable: true, + }) + //#endregion + public wktGeometry: string | undefined = undefined; + + //#region CORE: wkbGeometry (DD trigger populated) + @catalogDB({ + column: { + name: 'wkb_geometry', + type: 'geometry', + spatialFeatureType: 'Geometry', + srid: 4326, + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public wkbGeometry: string | undefined = undefined; + + //#region CORE: keywords + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:keywords', + queryableField: 'mc:keywords', + pycswField: 'pycsw:Keywords', + }) + @catalogDB({ + column: { + name: 'keywords', + type: 'text', + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + isManuallyEditable: true, + }) + //#endregion + public keywords: string | undefined = undefined; + + //#region CORE: anyTextTsvector + @catalogDB({ + column: { + name: 'anytext_tsvector', + type: 'tsvector', + nullable: true, + }, + }) + @tsTypes({ + mappingType: TsTypes.STRING, + }) + //#endregion + public anyTextTsvector: string | undefined = undefined; + + //#region CORE: links + @pycsw({ + profile: 'mc_dem', + xmlElement: 'mc:links', + queryableField: 'mc:links', + pycswField: 'pycsw:Links', + }) + @catalogDB({ + column: { + name: 'links', + type: 'text', + nullable: true, + }, + field: { + overrideType: TsTypes.STRING, + }, + }) + @tsTypes({ + mappingType: TsTypes.LINKS, + }) + @graphql({ + nullable: true, + }) + @fieldConfig({ + category: FieldCategory.GENERAL, + complexType: TsTypes.LINKS, + isAutoGenerated: true, + }) + //#endregion + public links: Link[] | undefined = undefined; + + public constructor() { + // eslint-disable-next-line + super(); + } + + public static getPyCSWMappings(): IPropPYCSWMapping[] { + const ret = []; + const layer = new PycswDEMCatalogRecord(); + for (const prop in layer) { + const pycswMap = getPyCSWMapping(layer, prop); + if (pycswMap) { + ret.push({ + prop: prop, + ...pycswMap, + }); + } + } + return ret; + } + + public static getFieldConfigs(): IPropFieldConfigInfo[] { + const ret = []; + const layer = new PycswDEMCatalogRecord(); + for (const prop in layer) { + const fieldConfigMap = getFieldConfig(layer, prop); + if (fieldConfigMap) { + const fieldConfig = { prop: prop, ...fieldConfigMap }; + if (fieldConfigMap.complexType) { + fieldConfig.subFields = getFieldConfigClassInfo(fieldConfigMap.complexType.value); + } + ret.push(fieldConfig); + } + } + return ret; + } + + public getORMCatalogMappings(): IPropCatalogDBMapping[] { + const ret = []; + + for (const prop in this) { + const catalogDbMap = getCatalogDBMapping(this, prop); + const tsTypesMap = getTsTypesMapping(this, prop); + if (catalogDbMap && tsTypesMap) { + ret.push({ + prop: prop, + ...catalogDbMap, + ...tsTypesMap, + }); + } + } + return ret; + } + + public getORMCatalogEntityMappings(): ICatalogDBEntityMapping { + return getCatalogDBEntityMapping(PycswDEMCatalogRecord); + } +} diff --git a/src/models/layerMetadata/pycswLayerCatalogRecord.ts b/src/models/layerMetadata/pycswLayerCatalogRecord.ts index fc278d5..0065cf5 100644 --- a/src/models/layerMetadata/pycswLayerCatalogRecord.ts +++ b/src/models/layerMetadata/pycswLayerCatalogRecord.ts @@ -128,10 +128,6 @@ export class PycswLayerCatalogRecord extends LayerMetadata implements IPycswCore @graphql({ nullable: true, }) - @fieldConfig({ - category: FieldCategory.GENERAL, - isAutoGenerated: true, - }) //#endregion public insertDate: Date | undefined = undefined; diff --git a/src/models/pycsw/coreEnums.ts b/src/models/pycsw/coreEnums.ts index df1c7c5..8dd68e0 100644 --- a/src/models/pycsw/coreEnums.ts +++ b/src/models/pycsw/coreEnums.ts @@ -1,5 +1,47 @@ export enum RecordType { RECORD_RASTER = 'RECORD_RASTER', RECORD_3D = 'RECORD_3D', + RECORD_DEM = 'RECORD_DEM', RECORD_ALL = 'RECORD_ALL', } + +export enum VerticalDatum { + WGS_1984 = 'WGS 1984', + WGS_1972 = 'WGS 1972', + PULKOVO_1942 = 'Pulkovo 1942', + PALESTINE_1923 = 'Palestine 1923', + MSL_HEIGHT = 'MSL Height', + ISRAEL = 'Israel', + ED_1950_IDF = 'ED 1950 IDF', +} + +export enum Units { + METER = 'METER', + DD = 'DD', + DMS = 'DMS', + ARC_SECONDS = 'ARC_SECONDS', + UNKNOWN = 'UNKNOWN', +} + +export enum UndulationModel { + MSL_EGM96 = 'MSL EGM96', + MSL_EGM2008 = 'MSL EGM2008', + MSL_DMA10 = 'MSL DMA10', + ILUM = 'ILUM', +} + +export enum DataType { + FLOAT64 = 'FLOAT64', + FLOAT32 = 'FLOAT32', + FLOAT16 = 'FLOAT16', + INT64 = 'INT64', + INT32 = 'INT32', + INT16 = 'INT16', + INT8 = 'INT8', +} + +export enum NoDataValue { + NO_DATA_32768 = '-32768', + NO_DATA_326767 = '-326767', + NO_DATA_999 = '-999', +}