Skip to content

Commit

Permalink
#181 M5 complete GCO namespace with support of ISOPeriodDuration, ISO…
Browse files Browse the repository at this point in the history
…UomIdentifier
  • Loading branch information
eblondel committed Oct 2, 2024
1 parent 3747c02 commit da871b5
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export(ISOOrganisation)
export(ISOOtherAggregate)
export(ISOParameter)
export(ISOParameterDirection)
export(ISOPeriodDuration)
export(ISOPixelOrientation)
export(ISOPlatform)
export(ISOPortrayalCatalogueReference)
Expand Down Expand Up @@ -329,6 +330,7 @@ export(ISOTopologyLevel)
export(ISOTypeName)
export(ISOURL)
export(ISOUnlimitedInteger)
export(ISOUomIdentifier)
export(ISOUsage)
export(ISOVectorSpatialRepresentation)
export(ISOVerticalExtent)
Expand Down
129 changes: 129 additions & 0 deletions R/ISOPeriodDuration.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#' ISOPeriodDuration
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO period duration
#' @return Object of \code{\link{R6Class}} for modelling an ISO PeriodDuration
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' - ISO 19115-3 \url{https://schemas.isotc211.org/19115/-3/gco/1.0/gco/#element_TM_PeriodDuration}
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOPeriodDuration <- R6Class("ISOPeriodDuration",
inherit = ISOAbstractObject,
private = list(
xmlElement = "TM_PeriodDuration",
xmlNamespacePrefix = list(
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
value = NA,

#'@description Initializes a period duration
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
#'@param years years
#'@param months months
#'@param days days
#'@param hours hours
#'@param mins mins
#'@param secs secs
#'@param start start position
#'@param end end position
initialize = function(xml = NULL, value = NULL,
years = 0, months = 0, days = 0,
hours = 0, mins = 0, secs = 0,
start = NULL, end = NULL){
super$initialize(xml = xml)
if(is.null(xml)){
if(!is.null(value)){
self$value = value
}else{
self$setDuration(years = years, months = months, days = days,
hours = hours, mins = mins, secs = secs,
start = start, end = end)
}
}
},

#'@description Computes period duration
#'@param years years
#'@param months months
#'@param days days
#'@param hours hours
#'@param mins mins
#'@param secs secs
#'@param start start position
#'@param end end position
setDuration = function(years = 0, months = 0, days = 0,
hours = 0, mins = 0, secs = 0,
start = NULL, end = NULL){

if(!is.null(start) & !is.null(end)){
if(is(start,"numeric")) start <- as(start, "character")
if(!(is(start, "character") & nchar(start) %in% c(4,7))){
if(!all(class(start)==c("POSIXct","POSIXt")) | is(start, "Date")){
stop("For a date, the value should be of class ('POSIXct','POSIXt') or 'Date'")
}
}
if(is(end,"numeric")) end <- as(end, "character")
if(!(is(end, "character") & nchar(end) %in% c(4,7))){
if(!all(class(end)==c("POSIXct","POSIXt")) | is(end, "Date")){
stop("For a date, the value should be of class ('POSIXct','POSIXt') or 'Date'")
}
}
if(nchar(start)==4 && nchar(end)==4){
years <- length(as.numeric(start):as.numeric(end))
months <- 0; days <- 0; hours <- 0; mins <- 0; secs <- 0;
}else if(nchar(start)==7 && nchar(end)==7){
isLeapYear = function(year){ return(((year %% 4 == 0) & (year %% 100 != 0)) | (year %% 400 == 0)) }
startYear <- as.numeric(substr(start, 1, 4))
startMonth <- as.numeric(substr(start,6,7))
startDate <- as.Date(paste(start,"01",sep="-"))
endYear <- as.numeric(substr(end, 1, 4))
endMonth <- as.numeric(substr(end,6,7))
endDate <- as.Date(paste(end,ifelse(isLeapYear(endYear)&&endMonth==2,"29","28"),sep="-"))
years.seq <- seq(startDate, endDate, by = "years")
years <- length(years.seq)-1
months.start <- years.seq[length(years.seq)]
months.seq <- seq(months.start, endDate, by = "months")
months <- length(months.seq)-1
days <- 0; hours <- 0; mins <- 0; secs <- 0;
}else{
years.seq <- seq(start, end, by = "years")
years <- length(years.seq)-1
months.start <- years.seq[length(years.seq)]
months.seq <- seq(months.start, end, by = "months")
months <- length(months.seq)-1
days.start <- months.seq[length(months.seq)]
days.seq <- seq(days.start, end, by = "DSTdays")
days <- length(days.seq)-1
hours.start <- days.seq[length(days.seq)]
hours.seq <- seq(hours.start, end, by = "hours")
hours <- length(hours.seq)-1
mins.start <- hours.seq[length(hours.seq)]
mins.seq <- seq(mins.start, end, by = "mins")
mins <- length(mins.seq)-1
secs.start <- mins.seq[length(mins.seq)]
secs.seq <- seq(secs.start, end, by = "secs")
secs <- length(secs.seq)-1
}
}

duration <- "P"
if(years>0) duration <- paste0(duration, years, "Y")
if(months>0) duration <- paste0(duration, months, "M")
if(days>0) duration <- paste0(duration, days, "D")
if(hours>0 | hours>0 | mins>0) duration <- paste0(duration, "T")
if(hours>0) duration <- paste0(duration, hours, "H")
if(mins>0) duration <- paste0(duration, mins, "M")
if(secs>0) duration <- paste0(duration, secs, "S")
self$value <- duration
}
)
)
37 changes: 37 additions & 0 deletions R/ISOUomIdentifier.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#' ISOUomIdentifier
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO uom identifier
#' @return Object of \code{\link{R6Class}} for modelling an ISO Uom Identifier
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' - ISO 19115-3 \url{https://schemas.isotc211.org/19115/-3/gco/1.0/gco/#element_UomIdentifier}
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOUomIdentifier <- R6Class("ISOUomIdentifier",
inherit = ISOAbstractObject,
private = list(
xmlElement = "UomIdentifier",
xmlNamespacePrefix = list(
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
value = NA,

#'@description Initializes a Uom identifier
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
initialize = function(xml = NULL, value){
super$initialize(xml = xml)
if(is.null(xml)){
self$value = value
}
}
)
)
4 changes: 2 additions & 2 deletions inst/extdata/coverage/geometa_coverage_inventory.csv
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","RecordType","ISORecordType",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","Scale","ISOScale",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","ScopedName","ISOScopedName",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","TM_PeriodDuration","<missing>",FALSE,FALSE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","TM_PeriodDuration","ISOPeriodDuration",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","TypeName","ISOTypeName",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","UnlimitedInteger","ISOUnlimitedInteger",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","UomIdentifier","<missing>",FALSE,FALSE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO","UomIdentifier","ISOUomIdentifier",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial Common eXtension (GCX) Version: 1.0","GCX","Anchor","ISOAnchor",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCX"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial Common eXtension (GCX) Version: 1.0","GCX","FileName","ISOFileName",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCX"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial Common eXtension (GCX) Version: 1.0","GCX","MimeFileType","ISOMimeFileType",TRUE,TRUE,"ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCX"
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_summary.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Specification","Schema","Title","Namespace","Supported","Missing","Refactored","Torefactor","Coverage"
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Citation and responsible party information (CIT) Version: 2.0","CIT",16,0,16,0,100
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO",22,2,22,2,91.67
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial COmmon Objects (GCO) Version: 1.0","GCO",24,0,24,0,100
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial Common eXtension (GCX) Version: 1.0","GCX",3,0,3,0,100
"ISO/TS 19115-3:2023","ISO 19115-1:2014","Geospatial EXtent (GEX) Version: 1.0","GEX",8,0,8,0,100
"ISO/TS 19115-3:2023","ISO 19115-1:2014","metadata for LANguage and localization (LAN) Version: 1.0","LAN",7,0,7,0,100
Expand Down
10 changes: 5 additions & 5 deletions inst/extdata/coverage/geometa_coverage_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@
<td align="left">ISO 19115-1:2014</td>
<td align="left">Geospatial COmmon Objects (GCO) Version: 1.0</td>
<td align="left">GCO</td>
<td align="left"><a href="https://github.com/eblondel/geometa"><img src="data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzUiIGhlaWdodD0iMjAiIHJvbGU9ImltZyIgYXJpYS1sYWJlbD0iOTIlIj48dGl0bGU+OTIlPC90aXRsZT48bGluZWFyR3JhZGllbnQgaWQ9InMiIHgyPSIwIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjYmJiIiBzdG9wLW9wYWNpdHk9Ii4xIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLW9wYWNpdHk9Ii4xIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9InIiPjxyZWN0IHdpZHRoPSIzNSIgaGVpZ2h0PSIyMCIgcng9IjMiIGZpbGw9IiNmZmYiLz48L2NsaXBQYXRoPjxnIGNsaXAtcGF0aD0idXJsKCNyKSI+PHJlY3Qgd2lkdGg9IjAiIGhlaWdodD0iMjAiIGZpbGw9IiMzM2NjN2EiLz48cmVjdCB4PSIwIiB3aWR0aD0iMzUiIGhlaWdodD0iMjAiIGZpbGw9IiMzM2NjN2EiLz48cmVjdCB3aWR0aD0iMzUiIGhlaWdodD0iMjAiIGZpbGw9InVybCgjcykiLz48L2c+PGcgZmlsbD0iI2ZmZiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1mYW1pbHk9IlZlcmRhbmEsR2VuZXZhLERlamFWdSBTYW5zLHNhbnMtc2VyaWYiIHRleHQtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iIGZvbnQtc2l6ZT0iMTEwIj48dGV4dCBhcmlhLWhpZGRlbj0idHJ1ZSIgeD0iMTc1IiB5PSIxNTAiIGZpbGw9IiMwMTAxMDEiIGZpbGwtb3BhY2l0eT0iLjMiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiB0ZXh0TGVuZ3RoPSIyNTAiPjkyJTwvdGV4dD48dGV4dCB4PSIxNzUiIHk9IjE0MCIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIGZpbGw9IiNmZmYiIHRleHRMZW5ndGg9IjI1MCI+OTIlPC90ZXh0PjwvZz48L3N2Zz4=" alt="ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO" /></a></td>
<td align="right">22</td>
<td align="right">2</td>
<td align="right">22</td>
<td align="right">2</td>
<td align="left"><a href="https://github.com/eblondel/geometa"><img src="data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNDMiIGhlaWdodD0iMjAiIHJvbGU9ImltZyIgYXJpYS1sYWJlbD0iMTAwJSI+PHRpdGxlPjEwMCU8L3RpdGxlPjxsaW5lYXJHcmFkaWVudCBpZD0icyIgeDI9IjAiIHkyPSIxMDAlIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNiYmIiIHN0b3Atb3BhY2l0eT0iLjEiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3Atb3BhY2l0eT0iLjEiLz48L2xpbmVhckdyYWRpZW50PjxjbGlwUGF0aCBpZD0iciI+PHJlY3Qgd2lkdGg9IjQzIiBoZWlnaHQ9IjIwIiByeD0iMyIgZmlsbD0iI2ZmZiIvPjwvY2xpcFBhdGg+PGcgY2xpcC1wYXRoPSJ1cmwoI3IpIj48cmVjdCB3aWR0aD0iMCIgaGVpZ2h0PSIyMCIgZmlsbD0iIzRhNGVhOCIvPjxyZWN0IHg9IjAiIHdpZHRoPSI0MyIgaGVpZ2h0PSIyMCIgZmlsbD0iIzRhNGVhOCIvPjxyZWN0IHdpZHRoPSI0MyIgaGVpZ2h0PSIyMCIgZmlsbD0idXJsKCNzKSIvPjwvZz48ZyBmaWxsPSIjZmZmIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LWZhbWlseT0iVmVyZGFuYSxHZW5ldmEsRGVqYVZ1IFNhbnMsc2Fucy1zZXJpZiIgdGV4dC1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiIgZm9udC1zaXplPSIxMTAiPjx0ZXh0IGFyaWEtaGlkZGVuPSJ0cnVlIiB4PSIyMTUiIHk9IjE1MCIgZmlsbD0iIzAxMDEwMSIgZmlsbC1vcGFjaXR5PSIuMyIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIHRleHRMZW5ndGg9IjMzMCI+MTAwJTwvdGV4dD48dGV4dCB4PSIyMTUiIHk9IjE0MCIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIGZpbGw9IiNmZmYiIHRleHRMZW5ndGg9IjMzMCI+MTAwJTwvdGV4dD48L2c+PC9zdmc+" alt="ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO" /></a></td>
<td align="right">24</td>
<td align="right">0</td>
<td align="right">24</td>
<td align="right">0</td>
</tr>
<tr class="odd">
<td align="left">ISO/TS 19115-3:2023</td>
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_summary.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
|Specification |Schema |Title |Namespace |Coverage | Supported| Missing| Refactored| Torefactor|
|:------------------------------------|:------------------------------------|:-----------------------------------------------------------------------------------|:---------|:----------------------------------------------------------------------------------------------------------------------------------|---------:|-------:|----------:|----------:|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |Citation and responsible party information (CIT) Version: 2.0 |CIT |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - CIT](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa)| 16| 0| 16| 0|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |Geospatial COmmon Objects (GCO) Version: 1.0 |GCO |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO](https://img.shields.io/badge/-92%25-33cc7a.svg)](https://github.com/eblondel/geometa)| 22| 2| 22| 2|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |Geospatial COmmon Objects (GCO) Version: 1.0 |GCO |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCO](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa)| 24| 0| 24| 0|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |Geospatial Common eXtension (GCX) Version: 1.0 |GCX |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GCX](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa)| 3| 0| 3| 0|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |Geospatial EXtent (GEX) Version: 1.0 |GEX |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - GEX](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa)| 8| 0| 8| 0|
|ISO/TS 19115-3:2023 |ISO 19115-1:2014 |metadata for LANguage and localization (LAN) Version: 1.0 |LAN |[![ISO/TS 19115-3:2023 - ISO 19115-1:2014 - LAN](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa)| 7| 0| 7| 0|
Expand Down
Loading

0 comments on commit da871b5

Please sign in to comment.