add types

This commit is contained in:
Tykayn 2023-08-02 16:59:24 +02:00 committed by tykayn
parent f819cd7cc7
commit 1e7dba294a
7 changed files with 417 additions and 430 deletions

View File

@ -6,11 +6,9 @@ import * as minimist from 'minimist'
import mappingConfigIRVE from './mappings/converters/configIRVE'
import mappingConfigIRVE_simple from './mappings/converters/mappingConfigIRVE_simple'
import mapping_engine from './mappings/engine'
import custom_utils from './mappings/utils.mjs'
const { debugLog } = custom_utils
const { isBooleanKey } = custom_utils
const { writeFile } = custom_utils
import custom_utils from './mappings/utils'
import MappingConfigType from "./mappings/mapping-config.type";
import {debugLog} from './mappings/utils.ts'
let use_mappping_engine = false
// use_mappping_engine = true
@ -26,7 +24,7 @@ let sourceFilePathGeoJson = './etalab_data/small.json'
let filterOnBoundingBox = true
filterOnBoundingBox = false
let boundingBoxCoordinates = {
let boundingBoxCoordinates : BoundingBoxCoordinatesType = {
xMin: 1.91,
xMax: 2.38,
yMin: 48.7,
@ -81,7 +79,7 @@ let converted_geo_json = {
* @param pointCounterMax
* @param boundingBoxCoordinates
*/
function convertDataForIRVE (sourceFilePath, mapping, pointCounterMax, boundingBoxCoordinates) {
function convertDataForIRVE (sourceFilePath, mapping: MappingConfigType, pointCounterMax, boundingBoxCoordinates) {
debugLog('convertDataFromChargemap from ', sourceFilePath)
fs.readFile(sourceFilePath, 'utf8', function (err, data) {

View File

@ -3,8 +3,9 @@
* détail dans le tableau
* https://wiki.openstreetmap.org/wiki/France/data.gouv.fr/Bornes_de_Recharge_pour_V%C3%A9hicules_%C3%89lectriques
*/
import MappingConfigType, {FeaturePropertyMappingConfigType} from "../mapping-config.type";
export default {
const MappingIRVE: MappingConfigType = {
config_name: "IRVE config",
config_author: "tykayn <contact@cipherbliss.com>",
default_properties_of_point: {
@ -110,4 +111,6 @@ export default {
}
}
},
}
}
export default MappingIRVE;

View File

@ -1,4 +1,4 @@
import custom_utils from './utils.mjs'
import custom_utils from './utils'
const {debugLog} = custom_utils
@ -45,7 +45,7 @@ export default class {
* @param pointKeyName
* @returns {boolean}
*/
isBooleanKey(pointKeyName) {
isBooleanKey(pointKeyName):boolean {
return listOfBooleanKeys.indexOf(pointKeyName) !== -1
}
@ -53,7 +53,7 @@ export default class {
truthyValues = ['true', 'True', 'TRUE', '1', 1]
falsyValues = ['false', 'False', 'FALSE', '0', 0]
filterFeaturesByOffset(offsetCount, listOfFeatures) {
filterFeaturesByOffset(offsetCount:number, listOfFeatures) : Array<any>{
let filteredList = listOfFeatures
// TODO
return filteredList

View File

@ -0,0 +1,16 @@
export interface FeaturePropertyMappingConfigType{
key_converted?:string,
truthy_value?:any,
}
export interface BoundingBoxCoordinatesType{
xMin: number,
xMax: number,
yMin: number,
yMax: number,
}
export default interface MappingConfigType{
config_name: string,
config_author: string,
default_properties_of_point: object,
tags: object
}

View File

@ -7,11 +7,11 @@ show_debug = 1
* faire un log
* @param message
*/
function debugLog(message) {
function debugLog(...args : any) {
if (!show_debug) {
return
}
console.log('debug: ', message)
console.log('debug: ', ...args)
}

View File

@ -20,18 +20,18 @@
"node-fs": "^0.1.7"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@babel/preset-typescript": "^7.22.5",
"@jest/globals": "^29.5.0",
"@jest/globals": "^29.6.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.4.5",
"babel-jest": "^29.5.0",
"jest": "^29.5.0",
"babel-jest": "^29.6.2",
"jest": "^29.6.2",
"loglevel": "^1.8.1",
"nodemon": "^2.0.22",
"ts-node": "^10.9.1",
"tslib": "^2.6.0",
"tslib": "^2.6.1",
"typescript": "^5.1.6"
}
}

File diff suppressed because it is too large Load Diff