# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' FeatureCollection Class
#'
#' @field type
#' @field bbox
#' @field coordinates
#' @field features
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FeatureCollection <- R6::R6Class(
'FeatureCollection',
public = list(
`type` = NULL,
`bbox` = NULL,
`coordinates` = NULL,
`features` = NULL,
initialize = function(`type`, `bbox`, `coordinates`, `features`){
if (!missing(`type`)) {
stopifnot(is.character(`type`), length(`type`) == 1)
self$`type` <- `type`
}
if (!missing(`bbox`)) {
stopifnot(is.list(`bbox`), length(`bbox`) != 0)
lapply(`bbox`, function(x) stopifnot(is.character(x)))
self$`bbox` <- `bbox`
}
if (!missing(`coordinates`)) {
stopifnot(is.list(`coordinates`), length(`coordinates`) != 0)
lapply(`coordinates`, function(x) stopifnot(is.character(x)))
self$`coordinates` <- `coordinates`
}
if (!missing(`features`)) {
stopifnot(is.list(`features`), length(`features`) != 0)
lapply(`features`, function(x) stopifnot(R6::is.R6(x)))
self$`features` <- `features`
}
},
toJSON = function() {
FeatureCollectionObject <- list()
if (!is.null(self$`type`)) {
FeatureCollectionObject[['type']] <- self$`type`
}
if (!is.null(self$`bbox`)) {
FeatureCollectionObject[['bbox']] <- self$`bbox`
}
if (!is.null(self$`coordinates`)) {
FeatureCollectionObject[['coordinates']] <- self$`coordinates`
}
if (!is.null(self$`features`)) {
FeatureCollectionObject[['features']] <- lapply(self$`features`, function(x) x$toJSON())
}
FeatureCollectionObject
},
fromJSON = function(FeatureCollectionJson) {
FeatureCollectionObject <- jsonlite::fromJSON(FeatureCollectionJson)
if (!is.null(FeatureCollectionObject$`type`)) {
self$`type` <- FeatureCollectionObject$`type`
}
if (!is.null(FeatureCollectionObject$`bbox`)) {
self$`bbox` <- FeatureCollectionObject$`bbox`
}
if (!is.null(FeatureCollectionObject$`coordinates`)) {
self$`coordinates` <- FeatureCollectionObject$`coordinates`
}
if (!is.null(FeatureCollectionObject$`features`)) {
self$`features` <- lapply(FeatureCollectionObject$`features`, function(x) {
featuresObject <- Feature$new()
featuresObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
featuresObject
})
}
},
fromJSONObject = function(FeatureCollectionObject) {
if (!is.null(FeatureCollectionObject$`type`)) {
self$`type` <- FeatureCollectionObject$`type`
}
if (!is.null(FeatureCollectionObject$`bbox`)) {
self$`bbox` <- FeatureCollectionObject$`bbox`
}
if (!is.null(FeatureCollectionObject$`coordinates`)) {
self$`coordinates` <- FeatureCollectionObject$`coordinates`
}
if (!is.null(FeatureCollectionObject$`features`)) {
self$`features` <- lapply(FeatureCollectionObject$`features`, function(x) {
featuresObject <- Feature$new()
featuresObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
featuresObject
})
}
},
toJSONString = function() {
featuresList = paste(lapply(self$`features`, function(x) x$toJSONString()),collapse = ",")
sprintf(
'{
"type": %s,
"bbox": [%s],
"coordinates": [%s],
"features": [%s]
}',
ifelse(is.null(self$`type`), "null",jsonlite::toJSON(self$`type`,auto_unbox=TRUE, null = "null")),
ifelse(is.null(self$`bbox`) || length(self$`bbox`) == 0, "" ,lapply(self$`bbox`, function(x) paste(paste0('"', x, '"'), sep=","))),
ifelse(is.null(self$`coordinates`) || length(self$`coordinates`) == 0, "" ,lapply(self$`coordinates`, function(x) paste(paste0('"', x, '"'), sep=","))),
featuresList
)
},
fromJSONString = function(FeatureCollectionJson) {
FeatureCollectionObject <- jsonlite::fromJSON(FeatureCollectionJson)
self$`type` <- FeatureCollectionObject$`type`
self$`bbox` <- FeatureCollectionObject$`bbox`
self$`coordinates` <- FeatureCollectionObject$`coordinates`
self$`features` <- lapply(FeatureCollectionObject$`features`, function(x) Feature$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.