diff --git a/NAMESPACE b/NAMESPACE index e733b4b..2044fcd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(MNR.DB.Geometries) export(MNR.DB.Organisations) export(MNR.DB.Users) export(MNR.GeoPlot) +export(attachResourcePaths) export(resourcePrefix) export(use_mnr_ui) import(dplyr) diff --git a/R/db.R b/R/db.R index 4a22895..5e7e9df 100644 --- a/R/db.R +++ b/R/db.R @@ -1,8 +1,13 @@ +#' MNR database queries base class +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB <- R6::R6Class( "MNR.DB", public = list( + #' @description Initialises the instance with a database client + #' \link[AVSDevR.DBClient]{DBClient} + #' @param db_client <\link[AVSDevR.DBClient]{DBClient}> A DBClient instance initialize = function(db_client) { if (is.null(db_client) || !inherits(db_client, "DBClient")) { rlang::abort( @@ -11,6 +16,10 @@ MNR.DB <- R6::R6Class( } private$db_client <- db_client }, + + #' @description Returns the current DBClient instance in use + #' @returns <\link[AVSDevR.DBClient]{DBClient}> The DBClient instance used + #' by the class instance getDBClient = function() { private$db_client } diff --git a/R/db_actuals.R b/R/db_actuals.R index cf67ac7..d058f4c 100644 --- a/R/db_actuals.R +++ b/R/db_actuals.R @@ -1,9 +1,14 @@ +#' MNR database queries for Actuals +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB.Actuals <- R6::R6Class( "MNR.DB.Actuals", inherit = MNR.DB, public = list( + #' @description Select the actuals for `refs` + #' @param refs The MNR application noise source references + #' @returns A tibble of Actuals for `refs` selectActuals = function(refs) { cat("Actuals:\n") private$db_client$table("actual_activities") %>% @@ -25,6 +30,11 @@ MNR.DB.Actuals <- R6::R6Class( dplyr::collect() %>% dplyr::glimpse() }, + + #' @description Returns the current actuals for a application or builds a + #' default actuals list from the proposed locations if there are none + #' @param refs The MNR application noise source references + #' @returns A tibble of the proposed actuals selectProposedActuals = function(refs) { partA <- private$db_client$table("proposed_activities") %>% dplyr::filter(is.null(deleted_at), is.null(cancelled_at)) %>% @@ -91,9 +101,12 @@ MNR.DB.Actuals <- R6::R6Class( dplyr::bind_rows(partA, partB) %>% dplyr::glimpse() }, - upsertActuals = function(actuals.sf, geometries) { + + #' @description Upserts the actuals in the actuals.sf into the database + #' @param actuals.sf An sf table containing the new actuals + upsertActuals = function(actuals.sf) { if (length(actuals.sf) == 0 || (nrow(actuals.sf) == 0)) { - return(TRUE) + return(invisible(NULL)) } self$deleteActuals(unique(actuals.sf$ref)) @@ -115,7 +128,7 @@ MNR.DB.Actuals <- R6::R6Class( if (nrow(actuals) == 0) { cat("## No actuals to insert\n") - return(TRUE) + return(invisible(NULL)) } cat("## Inserting locations for actuals\n") @@ -171,8 +184,11 @@ MNR.DB.Actuals <- R6::R6Class( "location_conservation_area_distances", sac_distance_rows ) - TRUE + invisible(NULL) }, + + #' @description Deletes actuals for `refs` + #' @param refs The MNR application noise source references deleteActuals = function(refs) { cat("## Deleting old actuals for", paste(refs, collapse = ","), "\n") old_references <- private$db_client$table("actual_activities") %>% @@ -199,6 +215,8 @@ MNR.DB.Actuals <- R6::R6Class( "locations", old_locations %>% dplyr::rename(id = location_id) ) } + + invisible(NULL) } ) ) diff --git a/R/db_applications.R b/R/db_applications.R index b66f199..450a738 100644 --- a/R/db_applications.R +++ b/R/db_applications.R @@ -1,15 +1,26 @@ +#' MNR database queries for Applications +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB.Applications <- R6::R6Class( "MNR.DB.Applications", inherit = MNR.DB, public = list( + #' @description Initialises the instance with a database client from + #' \link[AVSDevR.DBClient]{DBClient} + #' @param db_client <\link[AVSDevR.DBClient]{DBClient}> A DBClient instance initialize = function(db_client) { super$initialize(db_client) private$db_users <- MNR.DB.Users$new(db_client) private$db_orgs <- MNR.DB.Organisations$new(db_client) }, + #' @description Fetch application details from a permissions query + #' @param perm_query A permissions_query object + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query details object (collect = FALSE) or a collected tibble + #' of application details collectFromPermissions = function(perm_query, collect = TRUE) { # nolint end if (getOption("debug", FALSE)) { @@ -22,6 +33,15 @@ MNR.DB.Applications <- R6::R6Class( private$db_client$collectOrReturn() }, + #' @description Fetch applications details from the database without any + #' filtering applied + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details getUnfilteredApplications = function( as_permissions = FALSE, collect = TRUE ) { @@ -42,6 +62,16 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetch application details from the database with filtering + #' for administration rights applied (assuming the user has the role) + #' @param user_id The user to check + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details getAdminApplications = function( user_id = -1, as_permissions = FALSE, collect = TRUE ) { @@ -61,6 +91,16 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetch application details from the database filtered to + #' those that are publicly available (ie. not draft or what-if) + #' @param user_id The user to check + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details getPublicOnlyApplications = function( user_id = -1, as_permissions = FALSE, collect = TRUE ) { @@ -80,6 +120,17 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetch application details from the database filtered to + #' those that are related to a user (via submitter, organisation or + #' agent/recipient) + #' @param user_id The user to check + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details getRelatedApplications = function( user_id, as_permissions = FALSE, collect = TRUE ) { @@ -102,6 +153,16 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetch application details from the database filtered to + #' those that are related to a user's organisation + #' @param user_id The user to check + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details # nolint next: object_length_linter. Descriptive function name getUserOrganisationApplications = function( user_id, as_permissions = FALSE, collect = TRUE @@ -123,6 +184,15 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetch a list of applications belonging to a user + #' @param user_id The user to check + #' @param as_permissions Returns a permissions_query if TRUE else + #' the applications if FALSE + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A permissions_query object (as_permissions = TRUE, + #' collect = FALSE) or query details object (as_permissions = FALSE, + #' collect = FALSE) or a collected tibble of application details getUserApplications = function( user_id, as_permissions = FALSE, collect = TRUE ) { @@ -145,6 +215,11 @@ MNR.DB.Applications <- R6::R6Class( self$collectFromPermissions(perm_qry, collect) }, + #' @description Fetches the state of an application from the database + #' @param application_id The id of the application to check + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A list containing the state flags of an application getApplicationState = function(application_id, collect = TRUE) { if (length(application_id) == 0) { application_id <- -1 diff --git a/R/db_geometries.R b/R/db_geometries.R index 6607ebc..a0b2595 100644 --- a/R/db_geometries.R +++ b/R/db_geometries.R @@ -1,9 +1,17 @@ +#' MNR database queries for Gemoetries +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB.Geometries <- R6::R6Class( "MNR.DB.Geometries", inherit = MNR.DB, public = list( + #' @description Fetches the Oil & Gas block information from the database + #' @param with_geometries Also fetch the block geometries + #' @param ordered Sort the blocks (has an overhead) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object or a collected sf of the blocks getBlocks = function( with_geometries = TRUE, ordered = FALSE, collect = TRUE ) { @@ -45,6 +53,11 @@ MNR.DB.Geometries <- R6::R6Class( qry }, + #' @description Retrieves the Conservation Areas from the database + #' @param with_geometries Also fetch the geometries + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object or a collected sf of the conservation areas getConservationAreas = function(with_geometries = TRUE, collect = TRUE) { qry <- private$db_client$table("conservation_areas") @@ -60,6 +73,11 @@ MNR.DB.Geometries <- R6::R6Class( qry }, + #' @description Retrieves the Marine Regions from the database + #' @param with_geometries Also fetch the geometries + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object or a collected sf of the marine regions getMarineRegions = function(with_geometries = TRUE, collect = TRUE) { qry <- private$db_client$table("marine_regions") @@ -75,11 +93,22 @@ MNR.DB.Geometries <- R6::R6Class( qry }, + #' @description Retrieves the block marine region map table from the + #' database + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object or collected query of the block marine regions getBlockMarineRegions = function(collect = TRUE) { qry <- private$db_client$table("block_marine_regions") private$db_client$collectOrReturn(qry) }, + #' @description Retrieves the block conservation areas map table from the + #' database + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object or collected query of the block conservation + #' areas # nolint next: object_length_linter. Descriptive function name required getBlockConservationAreaDistances = function(collect = TRUE) { qry <- private$db_client$table("block_conservation_area_distances") diff --git a/R/db_organisations.R b/R/db_organisations.R index 00b97cd..ce3624d 100644 --- a/R/db_organisations.R +++ b/R/db_organisations.R @@ -1,9 +1,17 @@ +#' MNR database queries for Organsiations +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB.Organisations <- R6::R6Class( "MNR.DB.Organisations", inherit = MNR.DB, public = list( + #' @description Fetch the details of an organisation from the database + #' @param org_id The id of the organisation to fetch + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A query object for an organsation (collect = FALSE) or a + #' tibble with the organisation details getOrganisation = function(org_id, collect = TRUE) { private$db_client$table("organisations") %>% dplyr::filter(flag_approved == TRUE) %>% @@ -11,6 +19,14 @@ MNR.DB.Organisations <- R6::R6Class( private$db_client$collectOrReturn() }, + #' @description Fetch the details of all organisations from the database + #' @param as_int Return only the ids (TRUE) + #' @param name_only Return only the name (TRUE) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns The organisation ids if as_int is TRUE, the organisation names + #' if as_int is FALSE and name_only is TRUE, else the organisations or an + #' uncollected query object getAllOrganisations = function( as_int = FALSE, name_only = TRUE, collect = TRUE ) { @@ -29,6 +45,9 @@ MNR.DB.Organisations <- R6::R6Class( } }, + #' @description Check if an organisation is a regulator + #' @param org_id The id of the organisation to check + #' @returns TRUE if the organisation is a regulator isRegulator = function(org_id) { private$db_client$table("organisations") %>% dplyr::filter(flag_approved == TRUE) %>% @@ -39,6 +58,14 @@ MNR.DB.Organisations <- R6::R6Class( magrittr::is_greater_than(0) }, + #' @description Fetch the details of all the regulators from the database + #' @param as_int Return only the ids (TRUE) + #' @param name_only Return only the name (TRUE) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns The regulator ids if as_int is TRUE, the regulator names if + #' as_int is FALSE and name_only is TRUE, else the regulator or an + #' uncollected query object getRegulators = function(as_int = FALSE, name_only = TRUE, collect = TRUE) { qry <- private$db_client$table("organisations") %>% dplyr::filter(flag_approved == TRUE) %>% @@ -56,6 +83,12 @@ MNR.DB.Organisations <- R6::R6Class( } }, + #' @description Fetch the members of an organisation + #' @param org_name The name of the organisation to check + #' @param org_id The id of the organisation to check + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A tibble of the organisation members or an uncollected query getOrganisationMembers = function( org_name = "", org_id = -1, collect = TRUE ) { @@ -80,45 +113,25 @@ MNR.DB.Organisations <- R6::R6Class( private$db_client$collectOrReturn() }, - #' @depricated - getUsersFromOrg = function(org_name = "", org_id = -1, collect = TRUE) { - .Deprecated(new = "getOrganisationMembers") - - private$db_client$table("users") %>% - dplyr::filter(flag_enabled == TRUE) %>% - dplyr::filter(flag_verified == TRUE) %>% - dplyr::mutate(known_as = paste(first_name, last_name)) %>% - dplyr::left_join( - private$db_client$table("organisation_members") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::select(user_id, organisation_id), - by = c(id = "user_id") - ) %>% - dplyr::inner_join( - private$db_client$table("organisations") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::filter((id == !!org_id) | (name == !!org_name)) %>% - dplyr::select(id), - by = c(organisation_id = "id") - ) %>% - dplyr::select(-organisation_id) %>% - private$db_client$collectOrReturn() - }, - - isAgent = function(user_id) { - private$db_client$table("organisation_members") %>% + #' @description Check if user's organisation is an agent for another + #' organisation + #' @param org_id The id of the organisation to check + #' @returns TRUE if the user's organisation is an agent + isAgent = function(org_id) { + private$db_client$table("organisation_agents") %>% dplyr::filter(flag_approved == TRUE) %>% - dplyr::filter(user_id == !!user_id) %>% - dplyr::inner_join( - private$db_client$table("organisation_agents") %>% - dplyr::filter(flag_approved == TRUE), - by = c(organisation_id = "agent_id") - ) %>% + dplyr::filter(agent_id == !!org_id) %>% dplyr::count() %>% dplyr::pull() %>% magrittr::is_greater_than(0) }, + #' @description Fetch the agents of an organisation + #' @param org_id The id of the organisation to check + #' @param as_int Return only the id (TRUE) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns An uncollected query object or a tibble of agents getOrganisationAgents = function(org_id, as_int = FALSE, collect = TRUE) { qry <- private$db_client$table("organisation_agents") %>% dplyr::filter(flag_approved == TRUE) %>% @@ -140,6 +153,12 @@ MNR.DB.Organisations <- R6::R6Class( } }, + #' @description Fetch the recipients of an organisation + #' @param agent_id The id of the organisation (agent) to check + #' @param as_int Return only the id (TRUE) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns An uncollected query object or a tibble of recipients getAgentRecipients = function(agent_id, as_int = FALSE, collect = TRUE) { qry <- private$db_client$table("organisation_agents") %>% dplyr::filter(flag_approved == TRUE) %>% @@ -161,94 +180,15 @@ MNR.DB.Organisations <- R6::R6Class( } }, - #' @depricated - getAgentForOrganisations = function( - org_ids, as_int = FALSE, name_only = TRUE, collect = TRUE - ) { - .Deprecated(new = "getOrganisationAgents") - - qry <- private$db_client$table("organisations") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::inner_join( - private$db_client$table("organisation_agents") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::filter(organisation_id %in% !!org_ids) %>% - dplyr::select(agent_id) %>% - dplyr::collapse(), - by = c(id = "agent_id") - ) %>% - dplyr::distinct() - - if (as_int) { - qry %>% - dplyr::pull(id) - } else if (name_only) { - qry %>% - dplyr::pull(name) - } else { - qry %>% - private$db_client$collectOrReturn() - } - }, - - #' @depricated - getRecipientOrganisations = function( - org_id, as_int = FALSE, name_only = TRUE, collect = TRUE - ) { - .Deprecated(new = "getAgentRecipients") - - qry <- private$db_client$table("organisations") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::inner_join( - private$db_client$table("organisation_agents") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::filter(agent_id %in% !!org_id) %>% - dplyr::select(organisation_id) %>% - dplyr::collapse(), - by = c(id = "organisation_id") - ) %>% - dplyr::distinct() - - if (as_int) { - qry %>% - dplyr::pull(id) - } else if (name_only) { - qry %>% - dplyr::pull(name) - } else { - qry %>% - private$db_client$collectOrReturn() - } - }, - - #' @depricated - getUserOrgs = function( - user_id, as_int = TRUE, name_only = TRUE, collect = TRUE - ) { - .Deprecated(new = "getUserOrganisation") - - qry <- private$db_client$table("organisations") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::left_join( - private$db_client$table("organisation_members") %>% - dplyr::filter(flag_approved == TRUE) %>% - dplyr::select(user_id, organisation_id), - by = c(id = "organisation_id") - ) %>% - dplyr::filter(user_id == !!user_id) - - if (as_int) { - qry %>% - dplyr::pull(id) - } else if (name_only) { - qry %>% - dplyr::pull(name) - } else { - qry %>% - private$db_client$collectOrReturn() - } - }, - + #' @description Fetch the organisation of a user + #' @param user_id The id of the user to fetch the organisation of + #' @param as_int Return only the id (TRUE) + #' @param name_only Return only the name (TRUE) + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns The organisation id if as_int is TRUE, the organisation name if + #' as_int is FALSE and name_only is TRUE, else the organisation or an + #' uncollected query object getUserOrganisation = function( user_id, as_int = TRUE, name_only = TRUE, collect = TRUE ) { diff --git a/R/db_users.R b/R/db_users.R index c2581f1..fe6edb2 100644 --- a/R/db_users.R +++ b/R/db_users.R @@ -1,9 +1,17 @@ +#' MNR database queries for Users +#' #' @export # nolint next: object_name_linter. R6Class MNR.DB.Users <- R6::R6Class( "MNR.DB.Users", inherit = MNR.DB, public = list( + #' @description Initialises the instance with a database client from + #' \link[AVSDevR.DBClient]{DBClient} + #' @param db_client <\link[AVSDevR.DBClient]{DBClient}> A DBClient instance + #' @param admin_role_slug The slug of the application + #' administrator role within UserFrosting + #' (Defaults to: "application-admin") initialize = function(db_client, admin_role_slug = NULL) { super$initialize(db_client) private$db_uf <- AVSDevR.UserFrosting::UFDatabase$new(db_client) @@ -13,16 +21,34 @@ MNR.DB.Users <- R6::R6Class( } }, + #' @description Get user information from the database + #' @param user_id The user id to fetch + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns Details of the user denoted by user_id getUser = function(user_id, collect = TRUE) { private$db_uf$getUser(user_id, collect) }, + + #' @description Get user name from the database + #' @param user_id The user id to fetch + #' @returns The user's name getUserName = function(user_id) { private$db_uf$getUserName(user_id) }, + + #' @description Get user roles from the database + #' @param user_id The user id to fetch + #' @param collect Collect the query before returning (TRUE) or + #' return the built query object (FALSE) + #' @returns A list of user roles getUserRoles = function(user_id, collect = TRUE) { private$db_uf$getUserRoles(user_id, collect) }, + #' @description Check if a user is an application administrator + #' @param user_id The user id to fetch + #' @returns TRUE if the user is an administrator isApplicationsAdmin = function(user_id) { self$getUserRoles(user_id, collect = FALSE) %>% dplyr::filter(slug == !!private$admin_role_slug) %>% diff --git a/R/geoPlot.R b/R/geoPlot.R index a2d5d36..116b858 100644 --- a/R/geoPlot.R +++ b/R/geoPlot.R @@ -1,14 +1,32 @@ +mnr_geoplot_env <- new.env() + +#' MNR GIS plot base map generator +#' +#' Base layers are loaded and cached on first call to each of the boot methods. +#' #' @export # nolint next: object_name_linter. R6Class MNR.GeoPlot <- R6::R6Class( "MNR.GeoPlot", public = list( + #' @description Initialises the object by building the grid lines initialize = function() { private$bootGridLines() }, + #' @description Loads the JNCC layers required from file for the base map bootLayers = function() { - private$boundaryIoM <- sf::st_read( + if (exists("layers_loaded", envir = mnr_geoplot_env)) { + private$boundaryIoM <- get("boundaryIoM", envir = mnr_geoplot_env) + private$boundaryMSFD <- get("boundaryMSFD", envir = mnr_geoplot_env) + private$boundaryUKCS <- get("boundaryUKCS", envir = mnr_geoplot_env) + private$boundaryUKTerritorial <- get( + "boundaryUKTerritorial", envir = mnr_geoplot_env + ) + return(invisible(NULL)) + } + + boundaryIoM <- sf::st_read( file.path( system.file(package = "AVSDevR.MarineNoiseRegistry"), "layers", @@ -16,7 +34,7 @@ MNR.GeoPlot <- R6::R6Class( ), quiet = TRUE ) - private$boundaryMSFD <- sf::st_read( + boundaryMSFD <- sf::st_read( file.path( system.file(package = "AVSDevR.MarineNoiseRegistry"), "layers", @@ -24,7 +42,7 @@ MNR.GeoPlot <- R6::R6Class( ), quiet = TRUE ) - private$boundaryUKCS <- sf::st_read( + boundaryUKCS <- sf::st_read( file.path( system.file(package = "AVSDevR.MarineNoiseRegistry"), "layers", @@ -32,7 +50,7 @@ MNR.GeoPlot <- R6::R6Class( ), quiet = TRUE ) - private$boundaryUKTerritorial <- sf::st_read( + boundaryUKTerritorial <- sf::st_read( file.path( system.file(package = "AVSDevR.MarineNoiseRegistry"), "layers", @@ -40,15 +58,34 @@ MNR.GeoPlot <- R6::R6Class( ), quiet = TRUE ) + + assign("boundaryIoM", boundaryIoM, envir = mnr_geoplot_env) + assign("boundaryMSFD", boundaryMSFD, envir = mnr_geoplot_env) + assign("boundaryUKCS", boundaryUKCS, envir = mnr_geoplot_env) + assign( + "boundaryUKTerritorial", boundaryUKTerritorial, envir = mnr_geoplot_env + ) + assign("layers_loaded", TRUE, envir = mnr_geoplot_env) + + invisible(self$bootLayers()) }, + #' @description Loads the Oil & Gas quadrants from file for the base map bootQuadrants = function() { + if (exists("quadrants_loaded", envir = mnr_geoplot_env)) { + private$quadrants <- get("quadrants", envir = mnr_geoplot_env) + private$quadrant_annotations <- get( + "quadrant_annotations", envir = mnr_geoplot_env + ) + return(invisible(NULL)) + } + old_opts <- options(sf_use_s2 = FALSE) on.exit({ options(old_opts) }) - private$quadrants <- sf::st_read( + quadrants <- sf::st_read( file.path( system.file(package = "AVSDevR.MarineNoiseRegistry"), "layers", @@ -56,26 +93,47 @@ MNR.GeoPlot <- R6::R6Class( ), quiet = TRUE ) - private$quadrant_annotations <- suppressWarnings({ - private$quadrants %>% + quadrant_annotations <- suppressWarnings({ + quadrants %>% dplyr::select(quadrnt) %>% sf::st_centroid() }) + + assign("quadrants", quadrants, envir = mnr_geoplot_env) + assign( + "quadrant_annotations", quadrant_annotations, envir = mnr_geoplot_env + ) + assign("quadrants_loaded", TRUE, envir = mnr_geoplot_env) + + invisible(self$bootQuadrants()) }, + #' @description Loads the Conservation Areas from the database for the base + #' map. + #' @param db_client <\link[AVSDevR.DBClient]{DBClient}> A DBClient instance bootConservationAreas = function(db_client) { + if (exists("conservation_areas_loaded", envir = mnr_geoplot_env)) { + private$conservation_areas <- get( + "conservation_areas", envir = mnr_geoplot_env + ) + private$conservation_area_colours <- get( + "conservation_area_colours", envir = mnr_geoplot_env + ) + return(invisible(NULL)) + } + old_opts <- options(sf_use_s2 = FALSE) on.exit({ options(old_opts) }) - private$conservation_areas <- db_client$table("conservation_areas") %>% + conservation_areas <- db_client$table("conservation_areas") %>% dplyr::select(name, season, geom) %>% db_client$collectGeometries() %>% sf::st_sf() %>% sf::st_cast("MULTIPOLYGON") - colour_palette <- private$conservation_areas %>% + colour_palette <- conservation_areas %>% dplyr::mutate( colour = sapply(season, function(s) { switch( @@ -88,13 +146,31 @@ MNR.GeoPlot <- R6::R6Class( ) %>% dplyr::pull(colour) - private$conservation_area_colours <- private$conservation_areas %>% + conservation_area_colours <- conservation_areas %>% sf::st_coordinates() %>% tibble::as_tibble() %>% dplyr::mutate(colour = colour_palette[L3]) %>% dplyr::pull(colour) + + assign("conservation_areas", conservation_areas, envir = mnr_geoplot_env) + assign( + "conservation_area_colours", conservation_area_colours, + envir = mnr_geoplot_env + ) + assign("conservation_areas", TRUE, envir = mnr_geoplot_env) + + invisible(self$bootConservationAreas()) }, + #' @description Generates a base plotly map with optional layers included + #' @param ... Options to call plotly::plot_ly with + #' @param with_jncc_layers Includes the JNCC base layers if TRUE + #' (call obj$bootLayers() first) + #' @param with_quadrants Includes the Oil & Gas Quadrants if TRUE + #' (call obj$bootQuadrants() first) + #' @param with_conservation_areas Includes the Conservation Areas + #' if TRUE (call obj$bootConservationAreas() first) + #' @returns A plolty object base map makeBasePlot = function( ..., with_jncc_layers = TRUE, with_quadrants = FALSE, with_conservation_areas = FALSE @@ -151,6 +227,16 @@ MNR.GeoPlot <- R6::R6Class( ) }, + #' @description Bounds a mapbox map to a specific area and zoom + #' @param p A plotly mapbox map object + #' @param c_lat Center latitude + #' @param c_lon Center longitude + #' @param zoom A mapbox zoom level + #' @param xmin Minimum longitude to bound with + #' @param ymin Minimum latitude to bound with + #' @param xmax Maximum longitude to bound with + #' @param ymax Maximum latitude to bound with + #' @returns The plotly object boundMap = function( p, c_lat = 56, c_lon = -5.5, zoom = 3.5, xmin = -25, ymin = 45, xmax = 5, ymax = 65 @@ -186,6 +272,13 @@ MNR.GeoPlot <- R6::R6Class( bootGridLines = function() { + if (exists("gridlines_loaded", envir = mnr_geoplot_env)) { + private$major_lines <- get("major_lines", envir = mnr_geoplot_env) + private$minor_lines <- get("minor_lines", envir = mnr_geoplot_env) + private$zero_lines <- get("zero_lines", envir = mnr_geoplot_env) + return(invisible(NULL)) + } + old_opts <- options(sf_use_s2 = FALSE) on.exit({ options(old_opts) @@ -215,25 +308,31 @@ MNR.GeoPlot <- R6::R6Class( ) } suppressMessages({ - private$major_lines <- points %>% - dplyr::filter(is_major) %>% - sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% - dplyr::group_by(grp) %>% - dplyr::summarise() %>% - sf::st_cast("LINESTRING") - private$minor_lines <- points %>% - dplyr::filter(!is_major) %>% - sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% - dplyr::group_by(grp) %>% - dplyr::summarise() %>% - sf::st_cast("LINESTRING") - private$zero_lines <- points %>% - dplyr::filter((lat == 0) | (lon == 0)) %>% - sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% - dplyr::group_by(grp) %>% - dplyr::summarise() %>% - sf::st_cast("LINESTRING") + major_lines <- points %>% + dplyr::filter(is_major) %>% + sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% + dplyr::group_by(grp) %>% + dplyr::summarise() %>% + sf::st_cast("LINESTRING") + minor_lines <- points %>% + dplyr::filter(!is_major) %>% + sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% + dplyr::group_by(grp) %>% + dplyr::summarise() %>% + sf::st_cast("LINESTRING") + zero_lines <- points %>% + dplyr::filter((lat == 0) | (lon == 0)) %>% + sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) %>% + dplyr::group_by(grp) %>% + dplyr::summarise() %>% + sf::st_cast("LINESTRING") + assign("major_lines", major_lines, envir = mnr_geoplot_env) + assign("minor_lines", minor_lines, envir = mnr_geoplot_env) + assign("zero_lines", zero_lines, envir = mnr_geoplot_env) }) + + assign("gridlines_loaded", TRUE, envir = mnr_geoplot_env) + private$bootGridLines() }, addGridLines = function(p) { diff --git a/R/use_mnr_ui.R b/R/use_mnr_ui.R index d7c0cd2..76e6376 100644 --- a/R/use_mnr_ui.R +++ b/R/use_mnr_ui.R @@ -1,3 +1,5 @@ +#' Attaches the MNR stylesheets and scripts to the UI +#' #' @export use_mnr_ui <- function() { attachResourcePaths() @@ -21,11 +23,16 @@ use_mnr_ui <- function() { ) } +#' Provides the resource path for MNR specific files +#' #' @export resourcePrefix <- function() { paste0("avsdev_mnr_", utils::packageVersion("AVSDevR.MarineNoiseRegistry")) } +#' Attaches the MNR resource path to Shiny if not already attached +#' +#' @export attachResourcePaths <- function() { if (!(resourcePrefix() %in% names(shiny::resourcePaths()))) { shiny::addResourcePath( @@ -33,4 +40,5 @@ attachResourcePaths <- function() { system.file("www", package = "AVSDevR.MarineNoiseRegistry") ) } + invisible(NULL) } diff --git a/man/MNR.DB.Actuals.Rd b/man/MNR.DB.Actuals.Rd new file mode 100644 index 0000000..60199a6 --- /dev/null +++ b/man/MNR.DB.Actuals.Rd @@ -0,0 +1,123 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db_actuals.R +\name{MNR.DB.Actuals} +\alias{MNR.DB.Actuals} +\title{MNR database queries for Actuals} +\value{ +A tibble of Actuals for \code{refs} + +A tibble of the proposed actuals +} +\description{ +MNR database queries for Actuals + +MNR database queries for Actuals +} +\section{Super class}{ +\code{\link[AVSDevR.MarineNoiseRegistry:MNR.DB]{AVSDevR.MarineNoiseRegistry::MNR.DB}} -> \code{MNR.DB.Actuals} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB.Actuals-selectActuals}{\code{MNR.DB.Actuals$selectActuals()}} +\item \href{#method-MNR.DB.Actuals-selectProposedActuals}{\code{MNR.DB.Actuals$selectProposedActuals()}} +\item \href{#method-MNR.DB.Actuals-upsertActuals}{\code{MNR.DB.Actuals$upsertActuals()}} +\item \href{#method-MNR.DB.Actuals-deleteActuals}{\code{MNR.DB.Actuals$deleteActuals()}} +\item \href{#method-MNR.DB.Actuals-clone}{\code{MNR.DB.Actuals$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Actuals-selectActuals}{}}} +\subsection{Method \code{selectActuals()}}{ +Select the actuals for \code{refs} +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Actuals$selectActuals(refs)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{refs}}{\if{html}{\out{}} The MNR application noise source references} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Actuals-selectProposedActuals}{}}} +\subsection{Method \code{selectProposedActuals()}}{ +Returns the current actuals for a application or builds a +default actuals list from the proposed locations if there are none +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Actuals$selectProposedActuals(refs)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{refs}}{\if{html}{\out{}} The MNR application noise source references} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Actuals-upsertActuals}{}}} +\subsection{Method \code{upsertActuals()}}{ +Upserts the actuals in the actuals.sf into the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Actuals$upsertActuals(actuals.sf)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{actuals.sf}}{\if{html}{\out{}} An sf table containing the new actuals} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Actuals-deleteActuals}{}}} +\subsection{Method \code{deleteActuals()}}{ +Deletes actuals for \code{refs} +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Actuals$deleteActuals(refs)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{refs}}{\if{html}{\out{}} The MNR application noise source references} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Actuals-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Actuals$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.DB.Applications.Rd b/man/MNR.DB.Applications.Rd new file mode 100644 index 0000000..332e151 --- /dev/null +++ b/man/MNR.DB.Applications.Rd @@ -0,0 +1,306 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db_applications.R +\name{MNR.DB.Applications} +\alias{MNR.DB.Applications} +\title{MNR database queries for Applications} +\value{ +A query details object (collect = FALSE) or a collected tibble +of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A permissions_query object (as_permissions = TRUE, +collect = FALSE) or query details object (as_permissions = FALSE, +collect = FALSE) or a collected tibble of application details + +A list containing the state flags of an application +} +\description{ +MNR database queries for Applications + +MNR database queries for Applications +} +\section{Super class}{ +\code{\link[AVSDevR.MarineNoiseRegistry:MNR.DB]{AVSDevR.MarineNoiseRegistry::MNR.DB}} -> \code{MNR.DB.Applications} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB.Applications-new}{\code{MNR.DB.Applications$new()}} +\item \href{#method-MNR.DB.Applications-collectFromPermissions}{\code{MNR.DB.Applications$collectFromPermissions()}} +\item \href{#method-MNR.DB.Applications-getUnfilteredApplications}{\code{MNR.DB.Applications$getUnfilteredApplications()}} +\item \href{#method-MNR.DB.Applications-getAdminApplications}{\code{MNR.DB.Applications$getAdminApplications()}} +\item \href{#method-MNR.DB.Applications-getPublicOnlyApplications}{\code{MNR.DB.Applications$getPublicOnlyApplications()}} +\item \href{#method-MNR.DB.Applications-getRelatedApplications}{\code{MNR.DB.Applications$getRelatedApplications()}} +\item \href{#method-MNR.DB.Applications-getUserOrganisationApplications}{\code{MNR.DB.Applications$getUserOrganisationApplications()}} +\item \href{#method-MNR.DB.Applications-getUserApplications}{\code{MNR.DB.Applications$getUserApplications()}} +\item \href{#method-MNR.DB.Applications-getApplicationState}{\code{MNR.DB.Applications$getApplicationState()}} +\item \href{#method-MNR.DB.Applications-clone}{\code{MNR.DB.Applications$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-new}{}}} +\subsection{Method \code{new()}}{ +Initialises the instance with a database client from +\link[AVSDevR.DBClient]{DBClient} +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$new(db_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{db_client}}{<\link[AVSDevR.DBClient]{DBClient}> A DBClient instance} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-collectFromPermissions}{}}} +\subsection{Method \code{collectFromPermissions()}}{ +Fetch application details from a permissions query +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$collectFromPermissions(perm_query, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{perm_query}}{A permissions_query object} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getUnfilteredApplications}{}}} +\subsection{Method \code{getUnfilteredApplications()}}{ +Fetch applications details from the database without any +filtering applied +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getUnfilteredApplications( + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getAdminApplications}{}}} +\subsection{Method \code{getAdminApplications()}}{ +Fetch application details from the database with filtering +for administration rights applied (assuming the user has the role) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getAdminApplications( + user_id = -1, + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user to check} + +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getPublicOnlyApplications}{}}} +\subsection{Method \code{getPublicOnlyApplications()}}{ +Fetch application details from the database filtered to +those that are publicly available (ie. not draft or what-if) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getPublicOnlyApplications( + user_id = -1, + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user to check} + +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getRelatedApplications}{}}} +\subsection{Method \code{getRelatedApplications()}}{ +Fetch application details from the database filtered to +those that are related to a user (via submitter, organisation or +agent/recipient) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getRelatedApplications( + user_id, + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user to check} + +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getUserOrganisationApplications}{}}} +\subsection{Method \code{getUserOrganisationApplications()}}{ +Fetch application details from the database filtered to +those that are related to a user's organisation +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getUserOrganisationApplications( + user_id, + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user to check} + +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getUserApplications}{}}} +\subsection{Method \code{getUserApplications()}}{ +Fetch a list of applications belonging to a user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getUserApplications( + user_id, + as_permissions = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user to check} + +\item{\code{as_permissions}}{\if{html}{\out{}} Returns a permissions_query if TRUE else +the applications if FALSE} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-getApplicationState}{}}} +\subsection{Method \code{getApplicationState()}}{ +Fetches the state of an application from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$getApplicationState(application_id, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{application_id}}{\if{html}{\out{}} The id of the application to check} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Applications-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Applications$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.DB.Geometries.Rd b/man/MNR.DB.Geometries.Rd new file mode 100644 index 0000000..7cd6210 --- /dev/null +++ b/man/MNR.DB.Geometries.Rd @@ -0,0 +1,166 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db_geometries.R +\name{MNR.DB.Geometries} +\alias{MNR.DB.Geometries} +\title{MNR database queries for Gemoetries} +\value{ +A query object or a collected sf of the blocks + +A query object or a collected sf of the conservation areas + +A query object or a collected sf of the marine regions + +A query object or collected query of the block marine regions + +A query object or collected query of the block conservation +areas +} +\description{ +MNR database queries for Gemoetries + +MNR database queries for Gemoetries +} +\section{Super class}{ +\code{\link[AVSDevR.MarineNoiseRegistry:MNR.DB]{AVSDevR.MarineNoiseRegistry::MNR.DB}} -> \code{MNR.DB.Geometries} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB.Geometries-getBlocks}{\code{MNR.DB.Geometries$getBlocks()}} +\item \href{#method-MNR.DB.Geometries-getConservationAreas}{\code{MNR.DB.Geometries$getConservationAreas()}} +\item \href{#method-MNR.DB.Geometries-getMarineRegions}{\code{MNR.DB.Geometries$getMarineRegions()}} +\item \href{#method-MNR.DB.Geometries-getBlockMarineRegions}{\code{MNR.DB.Geometries$getBlockMarineRegions()}} +\item \href{#method-MNR.DB.Geometries-getBlockConservationAreaDistances}{\code{MNR.DB.Geometries$getBlockConservationAreaDistances()}} +\item \href{#method-MNR.DB.Geometries-clone}{\code{MNR.DB.Geometries$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-getBlocks}{}}} +\subsection{Method \code{getBlocks()}}{ +Fetches the Oil & Gas block information from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$getBlocks( + with_geometries = TRUE, + ordered = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{with_geometries}}{\if{html}{\out{}} Also fetch the block geometries} + +\item{\code{ordered}}{\if{html}{\out{}} Sort the blocks (has an overhead)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-getConservationAreas}{}}} +\subsection{Method \code{getConservationAreas()}}{ +Retrieves the Conservation Areas from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$getConservationAreas(with_geometries = TRUE, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{with_geometries}}{\if{html}{\out{}} Also fetch the geometries} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-getMarineRegions}{}}} +\subsection{Method \code{getMarineRegions()}}{ +Retrieves the Marine Regions from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$getMarineRegions(with_geometries = TRUE, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{with_geometries}}{\if{html}{\out{}} Also fetch the geometries} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-getBlockMarineRegions}{}}} +\subsection{Method \code{getBlockMarineRegions()}}{ +Retrieves the block marine region map table from the +database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$getBlockMarineRegions(collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-getBlockConservationAreaDistances}{}}} +\subsection{Method \code{getBlockConservationAreaDistances()}}{ +Retrieves the block conservation areas map table from the +database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$getBlockConservationAreaDistances(collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Geometries-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Geometries$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.DB.Organisations.Rd b/man/MNR.DB.Organisations.Rd new file mode 100644 index 0000000..1fac67d --- /dev/null +++ b/man/MNR.DB.Organisations.Rd @@ -0,0 +1,294 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db_organisations.R +\name{MNR.DB.Organisations} +\alias{MNR.DB.Organisations} +\title{MNR database queries for Organsiations} +\value{ +A query object for an organsation (collect = FALSE) or a +tibble with the organisation details + +The organisation ids if as_int is TRUE, the organisation names +if as_int is FALSE and name_only is TRUE, else the organisations or an +uncollected query object + +TRUE if the organisation is a regulator + +The regulator ids if as_int is TRUE, the regulator names if +as_int is FALSE and name_only is TRUE, else the regulator or an +uncollected query object + +A tibble of the organisation members or an uncollected query + +TRUE if the user's organisation is an agent + +An uncollected query object or a tibble of agents + +An uncollected query object or a tibble of recipients + +The organisation id if as_int is TRUE, the organisation name if +as_int is FALSE and name_only is TRUE, else the organisation or an +uncollected query object +} +\description{ +MNR database queries for Organsiations + +MNR database queries for Organsiations +} +\section{Super class}{ +\code{\link[AVSDevR.MarineNoiseRegistry:MNR.DB]{AVSDevR.MarineNoiseRegistry::MNR.DB}} -> \code{MNR.DB.Organisations} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB.Organisations-getOrganisation}{\code{MNR.DB.Organisations$getOrganisation()}} +\item \href{#method-MNR.DB.Organisations-getAllOrganisations}{\code{MNR.DB.Organisations$getAllOrganisations()}} +\item \href{#method-MNR.DB.Organisations-isRegulator}{\code{MNR.DB.Organisations$isRegulator()}} +\item \href{#method-MNR.DB.Organisations-getRegulators}{\code{MNR.DB.Organisations$getRegulators()}} +\item \href{#method-MNR.DB.Organisations-getOrganisationMembers}{\code{MNR.DB.Organisations$getOrganisationMembers()}} +\item \href{#method-MNR.DB.Organisations-isAgent}{\code{MNR.DB.Organisations$isAgent()}} +\item \href{#method-MNR.DB.Organisations-getOrganisationAgents}{\code{MNR.DB.Organisations$getOrganisationAgents()}} +\item \href{#method-MNR.DB.Organisations-getAgentRecipients}{\code{MNR.DB.Organisations$getAgentRecipients()}} +\item \href{#method-MNR.DB.Organisations-getUserOrganisation}{\code{MNR.DB.Organisations$getUserOrganisation()}} +\item \href{#method-MNR.DB.Organisations-clone}{\code{MNR.DB.Organisations$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getOrganisation}{}}} +\subsection{Method \code{getOrganisation()}}{ +Fetch the details of an organisation from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getOrganisation(org_id, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{org_id}}{\if{html}{\out{}} The id of the organisation to fetch} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getAllOrganisations}{}}} +\subsection{Method \code{getAllOrganisations()}}{ +Fetch the details of all organisations from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getAllOrganisations( + as_int = FALSE, + name_only = TRUE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{as_int}}{\if{html}{\out{}} Return only the ids (TRUE)} + +\item{\code{name_only}}{\if{html}{\out{}} Return only the name (TRUE)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-isRegulator}{}}} +\subsection{Method \code{isRegulator()}}{ +Check if an organisation is a regulator +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$isRegulator(org_id)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{org_id}}{\if{html}{\out{}} The id of the organisation to check} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getRegulators}{}}} +\subsection{Method \code{getRegulators()}}{ +Fetch the details of all the regulators from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getRegulators( + as_int = FALSE, + name_only = TRUE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{as_int}}{\if{html}{\out{}} Return only the ids (TRUE)} + +\item{\code{name_only}}{\if{html}{\out{}} Return only the name (TRUE)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getOrganisationMembers}{}}} +\subsection{Method \code{getOrganisationMembers()}}{ +Fetch the members of an organisation +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getOrganisationMembers( + org_name = "", + org_id = -1, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{org_name}}{\if{html}{\out{}} The name of the organisation to check} + +\item{\code{org_id}}{\if{html}{\out{}} The id of the organisation to check} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-isAgent}{}}} +\subsection{Method \code{isAgent()}}{ +Check if user's organisation is an agent for another +organisation +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$isAgent(org_id)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{org_id}}{\if{html}{\out{}} The id of the organisation to check} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getOrganisationAgents}{}}} +\subsection{Method \code{getOrganisationAgents()}}{ +Fetch the agents of an organisation +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getOrganisationAgents( + org_id, + as_int = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{org_id}}{\if{html}{\out{}} The id of the organisation to check} + +\item{\code{as_int}}{\if{html}{\out{}} Return only the id (TRUE)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getAgentRecipients}{}}} +\subsection{Method \code{getAgentRecipients()}}{ +Fetch the recipients of an organisation +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getAgentRecipients( + agent_id, + as_int = FALSE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{agent_id}}{\if{html}{\out{}} The id of the organisation (agent) to check} + +\item{\code{as_int}}{\if{html}{\out{}} Return only the id (TRUE)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-getUserOrganisation}{}}} +\subsection{Method \code{getUserOrganisation()}}{ +Fetch the organisation of a user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$getUserOrganisation( + user_id, + as_int = TRUE, + name_only = TRUE, + collect = TRUE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The id of the user to fetch the organisation of} + +\item{\code{as_int}}{\if{html}{\out{}} Return only the id (TRUE)} + +\item{\code{name_only}}{\if{html}{\out{}} Return only the name (TRUE)} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Organisations-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Organisations$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.DB.Rd b/man/MNR.DB.Rd new file mode 100644 index 0000000..9e2d77b --- /dev/null +++ b/man/MNR.DB.Rd @@ -0,0 +1,68 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db.R +\name{MNR.DB} +\alias{MNR.DB} +\title{MNR database queries base class} +\value{ +<\link[AVSDevR.DBClient]{DBClient}> The DBClient instance used +by the class instance +} +\description{ +MNR database queries base class + +MNR database queries base class +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB-new}{\code{MNR.DB$new()}} +\item \href{#method-MNR.DB-getDBClient}{\code{MNR.DB$getDBClient()}} +\item \href{#method-MNR.DB-clone}{\code{MNR.DB$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB-new}{}}} +\subsection{Method \code{new()}}{ +Initialises the instance with a database client +\link[AVSDevR.DBClient]{DBClient} +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB$new(db_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{db_client}}{<\link[AVSDevR.DBClient]{DBClient}> A DBClient instance} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB-getDBClient}{}}} +\subsection{Method \code{getDBClient()}}{ +Returns the current DBClient instance in use +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB$getDBClient()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.DB.Users.Rd b/man/MNR.DB.Users.Rd new file mode 100644 index 0000000..bfcb607 --- /dev/null +++ b/man/MNR.DB.Users.Rd @@ -0,0 +1,154 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/db_users.R +\name{MNR.DB.Users} +\alias{MNR.DB.Users} +\title{MNR database queries for Users} +\value{ +\if{html}{\out{}} Details of the user denoted by user_id + +\if{html}{\out{}} The user's name + +\if{html}{\out{}} A list of user roles + +\if{html}{\out{}} TRUE if the user is an administrator +} +\description{ +MNR database queries for Users + +MNR database queries for Users +} +\section{Super class}{ +\code{\link[AVSDevR.MarineNoiseRegistry:MNR.DB]{AVSDevR.MarineNoiseRegistry::MNR.DB}} -> \code{MNR.DB.Users} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.DB.Users-new}{\code{MNR.DB.Users$new()}} +\item \href{#method-MNR.DB.Users-getUser}{\code{MNR.DB.Users$getUser()}} +\item \href{#method-MNR.DB.Users-getUserName}{\code{MNR.DB.Users$getUserName()}} +\item \href{#method-MNR.DB.Users-getUserRoles}{\code{MNR.DB.Users$getUserRoles()}} +\item \href{#method-MNR.DB.Users-isApplicationsAdmin}{\code{MNR.DB.Users$isApplicationsAdmin()}} +\item \href{#method-MNR.DB.Users-clone}{\code{MNR.DB.Users$clone()}} +} +} +\if{html}{\out{ +
Inherited methods + +
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-new}{}}} +\subsection{Method \code{new()}}{ +Initialises the instance with a database client from +\link[AVSDevR.DBClient]{DBClient} +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$new(db_client, admin_role_slug = NULL)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{db_client}}{<\link[AVSDevR.DBClient]{DBClient}> A DBClient instance} + +\item{\code{admin_role_slug}}{\if{html}{\out{}} The slug of the application +administrator role within UserFrosting +(Defaults to: "application-admin")} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-getUser}{}}} +\subsection{Method \code{getUser()}}{ +Get user information from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$getUser(user_id, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user id to fetch} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-getUserName}{}}} +\subsection{Method \code{getUserName()}}{ +Get user name from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$getUserName(user_id)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user id to fetch} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-getUserRoles}{}}} +\subsection{Method \code{getUserRoles()}}{ +Get user roles from the database +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$getUserRoles(user_id, collect = TRUE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user id to fetch} + +\item{\code{collect}}{\if{html}{\out{}} Collect the query before returning (TRUE) or +return the built query object (FALSE)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-isApplicationsAdmin}{}}} +\subsection{Method \code{isApplicationsAdmin()}}{ +Check if a user is an application administrator +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$isApplicationsAdmin(user_id)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user_id}}{\if{html}{\out{}} The user id to fetch} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.DB.Users-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.DB.Users$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/MNR.GeoPlot.Rd b/man/MNR.GeoPlot.Rd new file mode 100644 index 0000000..b8af7b5 --- /dev/null +++ b/man/MNR.GeoPlot.Rd @@ -0,0 +1,167 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/geoPlot.R +\name{MNR.GeoPlot} +\alias{MNR.GeoPlot} +\title{MNR GIS plot base map generator} +\value{ +A plolty object base map + +The plotly object +} +\description{ +MNR GIS plot base map generator + +MNR GIS plot base map generator +} +\details{ +Base layers are loaded and cached on first call to each of the boot methods. +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-MNR.GeoPlot-new}{\code{MNR.GeoPlot$new()}} +\item \href{#method-MNR.GeoPlot-bootLayers}{\code{MNR.GeoPlot$bootLayers()}} +\item \href{#method-MNR.GeoPlot-bootQuadrants}{\code{MNR.GeoPlot$bootQuadrants()}} +\item \href{#method-MNR.GeoPlot-bootConservationAreas}{\code{MNR.GeoPlot$bootConservationAreas()}} +\item \href{#method-MNR.GeoPlot-makeBasePlot}{\code{MNR.GeoPlot$makeBasePlot()}} +\item \href{#method-MNR.GeoPlot-boundMap}{\code{MNR.GeoPlot$boundMap()}} +\item \href{#method-MNR.GeoPlot-clone}{\code{MNR.GeoPlot$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-new}{}}} +\subsection{Method \code{new()}}{ +Initialises the object by building the grid lines +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$new()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-bootLayers}{}}} +\subsection{Method \code{bootLayers()}}{ +Loads the JNCC layers required from file for the base map +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$bootLayers()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-bootQuadrants}{}}} +\subsection{Method \code{bootQuadrants()}}{ +Loads the Oil & Gas quadrants from file for the base map +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$bootQuadrants()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-bootConservationAreas}{}}} +\subsection{Method \code{bootConservationAreas()}}{ +Loads the Conservation Areas from the database for the base +map. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$bootConservationAreas(db_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{db_client}}{<\link[AVSDevR.DBClient]{DBClient}> A DBClient instance} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-makeBasePlot}{}}} +\subsection{Method \code{makeBasePlot()}}{ +Generates a base plotly map with optional layers included +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$makeBasePlot( + ..., + with_jncc_layers = TRUE, + with_quadrants = FALSE, + with_conservation_areas = FALSE +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{...}}{Options to call plotly::plot_ly with} + +\item{\code{with_jncc_layers}}{\if{html}{\out{}} Includes the JNCC base layers if TRUE +(call obj$bootLayers() first)} + +\item{\code{with_quadrants}}{\if{html}{\out{}} Includes the Oil & Gas Quadrants if TRUE +(call obj$bootQuadrants() first)} + +\item{\code{with_conservation_areas}}{\if{html}{\out{}} Includes the Conservation Areas +if TRUE (call obj$bootConservationAreas() first)} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-boundMap}{}}} +\subsection{Method \code{boundMap()}}{ +Bounds a mapbox map to a specific area and zoom +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$boundMap( + p, + c_lat = 56, + c_lon = -5.5, + zoom = 3.5, + xmin = -25, + ymin = 45, + xmax = 5, + ymax = 65 +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{p}}{A plotly mapbox map object} + +\item{\code{c_lat}}{\if{html}{\out{}} Center latitude} + +\item{\code{c_lon}}{\if{html}{\out{}} Center longitude} + +\item{\code{zoom}}{\if{html}{\out{}} A mapbox zoom level} + +\item{\code{xmin}}{\if{html}{\out{}} Minimum longitude to bound with} + +\item{\code{ymin}}{\if{html}{\out{}} Minimum latitude to bound with} + +\item{\code{xmax}}{\if{html}{\out{}} Maximum longitude to bound with} + +\item{\code{ymax}}{\if{html}{\out{}} Maximum latitude to bound with} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-MNR.GeoPlot-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{MNR.GeoPlot$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/attachResourcePaths.Rd b/man/attachResourcePaths.Rd new file mode 100644 index 0000000..ad004e3 --- /dev/null +++ b/man/attachResourcePaths.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use_mnr_ui.R +\name{attachResourcePaths} +\alias{attachResourcePaths} +\title{Attaches the MNR resource path to Shiny if not already attached} +\usage{ +attachResourcePaths() +} +\description{ +Attaches the MNR resource path to Shiny if not already attached +} diff --git a/man/resourcePrefix.Rd b/man/resourcePrefix.Rd new file mode 100644 index 0000000..74bdaf9 --- /dev/null +++ b/man/resourcePrefix.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use_mnr_ui.R +\name{resourcePrefix} +\alias{resourcePrefix} +\title{Provides the resource path for MNR specific files} +\usage{ +resourcePrefix() +} +\description{ +Provides the resource path for MNR specific files +} diff --git a/man/use_mnr_ui.Rd b/man/use_mnr_ui.Rd new file mode 100644 index 0000000..86c376b --- /dev/null +++ b/man/use_mnr_ui.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use_mnr_ui.R +\name{use_mnr_ui} +\alias{use_mnr_ui} +\title{Attaches the MNR stylesheets and scripts to the UI} +\usage{ +use_mnr_ui() +} +\description{ +Attaches the MNR stylesheets and scripts to the UI +}