Skip to content

Bug: Cannot render both WKT point and bounding box in same metadata field (spatialMetadataFields)ย #4583

@PawelKra

Description

@PawelKra

๐Ÿšน Bug: Cannot render both WKT point and bounding box in same metadata field (spatialMetadataFields)

Summary

When using the geospatialMapViewer functionality (introduced in PR [#3540](#3540)) to render maps on item pages, it is not possible to include both a WKT POINT(...) and a bounding box {east=..., south=..., ...} in the same metadata field (e.g., dcterms.spatial), even though the documentation explicitly states this should work.

What happens

If an item has both entries in the same metadata field:

<dcvalue element="dcterms" qualifier="spatial">POINT(21.0122 52.2297)</dcvalue>
<dcvalue element="dcterms" qualifier="spatial">{east=45.0, south=34.5, north=72.0, west=-25.0, accuracyLevel=0}</dcvalue>

The Angular frontend throws the following error:

Could not parse point from WKT string: undefined, error: Unable to parse: Parse error on line 1:
{EAST=45.0, SOUTH=34
^
Expecting 'POINT', ...

As a result, the map fails to render the bounding box, and may break entirely.

Expected behavior

According to the documentation:
https://github.com/kshepherd/dspace-geospatial-maps-doc/blob/main/README.md

You may use the same field for point and bounding box data โ€“ only valid points will be shown as markers, and only valid shapes will be drawn as rectangles.

The frontend should:

  • Treat POINT(...) or lat,lon values as points
  • Treat {east=..., south=..., ...} values as bounding boxes
  • Gracefully skip bbox strings during WKT parsing (rather than throw an error)

Suggested fix

In geospatial.functions.ts, the parseGeoJsonFromMetadataValue() function should skip values that start with { to avoid passing them to the WKT parser:

if (value.startsWith('{')) {
  return null; // or throw new SkipThisValueError(), depending on existing structure
}

Alternatively, introduce separate configuration options in geospatialMapViewer for pointFields and bboxFields to prevent misinterpretation of mixed metadata.

Environment


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageNew issue needs triage and/or scheduling

    Type

    No type

    Projects

    Status

    ๐Ÿ†• Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions