diff --git a/libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts b/libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts index b03c8b89a..5cb02ae3a 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts @@ -635,6 +635,27 @@ describe('read parts', () => { ]) }) }) + describe('one empty spatial extent', () => { + beforeEach(() => { + const spatialExtent = getRootElement( + parseXmlString(` + + + + +`) + ) + pipe( + findIdentification(), + findNestedElement('gmd:extent', 'gmd:EX_Extent'), + removeChildrenByName('gmd:geographicElement'), + appendChildren(() => spatialExtent) + )(recordRootEl) + }) + it('returns an empty array', () => { + expect(readSpatialExtents(recordRootEl)).toEqual([]) + }) + }) }) }) diff --git a/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts b/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts index 6785e9a29..8581fcf33 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts @@ -1042,7 +1042,7 @@ export function readSpatialExtents(rootEl: XmlElement) { return pipe( findChildElement('gmd:polygon', false), firstChildElement, - map((el) => readGeometry(el)) + map((el) => (el ? readGeometry(el) : null)) )(rootEl) } @@ -1087,6 +1087,9 @@ export function readSpatialExtents(rootEl: XmlElement) { ) ) ), + filterArray( + ([geometry, bbox, [description]]) => !!geometry || !!bbox || !!description + ), mapArray(([geometry, bbox, [description, translations]]) => { return { ...(geometry && { geometry }),