first try to convert chargemap to geojson
This commit is contained in:
parent
5fe084ca62
commit
3a51582123
|
@ -0,0 +1,75 @@
|
|||
import fs from "fs";
|
||||
|
||||
|
||||
let sourceFilePath :string = './chargemap_data/hurepoix.json'
|
||||
|
||||
/**
|
||||
makes a geojson from chargemap layer data
|
||||
*/
|
||||
function convertChargemapFile(sourceFilePath: string) {
|
||||
fs.readFile(sourceFilePath, 'utf8', function (err, data) {
|
||||
let data_transformed: any = JSON.parse(data)
|
||||
let base_dataset: any = {type: 'FeatureCollection', features: []}
|
||||
let base_point: any = {
|
||||
type: 'Feature',
|
||||
geometry: {type: 'Point', coordinates: []},
|
||||
properties: {
|
||||
amenity: "charging_station"
|
||||
}
|
||||
}
|
||||
console.log('data_transformed.items.length', data_transformed.items.length)
|
||||
data_transformed.items.forEach((item: any) => {
|
||||
|
||||
let new_point: any = {...base_point}
|
||||
|
||||
if (item.type === 'point') {
|
||||
|
||||
new_point.geometry.coordinates = [
|
||||
item.properties?.lat,
|
||||
item.properties?.lng,
|
||||
]
|
||||
|
||||
} else if (item.type === 'pool' && item.pool) {
|
||||
new_point.geometry.coordinates = [
|
||||
item.pool.gps_coordinates.lon,
|
||||
item.pool.gps_coordinates.lat,
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
base_dataset.features.push(new_point)
|
||||
})
|
||||
if(base_dataset){
|
||||
|
||||
writeFile('hurepoix_geojson.json', JSON.stringify(base_dataset, null, 2))
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* crée un fichier dans le dossier par défaut, output
|
||||
* @param fileName
|
||||
* @param fileContent
|
||||
*/
|
||||
function writeFile(fileName: string, fileContent: any) {
|
||||
|
||||
|
||||
let output_folder = 'output';
|
||||
return fs.writeFile(
|
||||
`./${output_folder}/${fileName}`,
|
||||
fileContent,
|
||||
'utf8',
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.log(`Error writing file: ${err}`)
|
||||
} else {
|
||||
console.log(`File ${fileName} is written successfully!`)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
convertChargemapFile(sourceFilePath)
|
||||
|
|
@ -2,6 +2,12 @@
|
|||
"count": 85,
|
||||
"items": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": []
|
||||
},
|
||||
"properties": {
|
||||
"lat": 48.6906548,
|
||||
"lng": 2.2017481,
|
||||
"icon": "icon-incompatible-normal.png",
|
||||
|
@ -60,7 +66,7 @@
|
|||
"is_tesla": false,
|
||||
"evses": []
|
||||
}
|
||||
},
|
||||
}},
|
||||
{
|
||||
"lat": 48.6697273,
|
||||
"lng": 2.2382884,
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## puissance_nominale
|
||||
|
||||
quelle pagaille:
|
||||
|
||||
|
||||
225
|
||||
150
|
||||
50
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<osm version="0.6" generator="geojsontoosm">
|
||||
<node id="-1" lat="48.6579437" lon="2.2700457999999997">
|
||||
<tag k="amenity" v="charging_station"/>
|
||||
</node></osm>
|
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,7 @@
|
|||
"start:91": "ts-node convert_to_osm_tags.ts --engine=true --department=91 --source=\"./etalab_data/all.json\"",
|
||||
"start:974": "ts-node convert_to_osm_tags.ts --engine=true --department=974 --source=\"./etalab_data/all.json\"",
|
||||
"simple": "ts-node convert_to_osm_tags.ts",
|
||||
"chargemap": "ts-node chargemap.ts",
|
||||
"filter": "node convert_to_osm_tags.ts --department=76 --engine=true",
|
||||
"test": "jest --coverage --watch"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue