Skip to content

Commit

Permalink
fix(converter): handle empty geometry extents in ISO
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Oct 4, 2024
1 parent 26f73d5 commit c03413e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions libs/api/metadata-converter/src/lib/iso19139/read-parts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,27 @@ describe('read parts', () => {
])
})
})
describe('one empty spatial extent', () => {
beforeEach(() => {
const spatialExtent = getRootElement(
parseXmlString(`
<gmd:geographicElement>
<gmd:EX_BoundingPolygon>
<gmd:polygon/>
</gmd:EX_BoundingPolygon>
</gmd:geographicElement>`)
)
pipe(
findIdentification(),
findNestedElement('gmd:extent', 'gmd:EX_Extent'),
removeChildrenByName('gmd:geographicElement'),
appendChildren(() => spatialExtent)
)(recordRootEl)
})
it('returns an empty array', () => {
expect(readSpatialExtents(recordRootEl)).toEqual([])
})
})
})
})

Expand Down
5 changes: 4 additions & 1 deletion libs/api/metadata-converter/src/lib/iso19139/read-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -1087,6 +1087,9 @@ export function readSpatialExtents(rootEl: XmlElement) {
)
)
),
filterArray(
([geometry, bbox, [description]]) => !!geometry || !!bbox || !!description
),
mapArray(([geometry, bbox, [description, translations]]) => {
return {
...(geometry && { geometry }),
Expand Down

0 comments on commit c03413e

Please sign in to comment.