Skip to content

Commit

Permalink
Improved joins and ids on center-lines vs. connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
daghovland committed Jan 22, 2025
1 parent 8d1d39d commit 934f604
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 45 deletions.
8 changes: 4 additions & 4 deletions examples/graphical.trig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ document:GateValve-5-node2-connector :visualisedAs graphic:GateValve-5-node2-con
document:graphic1234 a :Diagram ;
:hasExtent [
a :Extent ;
:minimumExtent [ :x 100 ; :y 100 ] ;
:maximumExtent [ :x 200 ; :y 200 ]
:minimumExtent [ :x "100"^^xsd:double ; :y "100"^^xsd:double ] ;
:maximumExtent [ :x "200"^^xsd:double ; :y "200"^^xsd:double ]
] ;
:hasSymbol graphic:PressureVessel-1 ;
:hasLine graphic:GateValve-5-node2-connector .
Expand All @@ -29,7 +29,7 @@ graphic:PressureVessel-1 a :Symbol ;
a :Position ;
:x "390"^^xsd:double ;
:y "210"^^xsd:double ;
:rotation 0
:rotation "0"^^xsd:double
];
:hasGraphics symbol:PT002A .

Expand All @@ -55,7 +55,7 @@ graphic:GateValve-5-node2-connector a :Line ;
:hasStroke [
a :Stroke ;
:dasharray "none"^^xsd:string ;
:width 1.4 ;
:width "1.4"^^xsd:double ;
:color [
a :RgbColor ;
:red 255 ;
Expand Down
212 changes: 178 additions & 34 deletions rml_mappings/graphics/CenterLine.map.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
@prefix : <http://rdf.equinor.com/dexpi/mappings/graphic#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:centerLineSubject rr:template "https://assetid.equinor.com/plantx/{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}/lines#{../Connection/@ToID}";
rr:termType rr:IRI;
rr:class graphic:Line .

:hasCoordinatesMap
rr:predicate graphic:hasCoordinates;
Expand All @@ -31,7 +28,7 @@
.


:CenterLineMap a rr:TriplesMap;
:CenterLineToMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
Expand All @@ -42,25 +39,115 @@
rr:termType rr:IRI;
rr:class graphic:Line
] ;
rr:predicateObjectMap :hasCoordinatesMap .
rr:predicateObjectMap :hasCoordinatesMap ;
rr:predicateObjectMap :lineHasStyleMap .

:CenterLineAfterComponentMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine[preceding-sibling::PipingComponent]"
];
rr:subjectMap [
rr:template "https://assetid.equinor.com/plantx/{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}/lines#{preceding-sibling::PipingComponent[1]/@ID}-node2";
rr:termType rr:IRI;
rr:class graphic:Line
] ;
rr:predicateObjectMap :hasCoordinatesMap ;
rr:predicateObjectMap :lineHasStyleMap .

:coordinateListContentMap a rr:PredicateObjectMap;
rr:predicate rdf:first;
rr:objectMap [
a rr:RefObjectMap ;
rr:parentTriplesMap :CoordinateMap ;
rr:joinCondition [
rr:child "../../@ID";
rr:parent "../../@ID";
], [
rr:child "../position()";
rr:parent "../position()";
], [
rr:child "../../position()";
rr:parent "../../position()";
:CenterLineFromMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine[../Connection/@FromID]"
];
rr:subjectMap [
rr:template "https://assetid.equinor.com/plantx/{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}/lines#{../Connection/@FromID}-node{../Connection/@FromNode}";
rr:termType rr:IRI;
rr:class graphic:Line
] ;
rr:predicateObjectMap :hasCoordinatesMap ;
rr:predicateObjectMap :lineHasStyleMap .

:CenterLineToIdMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine[../Connection/@ToID]"
];
rr:subjectMap [
rr:template "https://assetid.equinor.com/plantx/{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}/lines#{../Connection/@ToID}-node{../Connection/@ToNode}";
rr:termType rr:IRI;
rr:class graphic:Line
] ;
rr:predicateObjectMap :hasCoordinatesMap ;
rr:predicateObjectMap :lineHasStyleMap .

:lineHasStyleMap a rr:PredicateObjectMap;
rr:predicate graphic:hasStyle;
rr:objectMap [
a rr:RefObjectMap ;
rr:parentTriplesMap :LineStyleMap ;
rr:joinCondition [
rr:child "../@ID";
rr:parent "../@ID";
], [
rr:child "position()";
rr:parent "position()";
]
].
] .

:LineStyleMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../@ID}_{count(preceding-sibling::CenterLine)}_linestyle";
rr:termType rr:BlankNode
] ;
rr:predicateObjectMap [
rr:predicate graphic:hasStroke;
rr:objectMap [
a rr:RefObjectMap ;
rr:parentTriplesMap :LineStrokeMap ;
rr:joinCondition [
rr:child "../@ID";
rr:parent "../@ID";
], [
rr:child "position()";
rr:parent "position()";
]
]
].


:LineStrokeMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../@ID}_{count(preceding-sibling::CenterLine)}_linestroke";
rr:termType rr:BlankNode ;
rr:class graphic:Stroke
] ;
rr:predicateObjectMap [
rr:predicate graphic:dasharray;
rr:objectMap [
rr:constant "none";
]
] , [
rr:predicate graphic:width;
rr:objectMap [
rr:constant "0.25"^^xsd:double;
rr:datatype xsd:double;
]
]
.


