Skip to content

Commit

Permalink
feat: historical imagery providers (TDE-146) (#141)
Browse files Browse the repository at this point in the history
* feat: providers required for historical imagery collection

* test: added historical imagery collection providers tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
amfage and kodiakhq[bot] authored Nov 1, 2021
1 parent 14befef commit 997ebcf
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 4 deletions.
15 changes: 14 additions & 1 deletion extensions/historical-imagery/examples/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
"interval": [["1947-03-28T12:00:00.000Z", "1952-04-22T12:00:00.000Z"]]
}
},
"providers": [
{
"name": "NZ Aerial Mapping",
"description": "Aerial survey and geospatial services firm. Went into liquidation in 2014.",
"roles": ["producer"]
},
{
"name": "Toitū Te Whenua LINZ",
"description": "The New Zealand Government's lead agency for location and property information, Crown land and managing overseas investment.",
"roles": ["host", "licensor", "processor"],
"url": "https://www.linz.govt.nz/about-linz/what-were-doing/projects/crown-aerial-film-archive-historical-imagery-scanning-project"
}
],
"summaries": {
"platform": ["Fixed-wing Aircraft"],
"instruments": ["EAGLE IV"],
Expand Down Expand Up @@ -72,7 +85,7 @@
"minimum": 2193,
"maximum": 2193
},
"aerial-photo:altitide": {
"aerial-photo:altitude": {
"minimum": 10000,
"maximum": 11000
},
Expand Down
63 changes: 60 additions & 3 deletions extensions/historical-imagery/schema.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://linz.github.io/stac/_STAC_VERSION_/historical-imagery/schema.json",
"title": "historical Imagery Extension",
"description": "STAC historical Imagery Extension for STAC Items and STAC Collections.",
"title": "Historical Imagery Extension",
"description": "STAC Historical Imagery Extension for STAC Items and STAC Collections.",
"oneOf": [
{
"$comment": "This is the schema for STAC Items.",
Expand Down Expand Up @@ -38,13 +38,16 @@
"allOf": [
{
"type": "object",
"required": ["type", "title"],
"required": ["type", "title", "providers"],
"properties": {
"type": {
"const": "Collection"
}
}
},
{
"$ref": "#/definitions/fields_collection"
},
{
"$ref": "#/definitions/stac_extensions_collection"
}
Expand Down Expand Up @@ -114,6 +117,60 @@
}
}
}
},
"fields_collection": {
"type": "object",
"$comment": "Remove licensor and producer when validation against linz STAC extension is included.",
"properties": {
"providers": {
"allOf": [
{
"contains": {
"properties": {
"roles": {
"contains": {
"const": "licensor"
}
}
}
}
},
{
"contains": {
"properties": {
"roles": {
"contains": {
"const": "producer"
}
}
}
}
},
{
"contains": {
"properties": {
"roles": {
"contains": {
"const": "processor"
}
}
}
}
},
{
"contains": {
"properties": {
"roles": {
"contains": {
"const": "host"
}
}
}
}
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,38 @@ o.spec('historical-imagery collection', () => {
JSON.stringify(validate.errors),
);
});

o("Example without 'providers' should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example.providers;

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(validate.errors.some((error) => error.message === "should have required property '.providers'")).equals(true)(
JSON.stringify(validate.errors),
);
});

o('Collection without required provider roles should fail validation', async () => {
// given
for (const role of ['producer', 'licensor', 'processor', 'host']) {
const example = JSON.parse(await fs.readFile(examplePath));
example.providers = example.providers.filter((provider) => !role in provider.roles);

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) => error.dataPath === '.providers' && error.message === 'should contain a valid item',
),
).equals(true)(JSON.stringify(validate.errors));
}
});
});

0 comments on commit 997ebcf

Please sign in to comment.