type check ok

This commit is contained in:
Tykayn 2023-08-05 11:04:29 +02:00 committed by tykayn
parent a4af49388d
commit 7f31023f58
5 changed files with 46 additions and 477 deletions

View File

@ -9,6 +9,7 @@ import mapping_engine from './mappings/engine'
import MappingConfigType, {BoundingBoxCoordinatesType, FeatureCollection} from "./mappings/mapping-config.type"; import MappingConfigType, {BoundingBoxCoordinatesType, FeatureCollection} from "./mappings/mapping-config.type";
import utils from './mappings/utils' import utils from './mappings/utils'
const minimist = require('minimist') const minimist = require('minimist')
const debugLog = utils.debugLog; const debugLog = utils.debugLog;
@ -76,6 +77,31 @@ let converted_geo_json: any = {
features: [] features: []
} }
let output_folder = 'output';
/**
* crée un fichier dans le dossier par défaut, output
* @param fileName
* @param fileContent
*/
function writeFile(fileName: string, fileContent: any) {
debugLog('write file ', fileName)
return fs.writeFile(
`./${output_folder}/${fileName}`,
fileContent,
'utf8',
(err) => {
if (err) {
debugLog(`Error writing file: ${err}`)
} else {
debugLog(`File ${fileName} is written successfully!`)
}
}
)
}
/** /**
* *
* @param sourceFilePath * @param sourceFilePath
@ -83,7 +109,7 @@ let converted_geo_json: any = {
* @param pointCounterMax * @param pointCounterMax
* @param boundingBoxCoordinates * @param boundingBoxCoordinates
*/ */
function convertDataForIRVE(sourceFilePath: string, mapping: MappingConfigType, pointCounterMax: number, boundingBoxCoordinates: any) { function convertDataForIRVE(sourceFilePath: string, mapping: any, pointCounterMax: number, boundingBoxCoordinates: any) {
debugLog('convertDataFromChargemap from ', sourceFilePath) debugLog('convertDataFromChargemap from ', sourceFilePath)
fs.readFile(sourceFilePath, 'utf8', function (err, data) { fs.readFile(sourceFilePath, 'utf8', function (err, data) {
@ -166,7 +192,7 @@ function convertDataForIRVE(sourceFilePath: string, mapping: MappingConfigType,
// write file on disk // write file on disk
let fileNameToWrite = 'my_converted_data_set' + filteredName + '.json' let fileNameToWrite = 'my_converted_data_set' + filteredName + '.json'
console.log('write file ', fileNameToWrite) console.log('write file ', fileNameToWrite)
utils.writeFile(fileNameToWrite, JSON.stringify(converted_geo_json, null, 2)) writeFile(fileNameToWrite, JSON.stringify(converted_geo_json, null, 2))
debugLog('mapped output:', converted_geo_json.features) debugLog('mapped output:', converted_geo_json.features)
@ -178,7 +204,7 @@ function convertDataForIRVE(sourceFilePath: string, mapping: MappingConfigType,
/** /**
* retuns the converted element from mapping config if present, null otherwise * retuns the converted element from mapping config if present, null otherwise
*/ */
function mapElementFromConfSimple(featurePoint: any, mappingConfig: MappingConfigType) { function mapElementFromConfSimple(featurePoint: any, mappingConfig: any) {
let mappingKeys = Object.keys(mappingConfig) let mappingKeys = Object.keys(mappingConfig)
let featurePointPropertiesKeys = Object.keys(featurePoint.properties) let featurePointPropertiesKeys = Object.keys(featurePoint.properties)
@ -210,7 +236,8 @@ function mapElementFromConfSimple(featurePoint: any, mappingConfig: MappingConfi
} }
if (convertedValue) { if (convertedValue) {
newProperties[mappingConfig[pointKeyName]] = convertedValue let convertedKey : any = mappingConfig[pointKeyName]
newProperties[convertedKey] = convertedValue
} }
} }
}) })

View File

@ -1,212 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1691225984915" clover="3.2.0"> <coverage generated="1691226256879" clover="3.2.0">
<project timestamp="1691225984915" name="All files"> <project timestamp="1691226256879" name="All files">
<metrics statements="203" coveredstatements="76" conditionals="6" coveredconditionals="4" methods="9" coveredmethods="4" elements="218" coveredelements="84" complexity="0" loc="203" ncloc="203" packages="1" files="1" classes="1"/> <metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
<file name="engine.ts" path="/home/poule/encrypted/stockage-syncable/www/development/html/scripts/mapping_geojson_to_osm_tags/mappings/engine.ts">
<metrics statements="203" coveredstatements="76" conditionals="6" coveredconditionals="4" methods="9" coveredmethods="4"/>
<line num="1" count="1" type="stmt"/>
<line num="2" count="1" type="stmt"/>
<line num="3" count="1" type="stmt"/>
<line num="4" count="1" type="stmt"/>
<line num="5" count="1" type="stmt"/>
<line num="6" count="1" type="stmt"/>
<line num="7" count="1" type="stmt"/>
<line num="8" count="1" type="stmt"/>
<line num="9" count="1" type="stmt"/>
<line num="10" count="1" type="stmt"/>
<line num="11" count="1" type="stmt"/>
<line num="12" count="1" type="stmt"/>
<line num="13" count="1" type="stmt"/>
<line num="14" count="1" type="stmt"/>
<line num="15" count="1" type="stmt"/>
<line num="16" count="1" type="cond" truecount="1" falsecount="0"/>
<line num="17" count="1" type="stmt"/>
<line num="18" count="1" type="stmt"/>
<line num="19" count="1" type="cond" truecount="1" falsecount="0"/>
<line num="20" count="1" type="stmt"/>
<line num="21" count="1" type="stmt"/>
<line num="22" count="1" type="stmt"/>
<line num="23" count="1" type="cond" truecount="1" falsecount="0"/>
<line num="24" count="1" type="stmt"/>
<line num="25" count="1" type="stmt"/>
<line num="26" count="1" type="stmt"/>
<line num="27" count="1" type="stmt"/>
<line num="28" count="0" type="stmt"/>
<line num="29" count="0" type="stmt"/>
<line num="30" count="0" type="stmt"/>
<line num="31" count="0" type="stmt"/>
<line num="32" count="0" type="stmt"/>
<line num="33" count="0" type="stmt"/>
<line num="34" count="0" type="stmt"/>
<line num="35" count="0" type="stmt"/>
<line num="36" count="0" type="stmt"/>
<line num="37" count="0" type="stmt"/>
<line num="38" count="0" type="stmt"/>
<line num="39" count="0" type="stmt"/>
<line num="40" count="0" type="stmt"/>
<line num="41" count="0" type="stmt"/>
<line num="42" count="1" type="stmt"/>
<line num="43" count="1" type="stmt"/>
<line num="44" count="1" type="stmt"/>
<line num="45" count="1" type="stmt"/>
<line num="46" count="1" type="stmt"/>
<line num="47" count="1" type="stmt"/>
<line num="48" count="1" type="stmt"/>
<line num="49" count="0" type="stmt"/>
<line num="50" count="0" type="stmt"/>
<line num="51" count="0" type="stmt"/>
<line num="52" count="1" type="stmt"/>
<line num="53" count="1" type="stmt"/>
<line num="54" count="1" type="stmt"/>
<line num="55" count="1" type="stmt"/>
<line num="56" count="1" type="stmt"/>
<line num="57" count="1" type="stmt"/>
<line num="58" count="1" type="stmt"/>
<line num="59" count="1" type="stmt"/>
<line num="60" count="1" type="stmt"/>
<line num="61" count="1" type="stmt"/>
<line num="62" count="0" type="stmt"/>
<line num="63" count="0" type="stmt"/>
<line num="64" count="0" type="stmt"/>
<line num="65" count="0" type="stmt"/>
<line num="66" count="1" type="stmt"/>
<line num="67" count="1" type="stmt"/>
<line num="68" count="1" type="stmt"/>
<line num="69" count="1" type="stmt"/>
<line num="70" count="1" type="stmt"/>
<line num="71" count="1" type="stmt"/>
<line num="72" count="1" type="stmt"/>
<line num="73" count="1" type="stmt"/>
<line num="74" count="1" type="stmt"/>
<line num="75" count="0" type="stmt"/>
<line num="76" count="0" type="stmt"/>
<line num="77" count="0" type="stmt"/>
<line num="78" count="0" type="stmt"/>
<line num="79" count="0" type="stmt"/>
<line num="80" count="1" type="stmt"/>
<line num="81" count="1" type="stmt"/>
<line num="82" count="1" type="stmt"/>
<line num="83" count="1" type="stmt"/>
<line num="84" count="1" type="cond" truecount="1" falsecount="0"/>
<line num="85" count="1" type="cond" truecount="0" falsecount="1"/>
<line num="86" count="0" type="stmt"/>
<line num="87" count="0" type="stmt"/>
<line num="88" count="0" type="stmt"/>
<line num="89" count="1" type="stmt"/>
<line num="90" count="1" type="stmt"/>
<line num="91" count="1" type="stmt"/>
<line num="92" count="1" type="stmt"/>
<line num="93" count="1" type="stmt"/>
<line num="94" count="1" type="stmt"/>
<line num="95" count="1" type="stmt"/>
<line num="96" count="1" type="stmt"/>
<line num="97" count="1" type="stmt"/>
<line num="98" count="1" type="stmt"/>
<line num="99" count="1" type="stmt"/>
<line num="100" count="1" type="stmt"/>
<line num="101" count="1" type="cond" truecount="0" falsecount="1"/>
<line num="102" count="0" type="stmt"/>
<line num="103" count="0" type="stmt"/>
<line num="104" count="0" type="stmt"/>
<line num="105" count="0" type="stmt"/>
<line num="106" count="0" type="stmt"/>
<line num="107" count="0" type="stmt"/>
<line num="108" count="0" type="stmt"/>
<line num="109" count="0" type="stmt"/>
<line num="110" count="0" type="stmt"/>
<line num="111" count="0" type="stmt"/>
<line num="112" count="0" type="stmt"/>
<line num="113" count="0" type="stmt"/>
<line num="114" count="0" type="stmt"/>
<line num="115" count="0" type="stmt"/>
<line num="116" count="0" type="stmt"/>
<line num="117" count="0" type="stmt"/>
<line num="118" count="0" type="stmt"/>
<line num="119" count="1" type="stmt"/>
<line num="120" count="1" type="stmt"/>
<line num="121" count="0" type="stmt"/>
<line num="122" count="0" type="stmt"/>
<line num="123" count="0" type="stmt"/>
<line num="124" count="0" type="stmt"/>
<line num="125" count="0" type="stmt"/>
<line num="126" count="0" type="stmt"/>
<line num="127" count="0" type="stmt"/>
<line num="128" count="0" type="stmt"/>
<line num="129" count="0" type="stmt"/>
<line num="130" count="0" type="stmt"/>
<line num="131" count="0" type="stmt"/>
<line num="132" count="0" type="stmt"/>
<line num="133" count="0" type="stmt"/>
<line num="134" count="0" type="stmt"/>
<line num="135" count="0" type="stmt"/>
<line num="136" count="0" type="stmt"/>
<line num="137" count="0" type="stmt"/>
<line num="138" count="0" type="stmt"/>
<line num="139" count="0" type="stmt"/>
<line num="140" count="0" type="stmt"/>
<line num="141" count="0" type="stmt"/>
<line num="142" count="0" type="stmt"/>
<line num="143" count="0" type="stmt"/>
<line num="144" count="0" type="stmt"/>
<line num="145" count="0" type="stmt"/>
<line num="146" count="0" type="stmt"/>
<line num="147" count="0" type="stmt"/>
<line num="148" count="0" type="stmt"/>
<line num="149" count="0" type="stmt"/>
<line num="150" count="0" type="stmt"/>
<line num="151" count="0" type="stmt"/>
<line num="152" count="0" type="stmt"/>
<line num="153" count="0" type="stmt"/>
<line num="154" count="0" type="stmt"/>
<line num="155" count="0" type="stmt"/>
<line num="156" count="0" type="stmt"/>
<line num="157" count="0" type="stmt"/>
<line num="158" count="0" type="stmt"/>
<line num="159" count="0" type="stmt"/>
<line num="160" count="0" type="stmt"/>
<line num="161" count="0" type="stmt"/>
<line num="162" count="0" type="stmt"/>
<line num="163" count="0" type="stmt"/>
<line num="164" count="0" type="stmt"/>
<line num="165" count="0" type="stmt"/>
<line num="166" count="0" type="stmt"/>
<line num="167" count="0" type="stmt"/>
<line num="168" count="0" type="stmt"/>
<line num="169" count="0" type="stmt"/>
<line num="170" count="0" type="stmt"/>
<line num="171" count="0" type="stmt"/>
<line num="172" count="0" type="stmt"/>
<line num="173" count="0" type="stmt"/>
<line num="174" count="0" type="stmt"/>
<line num="175" count="0" type="stmt"/>
<line num="176" count="0" type="stmt"/>
<line num="177" count="0" type="stmt"/>
<line num="178" count="0" type="stmt"/>
<line num="179" count="0" type="stmt"/>
<line num="180" count="0" type="stmt"/>
<line num="181" count="0" type="stmt"/>
<line num="182" count="0" type="stmt"/>
<line num="183" count="0" type="stmt"/>
<line num="184" count="0" type="stmt"/>
<line num="185" count="0" type="stmt"/>
<line num="186" count="0" type="stmt"/>
<line num="187" count="0" type="stmt"/>
<line num="188" count="0" type="stmt"/>
<line num="189" count="0" type="stmt"/>
<line num="190" count="0" type="stmt"/>
<line num="191" count="0" type="stmt"/>
<line num="192" count="0" type="stmt"/>
<line num="193" count="0" type="stmt"/>
<line num="194" count="0" type="stmt"/>
<line num="195" count="0" type="stmt"/>
<line num="196" count="0" type="stmt"/>
<line num="197" count="0" type="stmt"/>
<line num="198" count="0" type="stmt"/>
<line num="199" count="0" type="stmt"/>
<line num="200" count="0" type="stmt"/>
<line num="201" count="0" type="stmt"/>
<line num="202" count="1" type="stmt"/>
<line num="203" count="1" type="stmt"/>
</file>
</project> </project>
</coverage> </coverage>

File diff suppressed because one or more lines are too long

View File

@ -23,30 +23,30 @@
<div class='clearfix'> <div class='clearfix'>
<div class='fl pad1y space-right2'> <div class='fl pad1y space-right2'>
<span class="strong">37.43% </span> <span class="strong">Unknown% </span>
<span class="quiet">Statements</span> <span class="quiet">Statements</span>
<span class='fraction'>76/203</span> <span class='fraction'>0/0</span>
</div> </div>
<div class='fl pad1y space-right2'> <div class='fl pad1y space-right2'>
<span class="strong">66.66% </span> <span class="strong">Unknown% </span>
<span class="quiet">Branches</span> <span class="quiet">Branches</span>
<span class='fraction'>4/6</span> <span class='fraction'>0/0</span>
</div> </div>
<div class='fl pad1y space-right2'> <div class='fl pad1y space-right2'>
<span class="strong">44.44% </span> <span class="strong">Unknown% </span>
<span class="quiet">Functions</span> <span class="quiet">Functions</span>
<span class='fraction'>4/9</span> <span class='fraction'>0/0</span>
</div> </div>
<div class='fl pad1y space-right2'> <div class='fl pad1y space-right2'>
<span class="strong">37.43% </span> <span class="strong">Unknown% </span>
<span class="quiet">Lines</span> <span class="quiet">Lines</span>
<span class='fraction'>76/203</span> <span class='fraction'>0/0</span>
</div> </div>
@ -61,7 +61,7 @@
</div> </div>
</template> </template>
</div> </div>
<div class='status-line low'></div> <div class='status-line medium'></div>
<div class="pad1"> <div class="pad1">
<table class="coverage-summary"> <table class="coverage-summary">
<thead> <thead>
@ -78,22 +78,7 @@
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
</tr> </tr>
</thead> </thead>
<tbody><tr> <tbody></tbody>
<td class="file low" data-value="engine.ts"><a href="engine.ts.html">engine.ts</a></td>
<td data-value="37.43" class="pic low">
<div class="chart"><div class="cover-fill" style="width: 37%"></div><div class="cover-empty" style="width: 63%"></div></div>
</td>
<td data-value="37.43" class="pct low">37.43%</td>
<td data-value="203" class="abs low">76/203</td>
<td data-value="66.66" class="pct medium">66.66%</td>
<td data-value="6" class="abs medium">4/6</td>
<td data-value="44.44" class="pct low">44.44%</td>
<td data-value="9" class="abs low">4/9</td>
<td data-value="37.43" class="pct low">37.43%</td>
<td data-value="203" class="abs low">76/203</td>
</tr>
</tbody>
</table> </table>
</div> </div>
<div class='push'></div><!-- for sticky footer --> <div class='push'></div><!-- for sticky footer -->
@ -101,7 +86,7 @@
<div class='footer quiet pad2 space-top1 center small'> <div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a> <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-08-05T08:59:44.912Z at 2023-08-05T09:04:16.877Z
</div> </div>
<script src="prettify.js"></script> <script src="prettify.js"></script>
<script> <script>

View File

@ -1,236 +0,0 @@
TN:
SF:mappings/engine.ts
FN:16,<instance_members_initializer>
FN:19,_default
FN:23,setConfig
FN:27,mapFeaturePoint
FN:48,isBooleanKey
FN:61,filterFeaturesByOffset
FN:74,filterFeaturesByPropertyRegex
FN:84,mapElementFromConf
FN:120,convertProperty
FNF:9
FNH:4
FNDA:1,<instance_members_initializer>
FNDA:1,_default
FNDA:1,setConfig
FNDA:0,mapFeaturePoint
FNDA:0,isBooleanKey
FNDA:0,filterFeaturesByOffset
FNDA:0,filterFeaturesByPropertyRegex
FNDA:1,mapElementFromConf
FNDA:0,convertProperty
DA:1,1
DA:2,1
DA:3,1
DA:4,1
DA:5,1
DA:6,1
DA:7,1
DA:8,1
DA:9,1
DA:10,1
DA:11,1
DA:12,1
DA:13,1
DA:14,1
DA:15,1
DA:16,1
DA:17,1
DA:18,1
DA:19,1
DA:20,1
DA:21,1
DA:22,1
DA:23,1
DA:24,1
DA:25,1
DA:26,1
DA:27,1
DA:28,0
DA:29,0
DA:30,0
DA:31,0
DA:32,0
DA:33,0
DA:34,0
DA:35,0
DA:36,0
DA:37,0
DA:38,0
DA:39,0
DA:40,0
DA:41,0
DA:42,1
DA:43,1
DA:44,1
DA:45,1
DA:46,1
DA:47,1
DA:48,1
DA:49,0
DA:50,0
DA:51,0
DA:52,1
DA:53,1
DA:54,1
DA:55,1
DA:56,1
DA:57,1
DA:58,1
DA:59,1
DA:60,1
DA:61,1
DA:62,0
DA:63,0
DA:64,0
DA:65,0
DA:66,1
DA:67,1
DA:68,1
DA:69,1
DA:70,1
DA:71,1
DA:72,1
DA:73,1
DA:74,1
DA:75,0
DA:76,0
DA:77,0
DA:78,0
DA:79,0
DA:80,1
DA:81,1
DA:82,1
DA:83,1
DA:84,1
DA:85,1
DA:86,0
DA:87,0
DA:88,0
DA:89,1
DA:90,1
DA:91,1
DA:92,1
DA:93,1
DA:94,1
DA:95,1
DA:96,1
DA:97,1
DA:98,1
DA:99,1
DA:100,1
DA:101,1
DA:102,0
DA:103,0
DA:104,0
DA:105,0
DA:106,0
DA:107,0
DA:108,0
DA:109,0
DA:110,0
DA:111,0
DA:112,0
DA:113,0
DA:114,0
DA:115,0
DA:116,0
DA:117,0
DA:118,0
DA:119,1
DA:120,1
DA:121,0
DA:122,0
DA:123,0
DA:124,0
DA:125,0
DA:126,0
DA:127,0
DA:128,0
DA:129,0
DA:130,0
DA:131,0
DA:132,0
DA:133,0
DA:134,0
DA:135,0
DA:136,0
DA:137,0
DA:138,0
DA:139,0
DA:140,0
DA:141,0
DA:142,0
DA:143,0
DA:144,0
DA:145,0
DA:146,0
DA:147,0
DA:148,0
DA:149,0
DA:150,0
DA:151,0
DA:152,0
DA:153,0
DA:154,0
DA:155,0
DA:156,0
DA:157,0
DA:158,0
DA:159,0
DA:160,0
DA:161,0
DA:162,0
DA:163,0
DA:164,0
DA:165,0
DA:166,0
DA:167,0
DA:168,0
DA:169,0
DA:170,0
DA:171,0
DA:172,0
DA:173,0
DA:174,0
DA:175,0
DA:176,0
DA:177,0
DA:178,0
DA:179,0
DA:180,0
DA:181,0
DA:182,0
DA:183,0
DA:184,0
DA:185,0
DA:186,0
DA:187,0
DA:188,0
DA:189,0
DA:190,0
DA:191,0
DA:192,0
DA:193,0
DA:194,0
DA:195,0
DA:196,0
DA:197,0
DA:198,0
DA:199,0
DA:200,0
DA:201,0
DA:202,1
DA:203,1
LF:203
LH:76
BRDA:16,0,0,1
BRDA:19,1,0,1
BRDA:23,2,0,1
BRDA:84,3,0,1
BRDA:85,4,0,0
BRDA:101,5,0,0
BRF:6
BRH:4
end_of_record