:CoordinateListMap a rr:TriplesMap;
Expand All @@ -70,10 +157,13 @@
rml:iterator "//*/CenterLine/Coordinate[position() = 1]"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../position()}_{position()}_coordinateListElement";
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../count(preceding-sibling::CenterLine)}_{count(preceding-sibling::Coordinate)}_coordinateListElement";
rr:termType rr:BlankNode;
];
rr:predicateObjectMap :coordinateListContentMap .
rr:predicateObjectMap
:coordinateListContentMap,
:restOfCoordinateListMap
.


:CoordinateListElementMap a rr:TriplesMap;
Expand All @@ -83,41 +173,95 @@
rml:iterator "//*/CenterLine/Coordinate[position() != last() and position() > 1]"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../position()}_{position()}_coordinateListElement";
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../count(preceding-sibling::CenterLine)}_{count(preceding-sibling::Coordinate)}_coordinateListElement";
rr:termType rr:BlankNode;
];
rr:predicateObjectMap :coordinateListContentMap .
# ];
# rr:predicateObjectMap [
# rr:predicate rdf:rest;
# rr:objectMap [
# rr:parentTriplesMap :CoordinateListMap ;

# ]
rr:predicateObjectMap
:coordinateListContentMap,
:restOfCoordinateListMap
.



:CoordinateListLastElementMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine/Coordinate[position() = last()]"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../count(preceding-sibling::CenterLine)}_{count(preceding-sibling::CenterLine)}_coordinateListElement";
rr:termType rr:BlankNode;
];
rr:predicateObjectMap :coordinateListContentMap,
[
rr:predicate rdf:rest;
rr:objectMap [
rr:constant rdf:nil;
]
].

:restOfCoordinateListMap a rr:PredicateObjectMap;
rr:predicate rdf:rest;
rr:objectMap [
rr:parentTriplesMap :CoordinateListElementMap ;
a rr:RefObjectMap ;
rr:joinCondition :nextCoordinateListElementJoinConditionId, :nextCoordinateListElementJoinConditionCenterLine, :nextCoordinateListElementJoinConditionCoordinate
] , [
rr:parentTriplesMap :CoordinateListLastElementMap ;
a rr:RefObjectMap ;
rr:joinCondition :nextCoordinateListElementJoinConditionId
, :nextCoordinateListElementJoinConditionCenterLine
, :nextCoordinateListElementJoinConditionCoordinate
].

:nextCoordinateListElementJoinConditionId
rr:child "../../@ID";
rr:parent "../../@ID".
:nextCoordinateListElementJoinConditionCenterLine
rr:child "../count(preceding-sibling::CenterLine)";
rr:parent "../count(preceding-sibling::CenterLine)".
:nextCoordinateListElementJoinConditionCoordinate
rr:child "count(preceding-sibling::Coordinate)";
rr:parent "count(preceding-sibling::Coordinate)+1".

:coordinateListContentMap a rr:PredicateObjectMap;
rr:predicate rdf:first;
rr:objectMap [
a rr:RefObjectMap ;
rr:parentTriplesMap :CoordinateMap ;
rr:joinCondition
:nextCoordinateListElementJoinConditionId,
:nextCoordinateListElementJoinConditionCenterLine ,
[
rr:child "count(preceding-sibling::Coordinate)";
rr:parent "count(preceding-sibling::Coordinate)";
]
].


:CoordinateMap a rr:TriplesMap;
rml:logicalSource [
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//*/CenterLine/Coordinate"
];
rr:subjectMap [
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../position()}_{position()}_coordinate";
rr:template "{/PlantModel/MetaData/GenericAttributes/GenericAttribute[@Name='DrawingNumberAssignmentClass']/@Value}_{../../@ID}_{../count(preceding-sibling::CenterLine)}_{count(preceding-sibling::Coordinate)}_coordinate";
rr:termType rr:BlankNode;
];
rr:predicateObjectMap [
rr:predicate graphic:x;
rr:objectMap [
rml:reference "@X";
rr:datatype xsd:integer;
rr:datatype xsd:double;
]
];
rr:predicateObjectMap [
rr:predicate graphic:y;
rr:objectMap [
rml:reference "@Y";
rr:datatype xsd:integer;
rr:datatype xsd:double;
]
]
.
13 changes: 6 additions & 7 deletions shacl/graphic-dexpi.shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@
sh:maxCount 1;
sh:node :StrokeShape ;
] ;
sh:property [
sh:path :hasStyle ;
sh:maxCount 1;
sh:datatype css:style ;
] ;
sh:closed true.

:StrokeShape a sh:NodeShape ;
Expand All @@ -179,12 +174,16 @@
sh:datatype xsd:string ;
], [
sh:path :width ;
sh:datatype xsd:decimal ;
sh:datatype xsd:double ;
sh:minCount 1;
sh:maxCount 1;
sh:message "A stroke must specify a width";
] , [
sh:path :color ;
sh:minCount 1;
sh:minCount 0;
sh:maxCount 1;
sh:node :ColorShape ;
sh:message "A stroke can have at most one color";
], [
sh:path rdf:type;
];
Expand Down

0 comments on commit 934f604

Please sign in to comment.