diff --git a/.gitignore b/.gitignore index d8f7b82..440c75b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,9 @@ client/.idea client/Boundaries/Dexpi2Svg/test.svg rml/C03V04.trig www/C03V04.svg +client/Boundaries/Dexpi2Svg/bin +client/Boundaries/Dexpi2Svg/obj +client/Boundaries/Boundaries/bin +client/Boundaries/Boundaries/obj +client/Boundaries/TestBoundaries/obj +client/Boundaries/TestBoundaries/bin \ No newline at end of file diff --git a/datalog/interactive_boundary.datalog b/datalog/interactive_boundary.datalog new file mode 100644 index 0000000..413a03f --- /dev/null +++ b/datalog/interactive_boundary.datalog @@ -0,0 +1,7 @@ +prefix data: + +data:insideBoundary [?new_node] :- + data:insideBoundary [?node], + imf:connectedTo [?node, ?new_node], + dexpi:PipingOrEquipment [?new_node], + NOT data:boundary [?node]. diff --git a/owl/README.md b/owl/README.md new file mode 100644 index 0000000..0c42146 --- /dev/null +++ b/owl/README.md @@ -0,0 +1,2 @@ +The imf ontology is downloaded [here](https://ns.imfid.org/20240531/). +The ontology must be downloaded into this folder and named imf-ontology.owl.ttl \ No newline at end of file diff --git a/rdfox/boundaries.rdfox b/rdfox/boundaries.rdfox index d245968..cd0a161 100644 --- a/rdfox/boundaries.rdfox +++ b/rdfox/boundaries.rdfox @@ -8,17 +8,16 @@ prefix rdf: prefix schema: prefix commonlib: prefix dexpi: -prefix asset: +prefix asset: prefix dbo: -prefix dexpi: prefix imf: prefix data: - import > asset:axioms ../owl/dexpi.ttl import > asset:axioms ../owl/imf-ontology.owl.ttl importaxioms asset:axioms import > schema:shacl ../shacl/imf-dexpi.shacl.ttl commitproc set commit-procedure.sparql +set endpoint.access-control-allow-origin * endpoint start diff --git a/rdfox/connected.rdfox b/rdfox/connected.rdfox index bfbd84d..5adeeca 100644 --- a/rdfox/connected.rdfox +++ b/rdfox/connected.rdfox @@ -3,6 +3,7 @@ boundaries.rdfox import ../datalog/surrounding.datalog import +p "../rml/pandid.trig" +set access-control-allow-origin * endpoint start set output out diff --git a/rdfox/dexpi.rdfox b/rdfox/dexpi.rdfox index 9e100c8..9187004 100644 --- a/rdfox/dexpi.rdfox +++ b/rdfox/dexpi.rdfox @@ -1,9 +1,8 @@ boundaries.rdfox import ../datalog/boundary.datalog +import ../datalog/interactive_boundary.datalog import +p "../rml/pandid.trig" -endpoint start - set output out select * where {?s a data:insideBoundaryX} \ No newline at end of file diff --git a/rdfox/endpoint.params b/rdfox/endpoint.params new file mode 100644 index 0000000..f97de1e --- /dev/null +++ b/rdfox/endpoint.params @@ -0,0 +1,2 @@ +#Enable cors +access-control-allow-origin * \ No newline at end of file diff --git a/rml/attributes-map.rml.ttl b/rml/attributes-map.rml.ttl index 97a7409..330f5aa 100644 --- a/rml/attributes-map.rml.ttl +++ b/rml/attributes-map.rml.ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . @prefix owl: . diff --git a/rml/connection-points.map.ttl b/rml/connection-points.map.ttl index 6414d41..ff1ca45 100644 --- a/rml/connection-points.map.ttl +++ b/rml/connection-points.map.ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/rml/element-map.rml.ttl b/rml/element-map.rml.ttl index 4aff8df..fe0fd8c 100644 --- a/rml/element-map.rml.ttl +++ b/rml/element-map.rml.ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/rml/equipment-map.rml..ttl b/rml/equipment-map.rml..ttl index c79825c..aceba18 100644 --- a/rml/equipment-map.rml..ttl +++ b/rml/equipment-map.rml..ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/rml/nozzlemap.rml..ttl b/rml/nozzlemap.rml..ttl index 6cacdca..8662f15 100644 --- a/rml/nozzlemap.rml..ttl +++ b/rml/nozzlemap.rml..ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/rml/piping-network-component-map.rml..ttl b/rml/piping-network-component-map.rml..ttl index df53042..978d3dd 100644 --- a/rml/piping-network-component-map.rml..ttl +++ b/rml/piping-network-component-map.rml..ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/rml/piping-network-segment-map.rml.ttl b/rml/piping-network-segment-map.rml.ttl index ecaeea0..4ee0ea5 100644 --- a/rml/piping-network-segment-map.rml.ttl +++ b/rml/piping-network-segment-map.rml.ttl @@ -6,7 +6,7 @@ @prefix schema: . @prefix commonlib: . @prefix dexpi: . -@prefix asset: . +@prefix asset: . @prefix dbo: . @prefix imf: . diff --git a/www/README.md b/www/README.md new file mode 100644 index 0000000..c25f80c --- /dev/null +++ b/www/README.md @@ -0,0 +1,7 @@ +# Select boundary in browser +1) Run the dexpi.rdfox script, the documentation for this script is found [here](../rdfox/README.md) +2) Open the dexpi.html file in a browser +3) Select the boundary points and an internal component +- Right click to select or deselect the internal component +- Left click to select or deselect boundary nodes +4) Hit enter to query RDFox for the boundary - the output of the query can be found in the logs. \ No newline at end of file diff --git a/www/dexpi.html b/www/dexpi.html new file mode 100644 index 0000000..a1ec54a --- /dev/null +++ b/www/dexpi.html @@ -0,0 +1,535 @@ + + + + + SVG Display + + + + + + + + + + + PV4712.02 + + + + F.C. + + + + F.C. + + + TV4750.03 + + + + F.O. + + + + MNb 47121 75HB13 80 + + + + + + + + + MNb 47122 75HB13 80 + + + + + + + + MNb 47123 75HB13 80 + + + + + + + + + + + MNc 47124 75HB13 80 + + + + + + 66KL21-80 + + + + + 75SA21-80 + + + + + + + 80/50 + + + + + + + 73KH12-50 + + + + + + + MNc 47125 73HG12 25 + + + + + + SV 104.01 + + + + + MNc 47125 75HB13 50 + + + + + + + + + MNc 47126 75HB13 50 + + + + + + + + + + 73KH12-25 + + + + + + + + + + + + + + + 73KH12-25 + + + + + + + + 73KH12-50 + + + + + + + + + + + + + + + + 73KH12-25 + + + + + + + + + + + + MNc 47127 75HB13 50 Q 80 + + + + Q80 + + + + + + + + + + + WKa 47130 75HB13 50 + + + + + + + + + WKb 47131 75HB13 50 + + + + + + + + + QSa 47140 75HB13 50 Q 80 + + + + + + + + + QSb 47141 75HB13 50 Q 80 + + + + + + + + + + + PI + + + + + PICSA + + + + + + HS + + + + + TICSA + + + + + + H1007 + + + Ident + + + + N1 + + + + N2 + + + + N3 + + + + N4 + + + + H1008 + + + Ident + + + + N1 + + + + N2 + + + + N3 + + + + N4 + + + + P4711 + + + Ident + + + + N1 + + + + N2 + + + + P4712 + + + Ident + + + + N1 + + + + N2 + + + + + T4750 + + + Ident + + + + N1 + + + + N2 + + + + N3 + + + + N5 + + + + N6 + + + + N7 + + + + N8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + APPROVED BY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/www/dexpisvg.xslt b/www/dexpisvg.xslt index 6af70ab..f7d4da8 100644 --- a/www/dexpisvg.xslt +++ b/www/dexpisvg.xslt @@ -1,7 +1,7 @@ @@ -9,7 +9,7 @@ - + @@ -20,42 +20,42 @@ - - + + - + - - + + - + - + - + - + @@ -63,7 +63,7 @@ - + M @@ -81,7 +81,7 @@ - + @@ -137,7 +137,9 @@ - + + + @@ -196,14 +198,16 @@ - + + + - + @@ -212,7 +216,7 @@ - + @@ -221,16 +225,16 @@ - + - + - + - + @@ -241,7 +245,7 @@ - + @@ -262,13 +266,13 @@ - + - + @@ -284,14 +288,14 @@ - + - + @@ -312,6 +316,6 @@ - + \ No newline at end of file diff --git a/www/script.js b/www/script.js new file mode 100644 index 0000000..5a1969d --- /dev/null +++ b/www/script.js @@ -0,0 +1,102 @@ +var nodes = document.querySelectorAll(".node"); + +document.addEventListener("keyup", (event) => { + if (event.key === "Enter") { + console.log("enter pressed") + let query = 'SELECT ?node WHERE{?node a data:insideBoundary .}' + result = queryTripleStore(query) + } +}); + +/** + * Left clicking is used to select or deselect nodes as boundries: + * 1) If the node is not a member of the boundary class: + * - Add the node to the boundary class to indicate that it is selected + * - Update rdfox with the following triple :nodeId a :boundary . + * 2) If the node is a member of the boundary class: + * - Remove the node from the boundary class to indicate that it is deselected + * - Update rdfox, delete the following triple :nodeId a :boundary . + * 3) If the node is not a member of the boundary class, but is a member of the internal class: + * - Add the node to the boundary class, and remove it from the internal class. + * * - Update rdfox, insert the following triple :nodeId a :boundary . + * - Update rdfox, delete the following triple :nodeId a :insideBoundary . + */ +nodes.forEach(function(node) { + node.addEventListener('click', () => { + if (node.classList.contains('boundary')) { + node.classList.remove('boundary'); + let deleteSparql = `DELETE DATA {<${node.id}> a data:boundary . }`; + updateTripleStore(deleteSparql); + } else { + node.classList.add('boundary'); + let insertSparql = `INSERT DATA { <${node.id}> a data:boundary . }`; + updateTripleStore(insertSparql); + if(node.classList.contains('internal')){ + node.classList.remove('internal'); + let deleteSparql = `DELETE DATA { <${node.id}> a data:insideBoundary . }`; + updateTripleStore(deleteSparql); + } + } + }); + +/** + * Right clicking is used to select or deselect a node as internal: + * 1) If the node is not a member of the internal class: + * - Add the node to the internal class to indicate that it is selected + * - Update rdfox with the following triple :nodeId a :insideBoundary . + * 2) If the node is a member of the internal class: + * - Remove the node from the internal class to indicate that it is deselected + * - Update rdfox, delete the following triple :nodeId a :insideBoundary . + * 3) If the node is not a member of the internal class, but is a member of the boundary class: + * - Add the node to the internal class, and remove it from the boundary class. + * * - Update rdfox, insert the following triple :nodeId a :insideBoundary . + * - Update rdfox, delete the following triple :nodeId a :boundary . + */ + node.addEventListener('contextmenu', () => { + if (node.classList.contains('internal')) { + node.classList.remove('internal'); + let deleteSparql = `DELETE DATA {<${node.id}> a data:insideBoundary . }`; + updateTripleStore(deleteSparql) + } else { + node.classList.add('internal'); + let insertSparql = `INSERT DATA { <${node.id}> a data:insideBoundary . }`; + updateTripleStore(insertSparql); + if(node.classList.contains('boundary')){ + node.classList.remove('boundary'); + let deleteSparql = `DELETE DATA {<${node.id}> a data:boundary . }`; + updateTripleStore(deleteSparql); + } + } + }) +}); + +function updateTripleStore(sparql) { + fetch('http://localhost:12110/datastores/boundaries/sparql', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: `update=${sparql}` + }) + .then(response => response.text()) + .then(data => { + console.log(data); + }) + .catch(error => { + console.error('Error:', error); + }); +} + +function queryTripleStore(sparql) { + var encoded = encodeURI(sparql) + fetch(`http://localhost:12110/datastores/boundaries/sparql?query=${encoded}`, { + method: 'GET', + }) + .then(response => response.text()) + .then(data => { + console.log(data); + }) + .catch(error => { + console.error('Error:', error); + }); +} \ No newline at end of file diff --git a/www/style.css b/www/style.css new file mode 100644 index 0000000..0e0b393 --- /dev/null +++ b/www/style.css @@ -0,0 +1,20 @@ +/* ------ style.css ----- */ + +.node:hover text { + transition: 0.6s; + cursor:pointer; +} + +.boundary text { + fill: #FF0000; + transition: 0.6s; +} + +.internal text { + fill: rgb(234, 255, 0); + transition: 0.6s; +} + +.package text { + fill: rgb(5, 109, 5) +}