Skip to content

Instantly share code, notes, and snippets.

@ashleysommer
Created May 15, 2024 21:28
Show Gist options
  • Save ashleysommer/4a87ff274d7639c4b0e9dcdba3eb72aa to your computer and use it in GitHub Desktop.
Save ashleysommer/4a87ff274d7639c4b0e9dcdba3eb72aa to your computer and use it in GitHub Desktop.
test_231.py
# -*- coding: utf-8 -*-
#
"""
https://github.com/RDFLib/pySHACL/issues/231
"""
import sys
import rdflib
import pyshacl
shapes_data = '''\
@prefix ex: <http://example.org/ontology/> .
@prefix sh-ex: <http://example.org/shapes/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix citygml: <http://example.org/ontology/citygml#> .
sh-ex:my_shape a sh:NodeShape ;
sh:targetClass citygml:WallSurfaceType ;
sh:property
<http://www.opengis.net/ont/sf#Polygon-isNormalsDeviated> .
<http://www.opengis.net/ont/sf#Polygon-isNormalsDeviated> a sh:PropertyShape ;
sh:hasValue false ;
sh:path <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#isNormalsDeviated> .
'''
data_g_text = '''\
@prefix ex: <http://example.org/ontology/> .
@prefix citygml: <http://example.org/ontology/citygml#> .
@prefix brep: <http://example.org/ontology/brep#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sf: <http://www.opengis.net/ont/sf#> .
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
@prefix valid: <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#> .
ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9_4 a sf:Polygon, citygml:WallSurfaceType ;
geo:asWKT "POLYGON Z ((78864.787 457866.289 10.244, 78866.931 457863.129 10.244, 78865.859 457864.71 12.256, 78864.787 457866.289 10.244))"^^geo:wktLiteral ;
citygml:parent ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9 ;
brep:directionNormalX -8.275105e-01 ;
brep:directionNormalY -5.614502e-01 ;
brep:directionNormalZ 2.790508e-04 ;
valid:consecutiveSamePoints false ;
valid:hasDuplicatedRings false ;
valid:hasHoleOutside false ;
valid:hasInnerNestedRings false ;
valid:hasInteriorDisconnected false ;
valid:hasIntersectedRings false ;
valid:isCcwise true ;
valid:isClosed false ;
valid:isCollapsedtoLine false ;
valid:isCoplanar false ;
valid:isNormalsDeviated false ;
valid:noSelfIntersection true ;
valid:tooFewPoints false ;
valid:wallSurfaceNormals true .
'''
def test_231():
shape_g = rdflib.Graph().parse(data=shapes_data, format='turtle')
data_g = rdflib.Graph().parse(data=data_g_text, format="turtle")
conforms, results_graph, results_text = pyshacl.validate(
data_g,
shacl_graph=shape_g,
debug=True,
meta_shacl=False,
)
assert conforms
if __name__ == "__main__":
sys.exit(test_231())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment