From ceb68e657d91fab5f5588eed6da965a691ee12de Mon Sep 17 00:00:00 2001 From: eblondel Date: Mon, 21 Oct 2019 17:25:12 +0200 Subject: [PATCH] #28 manage topics (ISO 19139 topic categories) using entity subjects --- R/geoflow_action_geometa_create_iso_19115.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/R/geoflow_action_geometa_create_iso_19115.R b/R/geoflow_action_geometa_create_iso_19115.R index a31269dd..9a320c4a 100644 --- a/R/geoflow_action_geometa_create_iso_19115.R +++ b/R/geoflow_action_geometa_create_iso_19115.R @@ -114,7 +114,14 @@ geometa_create_iso_19115 <- function(entity, config, options){ #TODO status (N) ident$setLanguage(entity$language) ident$setCharacterSet("utf8") - #TODO TopicCategory (N) + #topic categories + topics <- list() + if(length(entity$subjects)>0) topics <- entity$subjects[sapply(entity$subjects, function(x){return(tolower(x$name) == "topic")})] + if(length(topics)>0){ + for(topic in topics){ + for(topicCategory in topic$keywords) ident$addTopicCategory(topicCategory$name) + } + } #adding contacts for(entity_contact in entity$contacts){ @@ -288,7 +295,9 @@ geometa_create_iso_19115 <- function(entity, config, options){ ident$setExtent(extent) #thesaurus/keywords - for(subject in entity$subjects){ + subjects <- entity$subjects + if(length(subjects)>0) subjects <- subjects[sapply(subjects, function(x){return(x$name != "topic")})] + if(length(subjects)>0) for(subject in subjects){ #add keywords kwds <- ISOKeywords$new() for(kwd in subject$keywords){