Skip to content

Commit b6a9a8a

Browse files
committed
Add SHACL shapes and test resources for Feature and FeatureCollection; fix missing @type in feature context
1 parent c179e45 commit b6a9a8a

19 files changed

Lines changed: 540 additions & 0 deletions

‎registereditems/geo/features/feature/context.jsonld‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"geojson": "https://purl.org/geojson/vocab#",
55
"links": "rdfs:seeAlso",
66
"properties": "@nest",
7+
"type": "@type",
78
"features": {
89
"@container": "@set",
910
"@id": "geojson:features"
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
@prefix sh: <http://www.w3.org/ns/shacl#> .
2+
@prefix geojson: <https://purl.org/geojson/vocab#> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix oa: <http://www.w3.org/ns/oa#> .
6+
@prefix dct: <http://purl.org/dc/terms/> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
@prefix iana-rel: <http://www.iana.org/assignments/relation/> .
9+
10+
#
11+
# GeoJSON Feature shape
12+
#
13+
14+
geojson:FeatureShape
15+
a sh:NodeShape ;
16+
sh:targetClass geojson:Feature ;
17+
sh:name "GeoJSON Feature" ;
18+
sh:description "Validates a GeoJSON Feature as uplifted to RDF via the OGC GeoJSON building block." ;
19+
20+
# geometry is optional (null geometry produces no RDF triple); at most one
21+
sh:property [
22+
sh:path geojson:geometry ;
23+
sh:name "geometry" ;
24+
sh:description "A Feature may have at most one geometry value; null geometry produces no RDF triple." ;
25+
sh:maxCount 1 ;
26+
sh:nodeKind sh:BlankNodeOrIRI ;
27+
sh:node geojson:GeometryShape ;
28+
] ;
29+
30+
# bbox is optional; when present it must be a single RDF list (blank node head)
31+
sh:property [
32+
sh:path geojson:bbox ;
33+
sh:name "bbox" ;
34+
sh:maxCount 1 ;
35+
sh:nodeKind sh:BlankNode ;
36+
] ;
37+
38+
# links (rdfs:seeAlso) are optional; each must conform to LinkShape
39+
sh:property [
40+
sh:path rdfs:seeAlso ;
41+
sh:name "links" ;
42+
sh:node geojson:LinkShape ;
43+
] .
44+
45+
46+
#
47+
# GeoJSON Geometry shape
48+
#
49+
50+
geojson:GeometryShape
51+
a sh:NodeShape ;
52+
sh:name "GeoJSON Geometry" ;
53+
sh:description "A GeoJSON geometry object: must carry a recognised geometry type and either coordinates (simple geometries) or member geometries (GeometryCollection)." ;
54+
55+
# rdf:type must be one of the seven GeoJSON geometry classes
56+
sh:property [
57+
sh:path rdf:type ;
58+
sh:name "geometry type" ;
59+
sh:description "Geometry type must be one of the seven GeoJSON geometry classes." ;
60+
sh:minCount 1 ;
61+
sh:in (
62+
geojson:Point
63+
geojson:MultiPoint
64+
geojson:LineString
65+
geojson:MultiLineString
66+
geojson:Polygon
67+
geojson:MultiPolygon
68+
geojson:GeometryCollection
69+
) ;
70+
] ;
71+
72+
# either coordinates (simple geometry) or geojson:geometries (collection) must be present
73+
sh:or (
74+
# simple geometry: has exactly one coordinates list
75+
[
76+
sh:property [
77+
sh:path geojson:coordinates ;
78+
sh:name "coordinates" ;
79+
sh:minCount 1 ;
80+
sh:maxCount 1 ;
81+
sh:nodeKind sh:BlankNode ; # RDF list head is always a blank node
82+
]
83+
]
84+
# geometry collection: typed as GeometryCollection and has at least one member
85+
[
86+
sh:class geojson:GeometryCollection ;
87+
sh:property [
88+
sh:path geojson:geometries ;
89+
sh:name "geometries" ;
90+
sh:minCount 1 ;
91+
]
92+
]
93+
) .
94+
95+
96+
#
97+
# Link (rdfs:seeAlso) shape
98+
#
99+
100+
geojson:LinkShape
101+
a sh:NodeShape ;
102+
sh:name "OGC JSON Link" ;
103+
sh:description "Validates a link object as uplifted from the OGC JSON Link building block." ;
104+
105+
# href (oa:hasTarget) is required and must be an IRI
106+
sh:property [
107+
sh:path oa:hasTarget ;
108+
sh:name "href" ;
109+
sh:description "Link href must be present as an IRI." ;
110+
sh:minCount 1 ;
111+
sh:maxCount 1 ;
112+
sh:nodeKind sh:IRI ;
113+
] ;
114+
115+
# rel (IANA relation) is optional and must be an IRI when present
116+
sh:property [
117+
sh:path <http://www.iana.org/assignments/relation> ;
118+
sh:name "rel" ;
119+
sh:maxCount 1 ;
120+
sh:nodeKind sh:IRI ;
121+
] ;
122+
123+
# type → dct:type, optional string
124+
sh:property [
125+
sh:path dct:type ;
126+
sh:name "type" ;
127+
sh:maxCount 1 ;
128+
sh:datatype xsd:string ;
129+
] ;
130+
131+
# hreflang → dct:language, optional string
132+
sh:property [
133+
sh:path dct:language ;
134+
sh:name "hreflang" ;
135+
sh:maxCount 1 ;
136+
sh:datatype xsd:string ;
137+
] ;
138+
139+
# title → rdfs:label, optional string
140+
sh:property [
141+
sh:path rdfs:label ;
142+
sh:name "title" ;
143+
sh:maxCount 1 ;
144+
sh:datatype xsd:string ;
145+
] ;
146+
147+
# length → dct:extent, optional non-negative integer
148+
sh:property [
149+
sh:path dct:extent ;
150+
sh:name "length" ;
151+
sh:maxCount 1 ;
152+
sh:datatype xsd:integer ;
153+
] .
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@prefix geojson: <https://purl.org/geojson/vocab#> .
2+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3+
4+
# Link (rdfs:seeAlso) present but with no oa:hasTarget (href).
5+
# Must fail the sh:minCount 1 on oa:hasTarget inside LinkShape.
6+
<http://www.example.com/features/bad-link1> a geojson:Feature ;
7+
geojson:geometry [
8+
a geojson:Point ;
9+
geojson:coordinates ( 174.7 -36.9 )
10+
] ;
11+
rdfs:seeAlso [ ] .
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"id": "http://www.example.com/features/bad2",
3+
"type": "Feature",
4+
"properties": {
5+
"note": "geometry key is absent, not null — fails JSON schema"
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "http://www.example.com/features/bad1",
3+
"geometry": {
4+
"type": "Point",
5+
"coordinates": [174.7, -36.9]
6+
},
7+
"properties": {}
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@prefix geojson: <https://purl.org/geojson/vocab#> .
2+
3+
# A Feature with null geometry produces no geojson:geometry triple after uplift.
4+
# The SHACL shape imposes no minCount on geometry, so this must pass.
5+
<http://www.example.com/features/nogeom2> a geojson:Feature .
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "http://www.example.com/features/nogeom1",
3+
"type": "Feature",
4+
"geometry": null,
5+
"properties": {
6+
"note": "Null geometry is valid per RFC 7946"
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@prefix geojson: <https://purl.org/geojson/vocab#> .
2+
3+
# Point geometry with no geojson:coordinates triple.
4+
# Must fail the sh:or in GeometryShape: neither branch is satisfied
5+
# (not a GeometryCollection, and no coordinates present).
6+
<http://www.example.com/features/bad-geom2> a geojson:Feature ;
7+
geojson:geometry [ a geojson:Point ] .
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"id": "http://www.example.com/features/point1",
3+
"type": "Feature",
4+
"geometry": {
5+
"type": "Point",
6+
"coordinates": [174.7501603083, -36.9307359096]
7+
},
8+
"properties": {
9+
"name": "Test point feature"
10+
}
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@prefix geojson: <https://purl.org/geojson/vocab#> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
4+
<http://www.example.com/features/polygon1> a geojson:Feature ;
5+
geojson:geometry [
6+
a geojson:Polygon ;
7+
geojson:coordinates (
8+
( (174.0 -36.0) (175.0 -36.0) (175.0 -37.0) (174.0 -37.0) (174.0 -36.0) )
9+
)
10+
] .

0 commit comments

Comments
 (0)