Skip to content

Commit

Permalink
add sensor observes rdfs:label
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvercr committed Oct 4, 2024
1 parent 25aa4ab commit 26e22bb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Quad } from "@rdfjs/types";
import type { Stream, Writer } from "@rdfc/js-runner";
import { getLogger, RDF, XSD } from "@treecg/types";
import { getLogger, RDF, RDFS, XSD } from "@treecg/types";
import * as N3 from "n3";
import { isotc, mumoData, qudt, sosa } from "./ontologies";
import {
Expand Down Expand Up @@ -45,6 +45,15 @@ export async function setup_nodes(
}
}

function observesToLabel(observes: string): string {
const lastIndex = observes.lastIndexOf("#");
if (lastIndex != -1) {
return observes.substring(lastIndex + 1);
} else {
return observes;
}
}

function observation(
value: number,
time: number,
Expand Down Expand Up @@ -72,6 +81,13 @@ function observation(
quads.push(
quad(resultId, qudt.unit, namedNode(sensor.item["sosa:observes"])),
);
quads.push(
quad(
namedNode(sensor.item["sosa:observes"]),
RDFS.terms.label,
literal(observesToLabel(sensor.item["sosa:observes"])),
),
);
quads.push(
quad(
resultId,
Expand Down

0 comments on commit 26e22bb

Please sign in to comment.