Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ME: iso19139 spatial extents #944

Merged
merged 4 commits into from
Aug 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ Ce lot de données produit en 2019, a été numérisé à partir du PCI Vecteur
securityConstraints: [],
otherConstraints: [],
// data quality?
spatialExtents: [],
spatialExtents: [
{
bbox: [2.5587, 49.3677, 2.5934, 49.4051],
},
],
temporalExtents: [],
status: 'completed',
updateFrequency: 'unknown',
Expand Down
49 changes: 37 additions & 12 deletions libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -105,7 +105,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -116,7 +116,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -127,7 +127,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -138,7 +138,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -149,7 +149,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -160,7 +160,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -171,7 +171,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -182,7 +182,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.gemet',
name: 'GEMET',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.gemet'
),
},
type: 'theme',
Expand All @@ -193,7 +193,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.inspire-theme',
name: 'GEMET - INSPIRE themes, version 1.0',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.inspire-theme'
),
},
type: 'theme',
Expand All @@ -204,7 +204,7 @@ export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = {
id: 'geonetwork.thesaurus.external.theme.inspire-theme',
name: 'GEMET - INSPIRE themes, version 1.0',
url: new URL(
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/local.theme.geocat.ch'
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/registries/vocabularies/external.theme.inspire-theme'
),
},
type: 'theme',
Expand Down Expand Up @@ -332,7 +332,32 @@ Die Quelle ist zu bezeichnen: „Quelle: Stadt Zürich“.`,
securityConstraints: [],
otherConstraints: [],
// data quality?
spatialExtents: [],
spatialExtents: [
{
description: 'AK',
},
{
bbox: [
6.75599105586694, 45.7887442565203, 10.5418236945627, 47.5175655551557,
],
},
{
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[6.777075, 45.827119, 0],
[6.755991, 47.517566, 0],
[10.541824, 47.477984, 0],
[10.446252, 45.788744, 0],
[6.777075, 45.827119, 0],
],
],
],
},
},
],
temporalExtents: [],
status: 'completed',
updateFrequency: 'asNeeded',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,11 @@ Depuis, ce sont les Districts routiers qui assurent la tenue à jour de ces info
name: 'Direction Asset Management (SPW - Mobilité et Infrastructures - Direction Asset Management)',
},
securityConstraints: [],
spatialExtents: [],
spatialExtents: [
{
bbox: [2.75, 49.45, 6.5, 50.85],
},
],
spatialRepresentation: 'vector',
status: 'ongoing',
temporalExtents: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
readResourcePublished,
readResourceUpdated,
readSecurityConstraints,
readSpatialExtents,
readSpatialRepresentation,
readStatus,
readTemporalExtents,
Expand All @@ -60,6 +61,7 @@ import {
writeResourcePublished,
writeResourceUpdated,
writeSecurityConstraints,
writeSpatialExtents,
writeSpatialRepresentation,
writeStatus,
writeTemporalExtents,
Expand Down Expand Up @@ -101,8 +103,8 @@ export class Iso19139Converter extends BaseConverter<string> {
distributions: readDistributions,
onlineResources: readOnlineResources,
temporalExtents: readTemporalExtents,
spatialExtents: readSpatialExtents,
// TODO
spatialExtents: () => [],
extras: () => undefined,
landingPage: () => undefined,
languages: () => [],
Expand Down Expand Up @@ -139,8 +141,8 @@ export class Iso19139Converter extends BaseConverter<string> {
distributions: writeDistributions,
onlineResources: writeOnlineResources,
temporalExtents: writeTemporalExtents,
spatialExtents: () => writeSpatialExtents,
// TODO
spatialExtents: () => undefined,
extras: () => undefined,
landingPage: () => undefined,
languages: () => undefined,
Expand Down
126 changes: 125 additions & 1 deletion libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore
// @ts-ignore
import GEOCAT_CH_DATASET from '../fixtures/geocat-ch.iso19139.dataset.xml'
// @ts-ignore
import { XmlElement } from '@rgrove/parse-xml'
// @ts-ignore
import GEOCAT_CH_SERVICE from '../fixtures/geocat-ch.iso19139.service.xml'
import { pipe } from '../function-utils'
import {
Expand All @@ -20,6 +20,7 @@ import {
readDistributions,
readOnlineResources,
readOwnerOrganization,
readSpatialExtents,
readTemporalExtents,
} from './read-parts'

Expand Down Expand Up @@ -379,6 +380,129 @@ describe('read parts', () => {
})
})
})
describe('readSpatialExtents', () => {
describe('no spatial extent', () => {
beforeEach(() => {
pipe(
findIdentification(),
findNestedElement('gmd:extent', 'gmd:EX_Extent'),
removeChildrenByName('gmd:geographicElement')
)(recordRootEl)
})
it('returns an empty array', () => {
expect(readSpatialExtents(recordRootEl)).toEqual([])
})
})
describe('one spatial extent with one geometry, one bbox and one description', () => {
beforeEach(() => {
const spatialExtent = getRootElement(
parseXmlString(`
<gmd:geographicElement>
<gmd:EX_GeographicDescription>
<gmd:geographicIdentifier>
<gmd:MD_Identifier>
<gmd:code>
<gco:CharacterString>AK</gco:CharacterString>
</gmd:code>
</gmd:MD_Identifier>
</gmd:geographicIdentifier>
</gmd:EX_GeographicDescription>
<gmd:EX_GeographicBoundingBox>
<gmd:westBoundLongitude>
<gco:Decimal>6.75599105586694</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
<gco:Decimal>10.5418236945627</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>45.7887442565203</gco:Decimal>
</gmd:southBoundLatitude>
<gmd:northBoundLatitude>
<gco:Decimal>47.5175655551557</gco:Decimal>
</gmd:northBoundLatitude>
</gmd:EX_GeographicBoundingBox>
<gmd:EX_BoundingPolygon>
<gmd:polygon>
<gml:MultiSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">6.777075 45.827119 6.755991 47.517566 10.541824 47.477984 10.446252 45.788744 6.777075 45.827119</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</gmd:polygon>
</gmd:EX_BoundingPolygon>
</gmd:geographicElement>`)
)
pipe(
findIdentification(),
findNestedElement('gmd:extent', 'gmd:EX_Extent'),
removeChildrenByName('gmd:geographicElement'),
appendChildren(() => spatialExtent)
)(recordRootEl)
})
it('returns an array of spatial extents with geometries, bbox and description', () => {
expect(readSpatialExtents(recordRootEl)).toEqual([
{
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[6.777075, 45.827119, 0],
[6.755991, 47.517566, 0],
[10.541824, 47.477984, 0],
[10.446252, 45.788744, 0],
[6.777075, 45.827119, 0],
],
],
],
},
bbox: [
6.75599105586694, 45.7887442565203, 10.5418236945627,
47.5175655551557,
],
description: 'AK',
},
])
})
})
describe('three spatial extents, first with description, second with bbox, third with geometry', () => {
it('returns an array of partial spatial extents with geometries, bbox and description', () => {
expect(readSpatialExtents(recordRootEl)).toEqual([
{
description: 'AK',
},
{
bbox: [
6.75599105586694, 45.7887442565203, 10.5418236945627,
47.5175655551557,
],
},
{
geometry: {
type: 'MultiPolygon',
coordinates: [
[
[
[6.777075, 45.827119, 0],
[6.755991, 47.517566, 0],
[10.541824, 47.477984, 0],
[10.446252, 45.788744, 0],
[6.777075, 45.827119, 0],
],
],
],
},
},
])
})
})
})
})

describe('service record', () => {
Expand Down
Loading
Loading