diff --git a/DESCRIPTION b/DESCRIPTION index 8b62b23..46f6f9a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -45,7 +45,7 @@ Imports: rstac, caret, randomForest, - sits + sits (>= 1.4.1) Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Collate: diff --git a/Dockerfile b/Dockerfile index 2be75b9..ac6f88e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,22 +12,18 @@ RUN R -e "install.packages('devtools')" # Install gdalcubes package RUN R -e "install.packages('gdalcubes')" -# Install sits package -RUN R -e "install.packages('sits')" - -# Install other necessary packages +# install other necessary packages RUN apt-get install -y libsodium-dev libudunits2-dev -RUN R -e "install.packages(c('plumber', 'useful', 'ids', 'R6', 'sf', 'stars','rstac','bfast', 'geojsonsf', 'torch'))" +RUN Rscript -e "install.packages(c('plumber', 'useful', 'ids', 'R6', 'sf', 'rstac','bfast'))" -# Create directories +# create directories RUN mkdir -p /opt/dockerfiles/ && mkdir -p /var/openeo/workspace/ && mkdir -p /var/openeo/workspace/data/ -# Install packages from the local directory +# install packages from local directory COPY ./ /opt/dockerfiles/ -RUN R -e "remotes::install_local('/opt/dockerfiles', dependencies = TRUE)" +RUN Rscript -e "remotes::install_local('/opt/dockerfiles',dependencies=TRUE)" -# CMD or entrypoint for startup -CMD ["R", "-q", "--no-save", "-f", "/opt/dockerfiles/Dockerfiles/start.R"] +# cmd or entrypoint for startup +CMD ["R", "-q", "--no-save", "-f /opt/dockerfiles/Dockerfiles/start.R"] -# Expose the port -EXPOSE 8000 +EXPOSE 8000 \ No newline at end of file diff --git a/Dockerfiles/start.R b/Dockerfiles/start.R index b72ed20..eadef27 100644 --- a/Dockerfiles/start.R +++ b/Dockerfiles/start.R @@ -6,8 +6,8 @@ aws.host <-Sys.getenv("AWSHOST") if (aws.host == ""){ aws.host = NULL }else{ - message("AWS host port id is:") - message(aws.host) + message("AWS host port id is:", aws.host) + } diff --git a/R/Collection-class.R b/R/Collection-class.R index 995396e..f6210d4 100644 --- a/R/Collection-class.R +++ b/R/Collection-class.R @@ -22,10 +22,9 @@ Collection <- R6Class( #' @param description Short description of the collection #' initialize = function(id = NA, title = NA, description = NA) { - - self$id = id - self$title = title - self$description = description + self$id <- id + self$title <- title + self$description <- description }, #' @description Add image collection to the collection class object @@ -33,7 +32,11 @@ Collection <- R6Class( #' @param ImageCollection Collection of class 'image collection' #' setCollection = function(ImageCollection) { - private$imageCollection = ImageCollection + if (!gdalcubes:::is.image_collection(ImageCollection)) { + stop("Assigned data is not an image collection") + } + + private$imageCollection <- ImageCollection self$setMetadata() }, @@ -48,10 +51,9 @@ Collection <- R6Class( #' @description add extent and bands to the metadata of the collection object #' setMetadata = function() { - - private$metadata = list( + private$metadata <- list( extent = extent(private$imageCollection), - bands = NULL #gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name + bands = gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name ) }, @@ -68,12 +70,11 @@ Collection <- R6Class( #' @return converted bandlist #' getEoBands = function() { - - list = list() - bands = as.list(self$getMetadata()$bands) - list = lapply(bands, function(x) { - append(list, list(name = x)) - }) + list <- list() + bands <- as.list(self$getMetadata()$bands) + list <- lapply(bands, function(x) { + append(list, list(name = x)) + }) return(list) }, @@ -88,29 +89,31 @@ Collection <- R6Class( license = "proprietary", extent = list( spatial = list( - bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, - self$getMetadata()$extent$right, self$getMetadata()$extent$top)) + bbox = list(list( + self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, + self$getMetadata()$extent$right, self$getMetadata()$extent$top + )) ), temporal = list( interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1)) ) ), - links = list( - list( - rel = "self", - href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/") - ), - list( - rel = "parent", - href = paste(Session$getConfig()$base_url, "collections", sep = "/") - )) + links = list( + list( + rel = "self", + href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/") + ), + list( + rel = "parent", + href = paste(Session$getConfig()$base_url, "collections", sep = "/") + ) + ) ) }, #' @description List extended metadata for the collection handler #' collectionInfoExtended = function() { - list( stac_version = Session$getConfig()$stac_version, stac_extensions = list(Session$getConfig()$stac_extensions), @@ -120,8 +123,10 @@ Collection <- R6Class( license = "proprietary", extent = list( spatial = list( - bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, - self$getMetadata()$extent$right, self$getMetadata()$extent$top)) + bbox = list(list( + self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, + self$getMetadata()$extent$right, self$getMetadata()$extent$top + )) ), temporal = list( interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1)) @@ -129,20 +134,18 @@ Collection <- R6Class( ), links = list(list( rel = "root", - href = paste(Session$getConfig()$base_url, "collections", sep = "/")) - ), + href = paste(Session$getConfig()$base_url, "collections", sep = "/") + )), "cube:dimensions" = list( x = list( type = "spatial", axis = "x", - extent = list(self$getMetadata()$extent$left, self$getMetadata()$extent$right - ) + extent = list(self$getMetadata()$extent$left, self$getMetadata()$extent$right) ), y = list( type = "spatial", axis = "y", - extent = list(self$getMetadata()$extent$bottom, self$getMetadata()$extent$top - ) + extent = list(self$getMetadata()$extent$bottom, self$getMetadata()$extent$top) ), t = list( type = "temporal", @@ -153,7 +156,7 @@ Collection <- R6Class( values = list(self$getMetadata()$bands) ) ), - summaries = list(constellation = list(""), 'eo:bands' = self$getEoBands()) + summaries = list(constellation = list(""), "eo:bands" = self$getEoBands()) ) } ), @@ -164,12 +167,13 @@ Collection <- R6Class( ) #' @export -is.Collection = function(obj) { +is.Collection <- function(obj) { return("Collection" %in% class(obj)) } + #' collections: -#'sentinel-2-l2a +#' sentinel-2-l2a SENTINEL_2_L2A <- Collection$new( id = "SENTINEL-2-L2A", title = "Sentinel 2 L2A", diff --git a/man/SENTINEL_2_L2A.Rd b/man/SENTINEL_2_L2A.Rd index cb56b15..7c4a841 100644 --- a/man/SENTINEL_2_L2A.Rd +++ b/man/SENTINEL_2_L2A.Rd @@ -4,7 +4,7 @@ \name{SENTINEL_2_L2A} \alias{SENTINEL_2_L2A} \title{collections: -sentinel-s2-l2a} +sentinel-2-l2a} \format{ An object of class \code{Collection} (inherits from \code{R6}) of length 13. } @@ -13,6 +13,6 @@ SENTINEL_2_L2A } \description{ collections: -sentinel-s2-l2a +sentinel-2-l2a } \keyword{datasets} diff --git a/man/eo_ml_datacube.Rd b/man/eo_ml_datacube.Rd new file mode 100644 index 0000000..b25af0e --- /dev/null +++ b/man/eo_ml_datacube.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/processes.R +\docType{data} +\name{eo_ml_datacube} +\alias{eo_ml_datacube} +\title{return object from ml pedict process} +\format{ +An object of class \code{list} of length 2. +} +\usage{ +eo_ml_datacube +} +\description{ +return object from ml pedict process +} +\keyword{datasets} diff --git a/man/ml_datacube_schema.Rd b/man/ml_datacube_schema.Rd new file mode 100644 index 0000000..a226a88 --- /dev/null +++ b/man/ml_datacube_schema.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/processes.R +\name{ml_datacube_schema} +\alias{ml_datacube_schema} +\title{ml datacube_schema} +\usage{ +ml_datacube_schema() +} +\value{ +datacube list +} +\description{ +Return a list with ml data cube description and schema +}