Skip to content
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
33 changes: 22 additions & 11 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,33 @@
}
},
"storageExplorer": {
"sourceDir": ""
"sourceDir": "",
"displayNameDir": "layerSources",
"validFileExtensions": ["tif"]
},
"jobnik": {
"baseUrl": "http://localhost:3000"
},
"application": {
"validation": {
"blockSize": 256,
"compression": "LZW",
"resolutionDegree": { "min": 0.00000009060870470168063430786, "max": 0.08982 },
"resolutionMeter": { "min": 0.01, "max": 10000 },
"supportedSrsIds": [
4326, 32601, 32602, 32603, 32604, 32605, 32606, 32607, 32608, 32609, 32610, 32611, 32612, 32613, 32614, 32615, 32616, 32617, 32618, 32619,
32620, 32621, 32622, 32623, 32624, 32625, 32626, 32627, 32628, 32629, 32630, 32631, 32632, 32633, 32634, 32635, 32636, 32637, 32638, 32639,
32640, 32641, 32642, 32643, 32644, 32645, 32646, 32647, 32648, 32649, 32650, 32651, 32652, 32653, 32654, 32655, 32656, 32657, 32658, 32659,
32660, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709, 32710, 32711, 32712, 32713, 32714, 32715, 32716, 32717, 32718, 32719,
32720, 32721, 32722, 32723, 32724, 32725, 32726, 32727, 32728, 32729, 32730, 32731, 32732, 32733, 32734, 32735, 32736, 32737, 32738, 32739,
32740, 32741, 32742, 32743, 32744, 32745, 32746, 32747, 32748, 32749, 32750, 32751, 32752, 32753, 32754, 32755, 32756, 32757, 32758, 32759,
32760
]
},
"defaultGeographicSrsId": 4326,
"defaultProjectedSrsId": 3395,
"supportedFormatsMap": {
"geotiff": "gtiff"
},
"supportedSrsIds": [
4326, 32601, 32602, 32603, 32604, 32605, 32606, 32607, 32608, 32609, 32610, 32611, 32612, 32613, 32614, 32615, 32616, 32617, 32618, 32619,
32620, 32621, 32622, 32623, 32624, 32625, 32626, 32627, 32628, 32629, 32630, 32631, 32632, 32633, 32634, 32635, 32636, 32637, 32638, 32639,
32640, 32641, 32642, 32643, 32644, 32645, 32646, 32647, 32648, 32649, 32650, 32651, 32652, 32653, 32654, 32655, 32656, 32657, 32658, 32659,
32660, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709, 32710, 32711, 32712, 32713, 32714, 32715, 32716, 32717, 32718, 32719,
32720, 32721, 32722, 32723, 32724, 32725, 32726, 32727, 32728, 32729, 32730, 32731, 32732, 32733, 32734, 32735, 32736, 32737, 32738, 32739,
32740, 32741, 32742, 32743, 32744, 32745, 32746, 32747, 32748, 32749, 32750, 32751, 32752, 32753, 32754, 32755, 32756, 32757, 32758, 32759,
32760
]
}
}
}
191 changes: 99 additions & 92 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"@map-colonies/config": "^4.0.1",
"@map-colonies/error-express-handler": "^4.0.0",
"@map-colonies/error-types": "^1.3.1",
"@map-colonies/express-access-log-middleware": "^4.0.0",
"@map-colonies/js-logger": "^4.0.0",
"@map-colonies/express-access-log-middleware": "^4.1.0",
"@map-colonies/js-logger": "^5.0.0",
"@map-colonies/openapi-express-viewer": "^5.0.0",
"@map-colonies/prometheus": "^1.0.0",
"@map-colonies/read-pkg": "^1.0.0",
"@map-colonies/schemas": "^1.17.0",
"@map-colonies/schemas": "https://ghatmpstorage.blob.core.windows.net/npm-packages/schemas-6939db3448a04daf1d79ab5f8ecfadeab67237c8.tgz",
"@map-colonies/tracing": "^1.0.0",
"@map-colonies/tracing-utils": "^1.0.0",
"@opentelemetry/api": "^1.9.0",
Expand Down
6 changes: 3 additions & 3 deletions src/common/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type ConfigInstance, config } from '@map-colonies/config';
import { commonBoilerplateV2, type commonBoilerplateV2Type } from '@map-colonies/schemas';
import { demDemGatewayV1, type demDemGatewayV1Type } from '@map-colonies/schemas';

// Choose here the type of the config instance and import this type from the entire application
type ConfigType = ConfigInstance<commonBoilerplateV2Type>;
type ConfigType = ConfigInstance<demDemGatewayV1Type>;

let configInstance: ConfigType | undefined;

Expand All @@ -13,7 +13,7 @@ let configInstance: ConfigType | undefined;
*/
async function initConfig(offlineMode?: boolean): Promise<void> {
configInstance = await config({
schema: commonBoilerplateV2,
schema: demDemGatewayV1,
offlineMode,
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/common/gdal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as gdalAsync from 'gdal-async';
import { z } from 'zod';
import type { InfoResponse } from '@src/info/models/infoManager';
import { EPSG_DATA_RECORDS } from './epsg';
import { resolutionDegreeSchema, resolutionMeterSchema } from './schemas';

interface PixelInfo {
pixelWidth: number;
Expand Down Expand Up @@ -74,7 +75,9 @@ export const getResolutions = (
throw new Error('Unsupported SRS type');
}

return resolutions;
const response = z.strictObject({ resolutionMeter: resolutionMeterSchema, resolutionDegree: resolutionDegreeSchema }).parse(resolutions);

return response;
};

export const getSrsName = (srsId: number): string => {
Expand Down
12 changes: 11 additions & 1 deletion src/common/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ import { GEOTIFF_DATA_TYPES } from './constants';

const config = getConfig();

const supportedSrsIds = config.get('application.supportedSrsIds') as unknown as number[]; // TODO: include application.supportedSrsIds in service schema
const blockSize = config.get('application.validation.blockSize');
const compression = config.get('application.validation.compression');
const resolutionDegree = config.get('application.validation.resolutionDegree');
const resolutionMeter = config.get('application.validation.resolutionMeter');
const supportedSrsIds = config.get('application.validation.supportedSrsIds');

export const areaOrPointSchema = z.literal(['Area', 'Point']);
export const blockSizeSchema = z.object({ x: z.literal(blockSize), y: z.literal(blockSize) });
export const compressionSchema = z.literal(compression);
export const layoutSchema = z.literal('COG');
export const noDataValueSchema = z.union([z.number(), z.nan()]).transform((value) => (Number.isNaN(value) ? 'NaN' : value));
export const overviewsCount = z.number().positive();
export const pixelDataTypesSchema = z.union([z.literal(GEOTIFF_DATA_TYPES)]); // add additional data types to union for each supported format
export const pixelSchema = z.number().positive();
export const resolutionDegreeSchema = z.number().min(resolutionDegree.min).max(resolutionDegree.max);
export const resolutionMeterSchema = z.number().min(resolutionMeter.min).max(resolutionMeter.max);
export const srsIdSchema = z.literal(supportedSrsIds);
export const srsNameSchema = z.string().min(1);

Expand Down
Loading
Loading