Skip to content

Write one topic category per value from comma-separated strings - #1273

Open
epifanio wants to merge 1 commit into
geopython:masterfrom
epifanio:fix-topicategory-list
Open

epifanio wants to merge 1 commit into
geopython:masterfrom
epifanio:fix-topicategory-list

Conversation

@epifanio

Copy link
Copy Markdown
Contributor

Problem

Repositories store several ISO topic categories as one comma-separated string (topicategory is a Text column), and two places mishandle that:

  1. OGC API - Records / STAC (record2json): a list becomes one theme concept per entry, but a string becomes one concept holding the whole string:
    {"concepts": [{"id": "climatologyMeteorologyAtmosphere,environment"}], "scheme": "…#MD_TopicCategoryCode"}
    Other keyword themes on the same record get one concept per keyword.
  2. apiso / iso19115p3 profiles: the loop over val.split(',') writes val instead of v, so a record with two categories gets two gmd:topicCategory (or mri:topicCategory) elements, both containing a,b.

Change

  • record2json: split a string topicategory on commas into one concept per (stripped, non-empty) value. Lists are handled as before.
  • apiso / iso19115p3: write the current value v.strip() in each MD_TopicCategoryCode.

Tests

  • New tests/unittests/test_ogc_api_records.py: a single value, two comma-separated values, extra spaces and a trailing comma, and a list. The two comma-separated cases fail without this change.
  • Unit: 163 passed. Functional (not harvesting and not distributedsearch and not pubsub): 410 passed. No functional test record has several topic categories, so no expected output changes.
  • Seen in production on a record with climatologyMeteorologyAtmosphere and environment, whose Records API theme was the single concept climatologyMeteorologyAtmosphere,environment.

Repositories store several ISO topic categories as one comma-separated
string (topicategory is a Text column), but:

- OGC API - Records / STAC made that whole string a single theme
  concept, e.g. {'id': 'climatologyMeteorologyAtmosphere,environment'},
  instead of one concept per topic category as it does for lists.
- The apiso and iso19115p3 profiles looped over the split values but
  wrote the whole string in each MD_TopicCategoryCode, so a record with
  two categories got two elements both holding "a,b".

Split the string into one concept, and one MD_TopicCategoryCode, per
value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant