# Netherlands Biodiversity API
#
# Access to the digitised Natural History collection at the Naturalis Biodiversity Center
#
# OpenAPI spec version: v2
# Contact: support@naturalis.nl
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#'
#' @docType class
#'
#' @format R6 class
#'
#' @usage
#' # GeoArea$new()
#'
#' @format
#' R6 class
#'
#' @title GeoArea Class
#'
#' @description
#' For more information on the NBA object model, please refer to the
#' official NBA documentation at
#' \href{https://docs.biodiversitydata.nl}{https://docs.biodiversitydata.nl} and
#' the NBA model and endpoints reference at
#' \href{https://docs.biodiversitydata.nl/endpoints-reference}{https://docs.biodiversitydata.nl/endpoints-reference}.
#'
#' @details Model class for GeoArea objects. Geographical mapping of species occurrences is essential in biogeographical analyses. More than 1.2 Million of our specimen records are geo-referenced, i.e. they have latitude and longitude coordinates reported for the sita at which they were collected. The data type geo stores geographical areas to which the geo-referenced species can be mapped. This enables querying for specimens found in a specific region, to e.g. retrieve all the primate species collected on Madagascar. The areas are represented as polygons of longitude/latitude pairs. All polygons are coded in the GeoJSON format.
#'
#'
#' @field sourceSystem SourceSystem
#'
#' @field sourceSystemId character
#'
#' @field recordURI character
#'
#' @field id character
#'
#' @field areaType character
#'
#' @field locality character
#'
#' @field shape list
#'
#' @field source character
#'
#' @field isoCode character
#'
#' @field countryNL character
#'
#'
#'
#' @section Methods:
#' \describe{
#'
#' \item{\code{$new()}}{
#'
#' Constructor GeoArea object.
#'
#' }
#' \item{\code{$fromList(GeoAreaList)}}{
#'
#' Create GeoArea object from list.
#'
#' }
#'
#' \item{\code{$toList()}}{
#'
#' Get list representation of GeoArea.
#'
#' }
#' \item{\code{fromJSONString(GeoAreaJson)}}{
#'
#' Create GeoArea object from JSON.
#'
#' }
#' \item{\code{toJSONString(pretty=TRUE)}}{
#'
#' Get JSON representation of GeoArea.
#'
#' }
#' }
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
GeoArea <- R6::R6Class(
"GeoArea",
public = list(
`sourceSystem` = NULL,
`sourceSystemId` = NULL,
`recordURI` = NULL,
`id` = NULL,
`areaType` = NULL,
`locality` = NULL,
`shape` = NULL,
`source` = NULL,
`isoCode` = NULL,
`countryNL` = NULL,
initialize = function(
`sourceSystem`,
`sourceSystemId`,
`recordURI`,
`id`,
`areaType`,
`locality`,
`shape`,
`source`,
`isoCode`,
`countryNL`) {
if (!missing(`sourceSystem`)) {
stopifnot(R6::is.R6(`sourceSystem`))
self[["sourceSystem"]] <- `sourceSystem`
}
if (!missing(`sourceSystemId`)) {
stopifnot(
is.character(`sourceSystemId`),
length(`sourceSystemId`) == 1
)
self[["sourceSystemId"]] <- `sourceSystemId`
}
if (!missing(`recordURI`)) {
stopifnot(
is.character(`recordURI`),
length(`recordURI`) == 1
)
self[["recordURI"]] <- `recordURI`
}
if (!missing(`id`)) {
stopifnot(
is.character(`id`),
length(`id`) == 1
)
self[["id"]] <- `id`
}
if (!missing(`areaType`)) {
stopifnot(
is.character(`areaType`),
length(`areaType`) == 1
)
self[["areaType"]] <- `areaType`
}
if (!missing(`locality`)) {
stopifnot(
is.character(`locality`),
length(`locality`) == 1
)
self[["locality"]] <- `locality`
}
if (!missing(`shape`)) {
self[["shape"]] <- `shape`
}
if (!missing(`source`)) {
stopifnot(
is.character(`source`),
length(`source`) == 1
)
self[["source"]] <- `source`
}
if (!missing(`isoCode`)) {
stopifnot(
is.character(`isoCode`),
length(`isoCode`) == 1
)
self[["isoCode"]] <- `isoCode`
}
if (!missing(`countryNL`)) {
stopifnot(
is.character(`countryNL`),
length(`countryNL`) == 1
)
self[["countryNL"]] <- `countryNL`
}
},
toList = function() {
GeoAreaList <- list()
if (!is.null(self[["sourceSystem"]])) {
GeoAreaList[["sourceSystem"]] <-
self[["sourceSystem"]]$toList()
}
if (!is.null(self[["sourceSystemId"]])) {
GeoAreaList[["sourceSystemId"]] <-
self[["sourceSystemId"]]
}
if (!is.null(self[["recordURI"]])) {
GeoAreaList[["recordURI"]] <-
self[["recordURI"]]
}
if (!is.null(self[["id"]])) {
GeoAreaList[["id"]] <-
self[["id"]]
}
if (!is.null(self[["areaType"]])) {
GeoAreaList[["areaType"]] <-
self[["areaType"]]
}
if (!is.null(self[["locality"]])) {
GeoAreaList[["locality"]] <-
self[["locality"]]
}
if (!is.null(self[["shape"]])) {
GeoAreaList[["shape"]] <-
self[["shape"]]
}
if (!is.null(self[["source"]])) {
GeoAreaList[["source"]] <-
self[["source"]]
}
if (!is.null(self[["isoCode"]])) {
GeoAreaList[["isoCode"]] <-
self[["isoCode"]]
}
if (!is.null(self[["countryNL"]])) {
GeoAreaList[["countryNL"]] <-
self[["countryNL"]]
}
## omit empty nested lists in returned list
GeoAreaList[vapply(
GeoAreaList,
length,
FUN.VALUE = integer(1)
) > 0]
},
fromList = function(GeoAreaList,
typeMapping = NULL) {
self[["sourceSystem"]] <- SourceSystem$new()$fromList(
GeoAreaList[["sourceSystem"]],
typeMapping = typeMapping
)
self[["sourceSystemId"]] <-
GeoAreaList[["sourceSystemId"]]
self[["recordURI"]] <-
GeoAreaList[["recordURI"]]
self[["id"]] <-
GeoAreaList[["id"]]
self[["areaType"]] <-
GeoAreaList[["areaType"]]
self[["locality"]] <-
GeoAreaList[["locality"]]
self[["shape"]] <-
GeoAreaList[["shape"]]
self[["source"]] <-
GeoAreaList[["source"]]
self[["isoCode"]] <-
GeoAreaList[["isoCode"]]
self[["countryNL"]] <-
GeoAreaList[["countryNL"]]
invisible(self)
},
toJSONString = function(pretty = TRUE) {
jsonlite::toJSON(
self$toList(),
simplifyVector = TRUE,
auto_unbox = TRUE,
pretty = pretty
)
},
fromJSONString = function(GeoAreaJson,
typeMapping = NULL) {
GeoAreaList <- jsonlite::fromJSON(
GeoAreaJson,
simplifyVector = FALSE
)
self <- self$fromList(GeoAreaList)
invisible(self)
},
print = function(...) {
## print class name
cat("<GeoArea>\n")
## print all members with values
cat("Fields:\n")
if (typeof(self$sourceSystem) == "environment") {
cat("\tsourceSystem:\tobject of class", paste0("<", class(self$sourceSystem)[1], ">"), "\n")
}
else if (typeof(self$sourceSystem) == "list") {
cat("\tsourceSystem:\tlist of length", length(self$sourceSystem), "\n")
}
else {
cat("\tsourceSystem:\t", self$sourceSystem, "\n")
}
if (typeof(self$sourceSystemId) == "environment") {
cat("\tsourceSystemId:\tobject of class", paste0("<", class(self$sourceSystemId)[1], ">"), "\n")
}
else if (typeof(self$sourceSystemId) == "list") {
cat("\tsourceSystemId:\tlist of length", length(self$sourceSystemId), "\n")
}
else {
cat("\tsourceSystemId:\t", self$sourceSystemId, "\n")
}
if (typeof(self$recordURI) == "environment") {
cat("\trecordURI:\tobject of class", paste0("<", class(self$recordURI)[1], ">"), "\n")
}
else if (typeof(self$recordURI) == "list") {
cat("\trecordURI:\tlist of length", length(self$recordURI), "\n")
}
else {
cat("\trecordURI:\t", self$recordURI, "\n")
}
if (typeof(self$id) == "environment") {
cat("\tid:\tobject of class", paste0("<", class(self$id)[1], ">"), "\n")
}
else if (typeof(self$id) == "list") {
cat("\tid:\tlist of length", length(self$id), "\n")
}
else {
cat("\tid:\t", self$id, "\n")
}
if (typeof(self$areaType) == "environment") {
cat("\tareaType:\tobject of class", paste0("<", class(self$areaType)[1], ">"), "\n")
}
else if (typeof(self$areaType) == "list") {
cat("\tareaType:\tlist of length", length(self$areaType), "\n")
}
else {
cat("\tareaType:\t", self$areaType, "\n")
}
if (typeof(self$locality) == "environment") {
cat("\tlocality:\tobject of class", paste0("<", class(self$locality)[1], ">"), "\n")
}
else if (typeof(self$locality) == "list") {
cat("\tlocality:\tlist of length", length(self$locality), "\n")
}
else {
cat("\tlocality:\t", self$locality, "\n")
}
if (typeof(self$shape) == "environment") {
cat("\tshape:\tobject of class", paste0("<", class(self$shape)[1], ">"), "\n")
}
else if (typeof(self$shape) == "list") {
cat("\tshape:\tlist of length", length(self$shape), "\n")
}
else {
cat("\tshape:\t", self$shape, "\n")
}
if (typeof(self$source) == "environment") {
cat("\tsource:\tobject of class", paste0("<", class(self$source)[1], ">"), "\n")
}
else if (typeof(self$source) == "list") {
cat("\tsource:\tlist of length", length(self$source), "\n")
}
else {
cat("\tsource:\t", self$source, "\n")
}
if (typeof(self$isoCode) == "environment") {
cat("\tisoCode:\tobject of class", paste0("<", class(self$isoCode)[1], ">"), "\n")
}
else if (typeof(self$isoCode) == "list") {
cat("\tisoCode:\tlist of length", length(self$isoCode), "\n")
}
else {
cat("\tisoCode:\t", self$isoCode, "\n")
}
if (typeof(self$countryNL) == "environment") {
cat("\tcountryNL:\tobject of class", paste0("<", class(self$countryNL)[1], ">"), "\n")
}
else if (typeof(self$countryNL) == "list") {
cat("\tcountryNL:\tlist of length", length(self$countryNL), "\n")
}
else {
cat("\tcountryNL:\t", self$countryNL, "\n")
}
## print all methods
cat("Methods:\n")
cat("\tfromJSONString\n")
cat("\ttoJSONString\n")
cat("\tfromList\n")
cat("\ttoList\n")
cat("\tprint\n")
invisible(self)
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.