Skip to content

Commit

Permalink
Merge pull request #152 from oSoc18/feature/ISSUE-151
Browse files Browse the repository at this point in the history
bug() 🐛 fixing
  • Loading branch information
LieselotGeirnaert authored Jul 23, 2018
2 parents 6aea168 + e4fa464 commit 7cf93d4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions helpers/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports.gebouwFetcher = async (params) => {
JSON.stringify(jsonLDBuilding(JSON.parse(gebouwDetails).identificator.objectId, JSON.parse(gebouwId).adressen[0].objectId,
lambertToWGS(JSON.parse(gebouwId).geometriePunt.point.coordinates[0], JSON.parse(gebouwId).geometriePunt.point.coordinates[1]))),
err => {
if (err) throw new Error("Error whiel writing building JSON")
if (err) throw new Error("Error while writing building JSON")
})
})
})
Expand All @@ -72,7 +72,7 @@ exports.gebouwFetcher = async (params) => {
JSON.stringify(jsonLDBuilding(JSON.parse(gebouwDetails).identificator.objectId, JSON.parse(gebouwId).adressen[0].objectId,
lambertToWGS(JSON.parse(gebouwId).geometriePunt.point.coordinates[0], JSON.parse(gebouwId).geometriePunt.point.coordinates[1]))),
err => {
if (err) throw new Error("Error whiel writing building JSON")
if (err) throw new Error("Error while writing building JSON")
})
fs.readFile(__dirname + `/../files/${params.postcode}/catalog.json`, (err, data) => {
let file_data = JSON.parse(data);
Expand All @@ -98,6 +98,25 @@ exports.gebouwFetcher = async (params) => {
fs.writeFile(__dirname + `/../files/${params.postcode}/catalog.json`, JSON.stringify(file_data), err => {
if (err) throw new Error("Error while adding building to catalog")
})
fs.readFile(__dirname + '/../files/master-catalog.json', (err, data) => {
if (err) throw new Error("error while reading master-catalog file")
let file_data = JSON.parse(data);
let contains = false
file_data["dcterms:hasPart"].forEach(element => {
if(element["foaf:page"] === `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/catalog.json`){
contains = true;
}
});
if(!contains){
file_data["dcterms:hasPart"].push({
"foaf:page": `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/catalog.json`,
"@type": "dcat:Catalog"
});
fs.writeFile(__dirname + '/../files/master-catalog.json', JSON.stringify(file_data), err => {
if (err) throw new Error("Error while writing files");
})
}
})
})
}

Expand Down

0 comments on commit 7cf93d4

Please sign in to comment.