Skip to content

Commit

Permalink
Merge pull request #154 from oSoc18/feature/ISSUE-153
Browse files Browse the repository at this point in the history
Added image and title fields for OASIS
  • Loading branch information
LieselotGeirnaert authored Jul 23, 2018
2 parents 7cf93d4 + 907e247 commit 1cc6e2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
10 changes: 1 addition & 9 deletions files/master-catalog.json
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
{
"@context": {
"dcat": "https://www.w3.org/ns/dcat#",
"dcterms": "http://purl.org/dc/terms/",
"foaf": "http://xmlns.com/foaf/0.1/"
},
"@type": "dcterms:Collection",
"dcterms:hasPart": []
}
{"@context":{"dcat":"https://www.w3.org/ns/dcat#","dcterms":"http://purl.org/dc/terms/","foaf":"http://xmlns.com/foaf/0.1/"},"@type":"dcterms:Collection","dcterms:hasPart":[{"foaf:page":"http://smartflanders.ilabt.imec.be/graph/1800/catalog.json","@type":"dcat:Catalog"},{"foaf:page":"http://smartflanders.ilabt.imec.be/graph/9300/catalog.json","@type":"dcat:Catalog"},{"foaf:page":"http://smartflanders.ilabt.imec.be/graph/9300/catalog.json","@type":"dcat:Catalog"}]}
2 changes: 1 addition & 1 deletion files/service-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
]
},
"http://purl.org/dc/terms/description": "The public toilet of the public library of Mechelen",
"http://www.w3.org/ns/locn#location": "http://data.vlaanderen.be/id/gebouw/123",
"http://www.w3.org/ns/locn#location": "http://data.vlaanderen.be/id/adres/1531526",
"toevla:accessibilityMeasurement": {
"toevla:accessibilityMeasurement_for": {
"dcterms:description": "The elevator",
Expand Down
21 changes: 13 additions & 8 deletions helpers/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ exports.gebouwFetcher = async (params) => {
if (err) throw new Error("Error while writing catalog file of specific building")
fs.writeFile(__dirname + `/../files/${params.postcode}/gebouwen/${JSON.parse(gebouwId).gebouw.objectId}.json`,
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]))),
lambertToWGS(JSON.parse(gebouwId).geometriePunt.point.coordinates[0], JSON.parse(gebouwId).geometriePunt.point.coordinates[1],
"Gebouw title", "https://installect.files.wordpress.com/2013/03/catsincup.jpg"))),
err => {
if (err) throw new Error("Error while writing building JSON")
})
Expand All @@ -70,15 +71,16 @@ exports.gebouwFetcher = async (params) => {
} else {
fs.writeFile(__dirname + `/../files/${params.postcode}/gebouwen/${JSON.parse(gebouwId).gebouw.objectId}.json`,
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]))),
lambertToWGS(JSON.parse(gebouwId).geometriePunt.point.coordinates[0], JSON.parse(gebouwId).geometriePunt.point.coordinates[1],
"Gebouw title", "https://installect.files.wordpress.com/2013/03/catsincup.jpg"))),
err => {
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);
let should_push = true;
for(let i = 0; i < file_data["dcat:dataset"].length; i++){
if (file_data["dcat:dataset"][i]["dcat:distribution"][0]["dcat:accessUrl"] === `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/gebouwen${JSON.parse(gebouwId).gebouw.objectId}.json`){
if (file_data["dcat:dataset"][i]["dcat:distribution"][0]["dcat:accessUrl"] === `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/gebouwen/${JSON.parse(gebouwId).gebouw.objectId}.json`){
should_push = false;
break;
}
Expand All @@ -89,7 +91,7 @@ exports.gebouwFetcher = async (params) => {
"dcat:keyword": "http://data.vlaanderen.be/ns/gebouw#Gebouw",
"dcat:distribution": [{
"@type": "dcat:Distribution",
"dcat:accessUrl": `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/gebouwen${JSON.parse(gebouwId).gebouw.objectId}.json`,
"dcat:accessUrl": `http://smartflanders.ilabt.imec.be/graph/${params.postcode}/gebouwen/${JSON.parse(gebouwId).gebouw.objectId}.json`,
"dcat:mediaType": "text/html"
}]
});
Expand Down Expand Up @@ -121,7 +123,7 @@ exports.gebouwFetcher = async (params) => {
}

})
return 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]))
return 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], "Gebouw title", "https://installect.files.wordpress.com/2013/03/catsincup.jpg"))
};

/**
Expand Down Expand Up @@ -169,7 +171,7 @@ function fetch(url) {
* @param {number} adresId
* @param {number} location
*/
function jsonLDBuilding(gebouwId, adresId, location) {
function jsonLDBuilding(gebouwId, adresId, location, name, image) {
return {
"@context": {
"gebouwenRegister": "http://data.vlaanderen.be/id/gebouw/",
Expand All @@ -180,10 +182,13 @@ function jsonLDBuilding(gebouwId, adresId, location) {
"toevla": "http://semweb.mmlab.be/ns/wa#",
"locn": "http://www.w3.org/ns/locn#",
"geo": "http://www.opengis.net/ont/geosparql#",
"xsd": "http://www.w3.org/2001/XMLSchema#"
"xsd": "http://www.w3.org/2001/XMLSchema#",
"image": "http://schema.org/image"
},
"@id": "gebouw:" + gebouwId,
"@type": "gebouw:Gebouw",
"gebouw:gebouwnaam": name,
"image": image,
"gebouw:Gebouw.adres": {
"@id": "http://data.vlaanderen.be/id/adres/" + adresId,
"@type": "http://www.w3.org/ns/locn#Address",
Expand Down Expand Up @@ -271,4 +276,4 @@ function jsonLDService(id, name, description, productType, telephone, email, ope
}

return jsonLD;
}
}

0 comments on commit 1cc6e2f

Please sign in to comment.