Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Validate Building Blocks PR
on:
pull_request:

# Read-only validation: runs postprocessing against the PR to catch things
# like broken bblock dependencies before merge, but never commits, deploys,
# or pushes anything - see process-bblocks.yml for the workflow that does.
#
# NOTE: if this repo overrides items_dir/register_file/generated_docs_path/
# annotated_path/test_outputs_path/config_file in process-bblocks.yml below,
# pass the same overrides here, or this check will run against the wrong
# paths.
jobs:
pr-check:
name: Validate PR
uses: opengeospatial/bblocks-postprocess/.github/workflows/pr-check.yml@master
100 changes: 100 additions & 0 deletions README.md.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# OGC Building Blocks for SOSA

The SOSA ([Sensor, Observation, Sample, and Actuator](https://www.w3.org/TR/vocab-ssn/)) ontology is a realisation of the
Observations, Measurements and Sampling (OMS) Conceptual model. This repository defines:
* JSON schema encoding for each feature type (class) defined by SOSA, compatible with the OGC API Features using the FG-JSON extension to GeoJSON
* JSON-LD contexts for each class to link schema elements to relevant class and properties defined by SOSA
* examples that can be used in documentation
* validation resources for this schema and the JSON-LD RDF binding

This encoding is defined using the [OGC Building Blocks template](https://opengeospatial.github.io/bblock-template) template, and hence can be combined with other Building Blocks to implement more complete domain models with interoperable encodings and extensible APIs.

## Status and Compatibility

This building block is __under construction__ and is undertaken in the context of the update of SOSA to align with OMS V3.

It is assumed that this will be backwards compatible with the last published SOSA version https://www.w3.org/TR/2017/REC-vocab-ssn-20171019/. Any changes to this status will be noted in this section.

## General Building block repository structure


The `build/` directory contains the **_reusable assets_** for implementing this building block, in full or part, and the rest of the repository contain *sources* to build these assets. *Sources* minimise redundant information and preserve original forms of inputs, such as externally published schemas etc. This allow these to be updated safely, and also allows for alternative forms of original source material to be used whilst preserving uniformity of the reusable assets.

![Usage](usage.png)


* The `build/` directory should never be edited
* Only resources in the `build/` directory should be used by applications

### Ready to use components

- `build/`: the available versions of the building block ready for reuse

Note that the these components will be consistently structured for a given type of building block, and the editable components may vary according to the source material used to derive the building block, and therefore cannot be directly referenced.

### Editable components

- `features/`: schemas for the feature types defined by this bb (which is a "super-bb" containing at least oneOf these defined features)
- `datatypes/`: reusable schemas for (potentially complex) datatypes defined by this bb
- `aspects/`: groups of properties that may be included in feature types (equivalent to attribute groups in XML schema)
- `assets/`: Documentation assets (e.g. images) directory. See [Assets](#assets) below.


### Individual building block structure

After building each of the building blocks (including any top-level composite building block) contains the following files:

- `bblock.json`: Contains the metadata for the building block.
- `description.md`: Human-readable, Markdown document with the description of this building block.
- `examples.yaml`: A list of examples for this building block. See [Examples](#examples) below.
- `schema.yaml`: JSON schema using YAML syntax for this building block, if any. See [JSON schema](#json-schema) below.
- `schema.json`: equivalent JSON schema using JSON syntax.

Note: some these files may not be present in the **source* - for example a description could be extracted from the model referenced in the schema or bblock.json metadata.

Note: the top level building block schemas may be generated from the components automatically.


## Building Block identifiers

These are automatically generated in the form:

```
<identifier-prefix><bb-path>
```

where:

- `identifier-prefix` is read from `bblocks-config.yaml`. This will initially be a placeholder value,
but should have an official value eventually (see [How-to](#how-to)).
- `bb-path` is the dot-separated path to the building block inside the repository.

## Examples

Each example consists of Markdown `content` and/or a list of `snippets`. `snippets`, in turn,
have a `language` (for highlighting, language tabs in Slate, etc.) and the `code` itself.

Each class supported by this building block has an
`examples.yaml` file. (`examples.json` may be used as an alternative.)


## Postprocessing overview

*TBD: this section to be automatically inserted from the template.*

This repository comes with a GitHub workflow that detects, validates and processes its building blocks,
so that their outputs can be tested before inclusion in the main OGC Register:

![OGC Building Blocks processing](https://raw.githubusercontent.com/avillar/bblocks-postprocess/master/process.png)

### Output testing

The outputs can be generated locally by running the following (*Note: Docker must be installed locally*):

```shell
# Process building blocks
docker run --rm --workdir /workspace -v $(pwd):/workspace ghcr.io/avillar/bblocks-postprocess
# Optional - build Slate docs
docker run --rm -v "$(pwd)/generateddocs/slate:/srv/slate/source" \
-v "$(pwd)/generateddocs/slate-build:/srv/slate/build" slatedocs/slate build
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "SOSA Observation Feature",
"abstract": "This building blocks defines a GeoJSON feature containing a SOSA Observation",
"status": "under-development",
"dateTimeAddition": "2023-05-18T00:00:00Z",
"itemClass": "schema",
"register": "ogc-building-block-register",
"version": "1.0",
"dateOfLastChange": "2023-05-18",
"sources": [
{
"title": "Semantic Sensor Network Ontology",
"link": "https://www.w3.org/TR/vocab-ssn/"
}
],
"maturity": "development",
"scope": "unstable",
"dependsOn": [
"ogc.unstable.sosa.properties.observation"
],
"tags": [
"sosa",
"ssn",
"observations",
"o&m",
"o&m&s"
],
"group": "SOSA"
}
20 changes: 15 additions & 5 deletions _sources/features/observation/semantic-uplift/featureType.shacl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@
sh:targetSubjectsOf
sosa:hasResult
;
# Need to add logic that has no member or inverse memberOf relationships
# These properties may also be held in common at the ObservationCollection level
# (sosa:hasMember / geojson:features), so only infer sosa:Observation when the
# subject is not itself acting as a collection.
sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate rdf:type ;
sh:object sosa:Observation ;
a sh:SPARQLRule ;
sh:prefixes [
sh:declare [ sh:prefix "sosa" ; sh:namespace "http://www.w3.org/ns/sosa/"^^<http://www.w3.org/2001/XMLSchema#anyURI> ] ;
sh:declare [ sh:prefix "geojson" ; sh:namespace "https://purl.org/geojson/vocab#"^^<http://www.w3.org/2001/XMLSchema#anyURI> ] ;
] ;
sh:construct """
CONSTRUCT { $this a sosa:Observation . }
WHERE {
FILTER NOT EXISTS { $this sosa:hasMember ?member . }
FILTER NOT EXISTS { $this geojson:features ?feature . }
}
""" ;
] ;
.

Expand Down
3 changes: 2 additions & 1 deletion _sources/features/observationCollection/bblock.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
"o&m",
"o&m&s"
],
"group": "SOSA"
"group": "SOSA",
"highlighted": true
}
23 changes: 23 additions & 0 deletions _sources/features/observationCollection/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "schema.json",
"@id": "c1",
"type": "Feature",
"featureType": "sosa:ObservationCollection",
"properties": {
"observedProperty": "http://dbpedia.org/ontology/population",
"resultTime": "1999",
"features": [
{
"@id": "pop1999",
"comment": "Example of an inline membership - would entail hasMember relations",
"hasFeatureOfInterest": "https://demo.pygeoapi.io/master/collections/utah_city_locations/items/Spanish%20Fork",
"hasSimpleResult": 15555.0
},
{
"@id": "pop1999",
"hasFeatureOfInterest": "https://demo.pygeoapi.io/master/collections/utah_city_locations/items/Salem",
"hasSimpleResult": 3275.0
}
]
},
}
21 changes: 20 additions & 1 deletion _sources/features/observationCollection/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,23 @@
<http://dbpedia.org/ontology/population> a skos:Concept;
skos:prefLabel "Population";
.



- title: Example of nested SOSA ObservationCollections with an inline Feature of Interest geometry
comment: |-
An ObservationCollection Feature's `features` array can itself contain nested
ObservationCollection Features, not just individual Observations - a
FeatureCollection cannot appear as a `features` member, so each nested
collection is a `Feature` whose members are held in `properties.hasMember`
rather than a further `features` array. Common properties are held at the
level of the collection that shares them, rather than repeated on every
member: the outer collection declares `resultTime` and an inline
`hasFeatureOfInterest` (with a sample `Point` geometry) shared by every
observation in the whole tree; each inner sub-collection declares its own
`observedProperty`, shared only by its own member observations, which in
turn carry nothing but their individual `phenomenonTime` and result.

snippets:
- language: json
ref: examples/observationCollection-foi-geometry.json
base-uri: http://example.com/
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"type": "FeatureCollection",
"featureType": "sosa:ObservationCollection",
"properties": {
"resultTime": "2022-05-01T22:33:44Z",
"hasFeatureOfInterest": {
"@id": "https://demo.pygeoapi.io/master/collections/utah_city_locations/items/Salem",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-111.6738, 40.0518]
},
"properties": {
"name": "Salem, Utah"
}
}
},
"features": [
{
"@id": "temperature-collection",
"type": "Feature",
"featureType": "sosa:ObservationCollection",
"geometry": null,
"properties": {
"observedProperty": "https://example.org/properties/temperature",
"hasMember": [
{
"@id": "obs-temp-1",
"phenomenonTime": "2022-05-01T22:33:40Z",
"hasSimpleResult": 21.4
},
{
"@id": "obs-temp-2",
"phenomenonTime": "2022-05-01T22:34:10Z",
"hasSimpleResult": 21.6
}
]
}
},
{
"@id": "humidity-collection",
"type": "Feature",
"featureType": "sosa:ObservationCollection",
"geometry": null,
"properties": {
"observedProperty": "https://example.org/properties/humidity",
"hasMember": [
{
"@id": "obs-hum-1",
"phenomenonTime": "2022-05-01T22:33:40Z",
"hasSimpleResult": 58.2
},
{
"@id": "obs-hum-2",
"phenomenonTime": "2022-05-01T22:34:10Z",
"hasSimpleResult": 57.9
}
]
}
}
]
}
12 changes: 12 additions & 0 deletions _sources/features/observationCollection/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ allOf:
oneOf:
# Embedded observations
- $ref: ../observation/schema.yaml
# Embedded nested ObservationCollection. A FeatureCollection cannot itself
# be a `features` member (json-fg.featureCollection-lenient constrains
# `features` to Features only), so a nested collection is still a plain
# Feature - any further nesting continues via `properties.hasMember`
# (see properties/observationCollection/schema.yaml), not another
# `features` array.
- allOf:
- $ref: bblocks://ogc.geo.json-fg.feature-lenient
- type: object
properties:
properties:
$ref: ../../properties/observationCollection/schema.yaml
# Ids/URIs
- type: string
Loading