diff --git a/data-raw/app_bcgov_theme.R b/data-raw/app_bcgov_theme.R new file mode 100644 index 00000000..ceddcf23 --- /dev/null +++ b/data-raw/app_bcgov_theme.R @@ -0,0 +1,59 @@ +if (!identical(getwd(), rprojroot::find_package_root_file())) { + stop("This script must be run from the top directory of the climr package") +} + +if (!any(grepl("^bslib$", rownames(installed.packages())))) { + stop("This script must be run from the after the installation of bslib package") +} + +# Set working directory to repo root +bsw5_repo <- "https://github.com/bcgov/bootstrap-v5-theme/archive/refs/heads/master.zip" +z <- tempfile(fileext = ".zip") +curl::curl_download(bsw5_repo, z) +f <- unzip(z, list = TRUE)$Name + +# Copy fonts +f1 <- grep("/dist/fonts/.+woff2?", f, value = TRUE) +unlink("inst/fonts/", recursive = TRUE) +dir.create("inst/fonts/", showWarnings = FALSE) +unzip(z, f1, junkpaths = TRUE, exdir = "inst/fonts/", overwrite = TRUE) + +# Copy images +f2 <- grep("/dist/images/.+(png|svg)", f, value = TRUE) +unlink("inst/shiny/www/images", recursive = TRUE) +dir.create("inst/shiny/www/images", showWarnings = FALSE) +unzip(z, f2, junkpaths = TRUE, exdir = "inst/shiny/www/images", overwrite = TRUE) + +# SCSS files +f3 <- grep("/dist/scss/.+scss", f, value = TRUE) +unlink("inst/lib/bsw5/dist/bcgov/", recursive = TRUE) +dir.create("inst/lib/bsw5/dist/bcgov/", showWarnings = FALSE) +unzip(z, f3, junkpaths = TRUE, exdir = "inst/lib/bsw5/dist/bcgov/", overwrite = TRUE) + +#Font file +f4 <- grep("_fonts.scss", dir("inst/lib/bsw5/dist/bcgov", recursive = TRUE, full.names = TRUE), value = TRUE) +f5 <- readLines(f4, warn = FALSE) |> gsub("../fonts/bc-sans", "fonts", x = _) +writeLines(f5, f4) + +# Appending +f6 <- grep("_additions.scss|_overrides.scss", dir("inst/lib/bsw5/dist/bcgov", recursive = TRUE, full.names = TRUE), value = TRUE) +bsw <- "inst/lib/bsw5/dist/bcgov/_bootswatch.scss" +file.create(bsw) +lapply(f6, file.append, file1 = bsw) +unlink(f6) + +# Drop unneeded +f7 <- grep("_common.scss|bootstrap-theme.scss", dir("inst/lib/bsw5/dist/bcgov", recursive = TRUE, full.names = TRUE), value = TRUE) +unlink(f7) + +# Files renaming +file.rename(f4, sub("_fonts.scss","font.css", f4)) + +# Patching +f8 <- readLines(bsw) +f8 <- gsub("^header nav", "body nav", f8) +writeLines(f8, bsw) + +v <- "inst/lib/bsw5/dist/bcgov/_variables.scss" +cat(c("\n$nav-underline-border-width: 0rem !default;", '\n$theme: "bcgov" !default;', '\n$navbar-bg: theme-color(primary-nav);'), file = v, append = TRUE) + diff --git a/data-raw/app_file_dep.R b/data-raw/app_file_dep.R new file mode 100644 index 00000000..4df63d69 --- /dev/null +++ b/data-raw/app_file_dep.R @@ -0,0 +1,9 @@ +# Leaflet vector grid plugin +dir.create("inst/shiny/www/htmlwidgets", showWarnings = FALSE, recursive = TRUE) +utils::download.file("https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.bundled.min.js", + "inst/shiny/www/htmlwidgets/lfx-vgrid-prod.js") + +# Western North-America BEC Subzone coloring from CCISS +dir.create("inst/shiny/data", showWarnings = FALSE, recursive = TRUE) +utils::download.file("https://github.com/bcgov/ccissr/raw/refs/heads/main/data-raw/data_tables/WNAv12_3_SubzoneCols.csv", + "inst/shiny/data/WNAv12_3_SubzoneCols.csv") diff --git a/inst/shiny/server.R b/inst/extdata/server.R similarity index 100% rename from inst/shiny/server.R rename to inst/extdata/server.R diff --git a/inst/shiny/ui.R b/inst/extdata/ui.R similarity index 100% rename from inst/shiny/ui.R rename to inst/extdata/ui.R diff --git a/inst/fonts/BCSans-Bold.woff b/inst/fonts/BCSans-Bold.woff new file mode 100644 index 00000000..f2ecf167 Binary files /dev/null and b/inst/fonts/BCSans-Bold.woff differ diff --git a/inst/fonts/BCSans-Bold.woff2 b/inst/fonts/BCSans-Bold.woff2 new file mode 100644 index 00000000..681df5b5 Binary files /dev/null and b/inst/fonts/BCSans-Bold.woff2 differ diff --git a/inst/fonts/BCSans-BoldItalic.woff b/inst/fonts/BCSans-BoldItalic.woff new file mode 100644 index 00000000..9a3353c2 Binary files /dev/null and b/inst/fonts/BCSans-BoldItalic.woff differ diff --git a/inst/fonts/BCSans-BoldItalic.woff2 b/inst/fonts/BCSans-BoldItalic.woff2 new file mode 100644 index 00000000..d2302357 Binary files /dev/null and b/inst/fonts/BCSans-BoldItalic.woff2 differ diff --git a/inst/fonts/BCSans-Italic.woff b/inst/fonts/BCSans-Italic.woff new file mode 100644 index 00000000..fb061a3e Binary files /dev/null and b/inst/fonts/BCSans-Italic.woff differ diff --git a/inst/fonts/BCSans-Italic.woff2 b/inst/fonts/BCSans-Italic.woff2 new file mode 100644 index 00000000..50baec2b Binary files /dev/null and b/inst/fonts/BCSans-Italic.woff2 differ diff --git a/inst/fonts/BCSans-Regular.woff b/inst/fonts/BCSans-Regular.woff new file mode 100644 index 00000000..07f8f0b7 Binary files /dev/null and b/inst/fonts/BCSans-Regular.woff differ diff --git a/inst/fonts/BCSans-Regular.woff2 b/inst/fonts/BCSans-Regular.woff2 new file mode 100644 index 00000000..056d2cc5 Binary files /dev/null and b/inst/fonts/BCSans-Regular.woff2 differ diff --git a/inst/lib/bsw5/dist/bcgov/_bootswatch.scss b/inst/lib/bsw5/dist/bcgov/_bootswatch.scss new file mode 100644 index 00000000..1a29b643 --- /dev/null +++ b/inst/lib/bsw5/dist/bcgov/_bootswatch.scss @@ -0,0 +1,201 @@ +//--------------------------------------------------------------------------------------- +// Additions are for extra classes not found in the normal Bootstrap +// WARNING: Do not create alot of new things here, remember always try to tweak and variable +// or override bootstrap css before trying to create something new. +//--------------------------------------------------------------------------------------- +// sass-lint:disable force-element-nesting, force-pseudo-nesting + +// The label element is no longer bolded by default, neither is this class defined +.form-label { + font-weight: 700; +} + +// Option to keep footer at the bottom of the page +@each $breakpoint in map-keys($grid-breakpoints) { + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); + @include media-breakpoint-up($breakpoint) { + // Set on html element to keep footer at bottom of window short pages + + body, .fill-body { + display: flex; + flex-direction: column; + min-height: 100vh; + } + // Apply to extra container element(s) around the main + .fill-body { + flex: 1; + } + header, .header, footer, .footer { + flex: none; + } + main, .main { + flex: 1; + overflow: auto; + } + + } +} + +$info-alert-border-level: -4; + +//Theme-color function is initizled as it was dropped with version 5 migration +@function theme-color($color-name){ + @return map-get($map: $theme-colors, $key: $color-name); +} + +// Add panel-success, panel-info etc. equivalents (like bootstrap v3) +@each $color, $value in (primary, secondary, success, info, warning, danger) { + .card-#{$color} { + border-color: theme-color($color); + > .card-header{ + background-color: tint-color(theme-color($color),85%); + color: tint-color(theme-color($color),0.5%); + } + > .card-footer{ + border-color: theme-color($color); + } + } +} + +// Light text on dark header, with dark border. When you really want to look like the +// old default panel class +.card-default { + border-color: theme-color(primary); + > .card-header { + background: theme-color(primary); + border-color: theme-color(primary); + color: theme-color(light); + } + > .card-footer { + border-color: theme-color(primary); + } +}//--------------------------------------------------------------------------------------- +// Overrides Bootstrap classes are change here, consider changing a variable before +// overriding classes. +//--------------------------------------------------------------------------------------- +// Reference: http://www2.gov.bc.ca/gov/content/governments/services-for-government/policies-procedures/web-content-development-guides/developers-guide/css-elements +// sass-lint:disable force-element-nesting, force-pseudo-nesting + +.nav-link, +.navbar-brand, +.page-link, +a.btn { + text-decoration: none; +} + +// Hover mixin and `$enable-hover-media-query` are deprecated. +// For backward compatibility +@mixin hover() { + &:hover { @content; } +} + +@mixin hover-focus() { + &:hover, + &:focus { + @content; + } +} + +@mixin plain-hover-focus() { + &, + &:hover, + &:focus { + @content; + } +} + +@mixin hover-focus-active() { + &:hover, + &:focus, + &:active { + @content; + } +} + + +.nav-tabs .nav-link:not(.active) { + @include hover-focus { + background-color: $control-link-bg; + border-color: $control-link-border-color; + color: $control-link-color; + } +} + +// Add focus ring to btn-link, highlight as regular link +.btn.btn-link { + text-decoration: underline; + &:focus, + &.focus { + box-shadow: 0 0 0 $btn-focus-width $btn-link-outline-color; + color: $link-hover-color; + } +} + +.btn{ + &.focus{ + border: 5px solid; + } + +} + + + +// Underline navbar links when active +.navbar-nav .nav-link { + @include hover-focus { + text-decoration: underline; + } +} + + +.list-group .list-group-item-action { + @include hover-focus { + text-decoration: underline; + } +} + +// Add spacing around content (use p-* to override) +main { + padding-bottom: 40px; + padding-top: 20px; +} + + +//Theme-color function is initizled as it was dropped with version 5 migration +@function theme-color($color-name){ + @return map-get($map: $theme-colors, $key: $color-name); +} + +// Header, adds the gold bottom border and shadow +body nav { + background-color: theme-color(primary-nav); + border-bottom: 2px solid theme-color(bcgold); + &.shadow { + box-shadow: 0 3px 3px 1px $header-box-shadow-color; + } +} + +// Set footer background, add gold border above +footer nav { + background-color: theme-color(primary-nav); + border-top: 2px solid theme-color(bcgold); +} + +// Only sibling list items in footer get left border +@each $breakpoint in map-keys($grid-breakpoints) { + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); + footer .navbar-expand#{$infix} .nav-item + .nav-item { + @include media-breakpoint-up($breakpoint) { + border-left: 1px solid $footer-separator-color; + } + } +} + +// Stronger border colour +.alert.alert-info { + border-color: color-level(info, -4); +} +.alert.alert-warning { + border-color: color-level(warning, -4); +} + diff --git a/inst/lib/bsw5/dist/bcgov/_variables.scss b/inst/lib/bsw5/dist/bcgov/_variables.scss new file mode 100644 index 00000000..340fe7e1 --- /dev/null +++ b/inst/lib/bsw5/dist/bcgov/_variables.scss @@ -0,0 +1,102 @@ +// Change theme-colors +$theme-colors: ( + primary: #38598a, + secondary:#6c757d, // new entry + success: #43893e, + info: #96c0e6, + warning: #f9ca54, + danger: #d93e45, + // new entries + primary-nav: #036, + secondary-nav: #5475a7, + bcgold: #fcba19, + light:#f8f9fa, // new entries + dark: #212529, // new entries +); + +//Theme-color function is initizled as it was dropped with version 5 migration +@function theme-color($color-name){ + @return map-get($map: $theme-colors, $key: $color-name); +} + +// Add our font as default +$bcgov-font-path: "../fonts" !default; +$font-family-sans-serif: BCSans, "Noto Sans", Verdana, Arial, sans serif !default; +$font-family-base: $font-family-sans-serif !default; +$line-height-base: 1.6 !default; +$body-color: #494949 !default; + +// Headings +$headings-font-weight: 700 !default; +$headings-line-height: 1.1 !default; +$headings-margin-bottom: 1.25rem !default; +$h1-font-size: 2.074rem !default; +$h2-font-size: 1.54912rem !default; +$h3-font-size: 1.33882rem !default; +$h4-font-size: 1rem !default; +$h5-font-size: 0.86425rem !default; +$h6-font-size: 0.80345rem !default; + +// Links +$link-text-decoration: underline !default; +$link-color: #1a5a96 !default; +$link-hover-color: #0631f3 !default; +$btn-link-outline-color: rgba(theme-color(primary), 0.5) !default; + +// Navbar - header and footer +$header-box-shadow-color: rgba(51, 51, 51, 0.5) !default; +$nav-link-padding-x: 0.8rem !default; +$nav-link-padding-y: 0.4rem !default; +$navbar-nav-link-padding-x: 0.8rem !default; +$navbar-nav-link-padding-y: 0.4rem !default; +$navbar-dark-color: #fff !default; +$navbar-dark-toggler-border-color: rgba(255, 255, 255, 0.6) !default; +$footer-separator-color: #4b5e73 !default; + +// Table header +$table-dark-bg: theme-color(primary) !default; +$table-dark-border-color: theme-color(primary) !default; + +// Darker borders +$gray-300: #dee2e6 !default; +$gray-400: #ced4da !default; +$gray-450: #bdc5cc !default; +$gray-500: #adb5bd !default; +$alpha-border-color: rgba(black, 0.3) !default; +$alert-border-level: -7 !default; +$card-border-color: $alpha-border-color !default; +$hr-border-color: $alpha-border-color !default; +$border-color: $gray-400 !default; +$input-border-color: $gray-500 !default; +$list-group-border-color: $alpha-border-color !default; +$nav-tabs-border-color: $gray-500 !default; +$nav-tabs-link-active-border-color: $gray-500 $gray-500 white !default; +$pagination-border-color: $gray-500 !default; +$pagination-disabled-border-color: $gray-400 !default; +// $pagination-active-border-color: $pagination-active-bg !default; +$table-border-color: $gray-450 !default; +$table-border-level: -5 !default; + +// Clearer hover states +$control-link-color: white !default; +$control-link-bg: tint-color( theme-color(secondary-nav),10%) !default; // custom var +$control-link-border-color: tint-color( theme-color(secondary-nav),10%) !default; // custom var + +$pagination-active-bg: theme-color(primary); //new entries +$pagination-active-border-color: theme-color(primary); //new entries +$pagination-hover-color: $control-link-color; +$pagination-hover-bg: $control-link-bg !default; +$pagination-hover-border-color: $control-link-border-color !default; +$list-group-active-bg: $control-link-bg !default; +$list-group-active-border-color: $control-link-border-color !default; +$list-group-action-hover-color: $link-hover-color; +$nav-tabs-link-hover-border-color: $control-link-color $control-link-color +$nav-tabs-border-color !default; + +$list-group-item-padding-y: 12px; //for navbar spacing + +$nav-pills-link-active-bg: theme-color(primary); //new entry for active color on pills w/t dropdowns +$progress-bar-bg:theme-color(primary); //new entry for progress bars +$nav-underline-border-width: 0rem !default; +$theme: "bcgov" !default; +$navbar-bg: theme-color(primary-nav); \ No newline at end of file diff --git a/inst/lib/bsw5/dist/bcgov/font.css b/inst/lib/bsw5/dist/bcgov/font.css new file mode 100644 index 00000000..afab3a1a --- /dev/null +++ b/inst/lib/bsw5/dist/bcgov/font.css @@ -0,0 +1,28 @@ +@font-face { + src: url("fonts/BCSans-Regular.woff2") format('woff2'), + url("fonts/BCSans-Regular.woff") format("woff"); + font-weight: 400; + font-style: normal; + font-family: "BCSans"; + } + @font-face { + src: url("fonts/BCSans-BoldItalic.woff2") format("woff2"), + url("fonts/BCSans-BoldItalic.woff") format("woff"); + font-weight: 700; + font-style: italic; + font-family: "BCSans"; + } + @font-face { + src: url("fonts/BCSans-Italic.woff2") format("woff2"), + url("fonts/BCSans-Italic.woff") format("woff"); + font-weight: 400; + font-style: italic; + font-family: "BCSans"; + } + @font-face { + src: url("fonts/BCSans-Bold.woff2") format("woff2"), + url("fonts/BCSans-Bold.woff") format("woff"); + font-weight: 700; + font-style: normal; + font-family: "BCSans"; + } diff --git a/inst/shiny/app.R b/inst/shiny/app.R new file mode 100644 index 00000000..0368b6a3 --- /dev/null +++ b/inst/shiny/app.R @@ -0,0 +1,315 @@ + +# Setup ---- + +library(shiny) +library(leaflet) +library(leaflet.extras) +library(DT) + +source("scripts/utils.R") + +# Data source poll ---- + +# precipitation <- lapply(1L:90L, function(i) { +# f <- \() sprintf("%sT06Z_MSC_HRDPA_APCP-Accum24h_Sfc_RLatLon0.0225_PT0H.tif", format(Sys.Date()-i+1L, "%Y%m%d")) +# dt_prep("model_hrdpa/2.5km/06", f, terra::rast) +# }) +# pcols <- local({ +# z <- rev(terra:::.default.pal()) |> grDevices::col2rgb() +# grDevices::rgb(red = z[1,], green = z[2,], blue = z[3,], maxColorValue = 255, alpha = (seq_along(z[1,]) - 1) * 0.91 / 100 * 255) +# }) + +# MapBox values +mbtk <- Sys.getenv("BCGOV_MAPBOX_TOKEN") +mblbstyle <- Sys.getenv("BCGOV_MAPBOX_LABELS_STYLE") +mbhsstyle <- Sys.getenv("BCGOV_MAPBOX_HILLSHADE_STYLE") + +# Base map ---- +l <- leaflet::leaflet() |> + # base layer + leaflet::addProviderTiles( + provider = leaflet::providers$CartoDB.PositronNoLabels, + options = leaflet::pathOptions(pane = "mapPane"), + group = "Light" + ) |> + leaflet::addProviderTiles( + provider = leaflet::providers$CartoDB.DarkMatterNoLabels, + options = leaflet::pathOptions(pane = "mapPane"), + group = "Dark" + ) |> + leaflet::addProviderTiles( + provider = leaflet::providers$Esri.WorldImagery, + options = leaflet::pathOptions(pane = "mapPane"), + group = "Satellite" + ) |> + leaflet::addProviderTiles( + provider = leaflet::providers$OpenStreetMap, + options = leaflet::pathOptions(pane = "mapPane"), + group = "OpenStreetMap" + ) |> + leaflet::addTiles( + urlTemplate = paste0("https://api.mapbox.com/styles/v1/", mbhsstyle, "/tiles/{z}/{x}/{y}?access_token=", mbtk), + attribution = '© Mapbox', + options = leaflet::pathOptions(pane = "mapPane"), + group = "Hillshade" + ) |> + # overlay layer + leaflet::addTiles( + urlTemplate = paste0("https://api.mapbox.com/styles/v1/", mblbstyle, "/tiles/{z}/{x}/{y}?access_token=", mbtk), + attribution = '© Mapbox', + options = leaflet::pathOptions(pane = "overlayPane"), + group = "Labels" + ) |> + add_wna() |> + # extensions + leaflet.extras::addSearchOSM( + options = leaflet.extras::searchOptions( + collapsed = TRUE, + hideMarkerOnCollapse = TRUE, + autoCollapse = TRUE, + zoom = 11 + ) + ) |> + leaflet::addLayersControl( + baseGroups = c("Light", "Dark", "Satellite", "OpenStreetMap", "Hillshade"), + overlayGroups = c("Labels", "WNA BEC"), + position = "topright" + ) |> + leaflet::setView(lng = -100, lat = 50, zoom = 5) |> + leaflet::addMiniMap(toggleDisplay = TRUE, minimized = TRUE) + +# Shiny App ---- + +shiny::shinyApp( + +# Shiny UI ---- + + ui = shiny::navbarPage(collapsible = TRUE, + theme = bslib::bs_theme( + preset = "bcgov", + "navbar-brand-padding-y" = "0rem", + "navbar-brand-margin-end" = "4rem" + ), + title = shiny::tagList( + shiny::tags$image( + src = "images/bcid-logo-rev-en.svg", + style = "display: inline-block", + height = "35px", + alt = "British Columbia" + ), + "ClimR" + ), + shiny::tabPanel(title = "Map", + shiny::div(class="outer", + leaflet::leafletOutput("climr", width = "100%", height = "100%"), + shiny::absolutePanel( + top = "204px", + right = "10px", + shiny::fileInput("upload", "Upload file or geometry") + ) + ) + ), + shiny::navbarMenu( + "Data", + "Locations", + shiny::tabPanel(title = "Points", + DT::DTOutput(outputId = "points_dt") + ) + ), + shiny::navbarMenu( + "About", + "----", + shiny::tabPanel("How to use") + ), + header = list( + shiny::includeCSS("www/style.css"), + shiny::includeScript("www/script.js") + ) + ) + + , + +# Shiny server ---- + + server = function(input, output, session) { + + output$climr <- leaflet::renderLeaflet(l) + +# Climate layers ---- + + # lyr_added <- list() + # current_date_idx <- list() + + # # Flood Zones + # shiny::observe({ + # selected_groups <- shiny::req(input$geonesis_groups) + # if (overlays$fz %in% selected_groups & !isTRUE(lyr_added[[overlays$fz]])) { + # shiny::withProgress({ + # shiny::setProgress(0.33, "Reading spatial feature") + # fz <- flood_zones() + # if (is.null(fz)) { + # shiny::setProgress(1, "Cancelled") + # shiny::showNotification("Flood zones data is currently unavailable.", type = "warning") + # leaflet::leafletProxy("geonesis") |> + # leaflet::hideGroup(overlays$fz) + # } else { + # shiny::setProgress(0.66, "Adding flood zones data to map") + # leaflet::leafletProxy("geonesis") |> + # leaflet::addPolygons( + # data = fz, color = "blue", weight = 1, smoothFactor = 0.25, + # opacity = 1.0, fillOpacity = 0.25, + # popup = shiny::HTML("Présence de zones inondables cartographiées ", shiny::a("(Details)", target = "_blank", href = "https://geoinondations.gouv.qc.ca/glossaire.html") |> as.character()), + # group = overlays$fz + # ) + # lyr_added[[overlays$fz]] <<- TRUE; rm(fz) + # shiny::setProgress(1, "Drawing polygons") + # } + # }) + # } + # }) + + # # Burned Zones + # shiny::observe({ + # selected_groups <- shiny::req(input$geonesis_groups) + # if (overlays$bz %in% selected_groups & !isTRUE(lyr_added[[overlays$bz]])) { + # shiny::withProgress({ + # shiny::setProgress(0.33, "Reading spatial feature") + # p <- perimeters() + # if (is.null(p)) { + # shiny::setProgress(1, "Cancelled") + # shiny::showNotification("Burning zones data is currently unavailable.", type = "warning") + # leaflet::leafletProxy("geonesis") |> + # leaflet::hideGroup(overlays$bz) + # } else { + # shiny::setProgress(0.66, "Adding burning zones data to map") + # leaflet::leafletProxy("geonesis") |> + # leaflet::addPolygons( + # data = p, color = "red", weight = 1, smoothFactor = 0.25, + # opacity = 1.0, fillOpacity = 0.25, + # popup = leafpop::popupTable( + # local({ + # a <- p[,3:5] + # a$i <- shiny::HTML( + # "Season-to-date buffered hotspots
(> 1000 Ha) ", + # shiny::a( + # "(Details)", + # target = "_blank", + # href = "https://cwfis.cfs.nrcan.gc.ca/mini-entrepot/metadata/fm3buffered" + # ) |> as.character() + # ) + # names(a)[1] <- "Hectares";a + # }), + # zcol = c(1:3,5), row.numbers = FALSE, feature.id = FALSE + # ), + # group = overlays$bz + # ) + # lyr_added[[overlays$bz]] <<- TRUE; rm(p) + # shiny::setProgress(1, "Drawing polygons") + # } + # }) + # } + # }) + + # # Active Fires + # shiny::observe({ + # selected_groups <- shiny::req(input$geonesis_groups) + # if (overlays$af %in% selected_groups & !isTRUE(lyr_added[[overlays$af]])) { + # shiny::withProgress({ + # shiny::setProgress(0.33, "Reading spatial feature") + # af <- active_fires() + # if (is.null(af)) { + # shiny::setProgress(1, "Cancelled") + # shiny::showNotification("Active fires data is currently unavailable.", type = "warning") + # leaflet::leafletProxy("geonesis") |> + # leaflet::hideGroup(overlays$af) + # } else { + # shiny::setProgress(0.66, "Adding active fires data to map") + # leaflet::leafletProxy("geonesis") |> + # leaflet::addCircleMarkers( + # data = af, radius = ~radius, color = "#000", weight = 0.5, + # opacity = 1, fillColor = ~stage_color, fillOpacity = 1, + # popup = leafpop::popupTable( + # af, row.numbers = FALSE, feature.id = FALSE, + # zcol = c(1:7) + # ), group = overlays$af + # ) |> + # leaflet::addLegend( + # colors = c("Red", "Yellow", "DodgerBlue", "Orange"), + # labels = c("Out of control", "Being held", "Under control", "Other"), + # group = overlays$af, + # opacity = 0.8, title = overlays$af, position = "bottomright" + # ) + # lyr_added[[overlays$af]] <<- TRUE; rm(af) + # shiny::setProgress(1, "Drawing polygons") + # } + # }) + # } + # }) + + # # Precipitation + # shiny::observe({ + # selected_groups <- shiny::req(input$geonesis_groups) + # selected_date <- shiny::req(input$as_of_date) + # if (overlays$p %in% selected_groups) { + # if (!isTRUE(lyr_added[[overlays$p]])) { + # shiny::withProgress({ + # shiny::setProgress(0.33, "Reading spatial raster") + # current_date_idx[[overlays$p]] <<- i <- {Sys.Date() - selected_date} |> as.integer() + # p <- precipitation[[i]]() + # if (is.null(p)) { + # shiny::setProgress(1, "Cancelled") + # shiny::showNotification("Precipitation (HRDPA) data is currently unavailable for selected date.", type = "warning") + # leaflet::leafletProxy("geonesis") |> + # leaflet::hideGroup(overlays$p) + # } else { + # shiny::setProgress(0.66, "Adding precipitation (HRDPA) data to map") + # r <- terra::minmax(p) + # v <- seq(r[1], r[2], length.out=5) + # pal <- leaflet::colorNumeric(pcols, v, reverse = TRUE) + # leaflet::leafletProxy("geonesis") |> + # leaflet::addRasterImage(p, colors = pcols, opacity=1, project = TRUE, group = overlays$p, layerId = overlays$p, options = gridOptions(zIndex = 10)) |> + # leaflet::addLegend( + # position = "bottomright", pal = pal, values = v, opacity = 1, + # title = "Precipitation (HRDPA) [mm]", group = overlays$p, layerId = overlays$p, + # labFormat = leaflet::labelFormat(transform = function(x) sort(x, decreasing = TRUE)) + # ) + # lyr_added[[overlays$p]] <<- TRUE; rm(p) + # shiny::setProgress(1, "Drawing raster") + # } + # }) + # } else { + # j <- {Sys.Date() - selected_date} |> as.integer() + # if (current_date_idx[[overlays$p]] != j) { + # shiny::withProgress({ + # shiny::setProgress(0.33, "Replacing spatial raster") + # current_date_idx[[overlays$p]] <<- j + # p <- precipitation[[j]]() + # if (is.null(p)) { + # shiny::setProgress(1, "Cancelled") + # shiny::showNotification("Precipitation (HRDPA) data is currently unavailable for selected date.", type = "warning") + # leaflet::leafletProxy("geonesis") |> + # leaflet::hideGroup(overlays$p) + # } else { + # shiny::setProgress(0.66, "Adding precipitation (HRDPA) data to map") + # r <- terra::minmax(p) + # v <- seq(r[1], r[2], length.out=5) + # pal <- leaflet::colorNumeric(pcols, v, reverse = TRUE) + # leaflet::leafletProxy("geonesis") |> + # leaflet::clearGroup(overlays$p) |> + # leaflet::removeControl(overlays$p) |> + # leaflet::addRasterImage(p, colors = pcols, opacity=1, project = TRUE, group = overlays$p, layerId = overlays$p, options = gridOptions(zIndex = 10)) |> + # leaflet::addLegend( + # position = "bottomright", pal = pal, values = v, opacity = 1, + # title = "Precipitation (HRDPA) [mm]", group = overlays$p, layerId = overlays$p, + # labFormat = leaflet::labelFormat(transform = function(x) sort(x, decreasing = TRUE)) + # ) + # lyr_added[[overlays$p]] <<- TRUE; rm(p) + # shiny::setProgress(1, "Drawing raster") + # } + # }) + # } + # } + # } + # }) + } +) diff --git a/inst/shiny/data/WNAv12_3_SubzoneCols.csv b/inst/shiny/data/WNAv12_3_SubzoneCols.csv new file mode 100644 index 00000000..4a5f7981 --- /dev/null +++ b/inst/shiny/data/WNAv12_3_SubzoneCols.csv @@ -0,0 +1,405 @@ +classification,colour +(None),#000000 +BAFAun,#E2F5F1 +BAFAunp,#F0E1DD +BGdh_OR,#E8241A +BGdw_WA,#EB2A24 +BGmk_MT,#E33339 +BGmk_NV,#E25069 +BGmm_MT,#CD423F +BGmw_WA,#E4585D +BGwm_WA,#D51925 +BGxh_WA,#DB1010 +BGxh1,#E53443 +BGxh2,#D72828 +BGxh3,#E75E63 +BGxw1,#D64945 +BGxw2,#D71515 +BGxx_WY,#DF325E +BSJPap,#4040D6 +BSJPku,#6E7ACA +BSJPpa,#3449E8 +BWBScm,#286AE2 +BWBScmC,#487FB7 +BWBScmE,#4797E7 +BWBScmNW,#71B5E8 +BWBScmW,#1774FF +BWBSdk,#7687E3 +BWBSdm,#627FD6 +BWBSdmN,#5A7E99 +BWBSdmS,#A6C8F3 +BWBSlb,#727CD5 +BWBSlbE,#516EB5 +BWBSlbN,#4F7ACF +BWBSlbW,#2D5391 +BWBSlf,#253CEC +BWBSmk,#1633F0 +BWBSmw,#1645F0 +BWBSnm,#485CC9 +BWBSpp,#444EDB +BWBSub,#5469F0 +BWBSuf,#5A5CDF +BWBSvk,#2C3BE0 +BWBSwk1,#7A88E2 +BWBSwk2,#5B69C9 +BWBSwk3,#5F5DCC +CCHun_CA,#754862 +CDFmm,#FAEA05 +CDFmm_OR,#E1E42B +CDFmm_WA,#EBDE1B +CDFxm_CA,#FCFC1F +CMAun,#E8E9F3 +CMAun_CA,#DEF2EA +CMAun_OR,#CFDECF +CMAun_WA,#EAEADA +CMAunp,#E4F3EA +CMAwh,#F3E9EE +CMXdm_OR,#CC87E9 +CMXwm_OR,#DCA3DA +CMXxm_CA,#BB8FD6 +CRFdh_CA,#891A14 +CVGdm_CA,#EEB6A9 +CWFds_CA,#3B73CE +CWFmm_OR,#0D47AB +CWFwm_OR,#2168CB +CWHdm,#79D31F +CWHdm_OR,#7DD78C +CWHdm_WA,#1BB926 +CWHds_WA,#8DEF37 +CWHds1,#36D01B +CWHds2,#2DD42A +CWHmh_OR,#1DEC32 +CWHmm1,#76E7B0 +CWHmm2,#7EDD69 +CWHms_OR,#53E33C +CWHms_WA,#33E15F +CWHms1,#24DA27 +CWHms2,#87CB78 +CWHvh_WA,#3BD04F +CWHvh1,#22E514 +CWHvh2,#48EB4D +CWHvh3,#4DE15A +CWHvm_OR,#066D06 +CWHvm_WA,#289838 +CWHvm1,#24AC12 +CWHvm2,#258D0E +CWHwh_WA,#70EB74 +CWHwh1,#13D219 +CWHwh2,#68E41A +CWHwm,#60C87B +CWHws1,#41E377 +CWHws2,#41D45C +CWHxm_OR,#87EC91 +CWHxm_WA,#33E31B +CWHxm1,#40D964 +CWHxm2,#5DD991 +ESSFabC,#C155D9 +ESSFabE,#B62DD8 +ESSFabN,#E4A6F3 +ESSFabS,#D876DD +ESSFabS2,#CEB1E9 +ESSFdc1,#C45AD6 +ESSFdc2,#B855CC +ESSFdc3,#B782DF +ESSFdcp,#8817DE +ESSFdcw,#9732DE +ESSFdh_WA,#671DA7 +ESSFdh1,#D0ABEE +ESSFdh2,#C08FE3 +ESSFdk_MT,#AD21EE +ESSFdk1,#7015DF +ESSFdk2,#A622CE +ESSFdkp,#C27AD8 +ESSFdkp_MT,#AA51CD +ESSFdkw,#5F2AF0 +ESSFdm_ID,#5F2AF0 +ESSFdmp_ID,#B074D0 +ESSFdv1,#BC67DD +ESSFdv2,#CB7EE0 +ESSFdvp,#981DC8 +ESSFdvw,#A01DC8 +ESSFmc,#C482D6 +ESSFmcp,#B23AD3 +ESSFmh,#CD79E0 +ESSFmk,#A317D5 +ESSFmkp,#B350D6 +ESSFmm1,#B861D4 +ESSFmm2,#AB2BCB +ESSFmm3,#C41BE5 +ESSFmmp,#C684E7 +ESSFmmw,#C360ED +ESSFmv1,#B54DD7 +ESSFmv2,#BE79E2 +ESSFmv3,#AD3FE4 +ESSFmv4,#974CEB +ESSFmvp,#AF47CB +ESSFmw,#AB1CDF +ESSFmw_WA,#8710E1 +ESSFmw1,#AE3AE0 +ESSFmw2,#A16CD2 +ESSFmwp,#BA6DD4 +ESSFmwp_WA,#B635D6 +ESSFmww,#E189D1 +ESSFun,#921AD2 +ESSFunp,#A52EEA +ESSFvc,#B525D1 +ESSFvcp,#BF4DC9 +ESSFvcw,#CE6AC4 +ESSFvh_ID,#A117CF +ESSFwc2,#C31AED +ESSFwc3,#CA3FEC +ESSFwc4,#DB45EB +ESSFwcp,#B22DCF +ESSFwcw,#E613DC +ESSFwh_MT,#BF68CE +ESSFwh1,#CD35DA +ESSFwh2,#AF2CD6 +ESSFwh3,#B125DB +ESSFwk1,#AC5BCF +ESSFwk2,#BC1CD8 +ESSFwm_MT,#D97EE1 +ESSFwm1,#D484EE +ESSFwm2,#B861CE +ESSFwm3,#D520EC +ESSFwm4,#C556E6 +ESSFwmp,#C35AD8 +ESSFwmp_MT,#B429CC +ESSFwmw,#E115BF +ESSFwv,#C031D3 +ESSFwvp,#A13ACA +ESSFxc_CO,#A72FD2 +ESSFxc_WA,#A76FCB +ESSFxc1,#A11ADA +ESSFxc2,#AE4AD6 +ESSFxc3,#871FD0 +ESSFxcp,#AD41EC +ESSFxcp_CO,#AA4FD8 +ESSFxcp_WA,#AD61D0 +ESSFxcw,#A553DF +ESSFxh_WA,#C97BEF +ESSFxk_MT,#D683DD +ESSFxk_UT,#A97ADC +ESSFxk_WY,#E747D5 +ESSFxkp_MT,#A422D3 +ESSFxkp_UT,#E981E9 +ESSFxv1,#A881EB +ESSFxv2,#441AEC +ESSFxvp,#7145DE +ESSFxvw,#8C5FCA +ESSFxw_OR,#7230C8 +ESSFxwp_OR,#D3689C +ESSFxx_WY,#E035E5 +FGff,#DBB74A +FGnf,#C69B23 +FGwk,#A07A19 +GBDdw_UT,#A4A487 +GBDxh_NV,#A09D85 +GBDxx_UT,#9C9969 +GOun_CO,#5D65D0 +ICHdh_ID,#71D86B +ICHdk,#71DE73 +ICHdm,#71EF65 +ICHdw_ID,#1BE714 +ICHdw1,#4AEF58 +ICHdw3,#1CD52F +ICHdw4,#4DDF42 +ICHmc1,#5CEE59 +ICHmc1a,#80D07D +ICHmc2,#20DC3F +ICHmh_MT,#64C829 +ICHmk1,#64E46F +ICHmk2,#0DDD18 +ICHmk3,#0DDD0D +ICHmk4,#1DE11D +ICHmk5,#41CA3C +ICHmm,#39E639 +ICHmw_MT,#86E869 +ICHmw1,#45E732 +ICHmw2,#96DB71 +ICHmw3,#7CDC71 +ICHmw4,#73D582 +ICHmw5,#92E681 +ICHvc,#81E689 +ICHvk_ID,#66D83C +ICHvk1,#16E024 +ICHvk2,#30DA4C +ICHwc,#6DE380 +ICHwk1,#93D478 +ICHwk2,#92E188 +ICHwk3,#4CCC38 +ICHwk4,#85DF62 +ICHxm1,#A4E949 +ICHxw,#75E67D +ICHxw_WA,#75E67D +ICHxwa,#80CD1A +IDFdc,#DED822 +IDFdh,#EEDB2C +IDFdh_MT,#C3CC18 +IDFdh_UT,#DBE33C +IDFdh_WA,#DEEC18 +IDFdk_MT,#D7E051 +IDFdk_WA,#D0CC51 +IDFdk1,#D7D768 +IDFdk2,#CDC753 +IDFdk3,#CDC553 +IDFdk4,#EAE30E +IDFdk5,#E4E63E +IDFdkx_MT,#F2E81C +IDFdm_MT,#DBD679 +IDFdm_WA,#D5D66C +IDFdm1,#E9E56E +IDFdm2,#E9D924 +IDFdw,#CEC622 +IDFdx_MT,#DAD974 +IDFdxx_WY,#E6C937 +IDFmw1,#DDDA13 +IDFmw2,#DDD313 +IDFww,#E9E55C +IDFww1,#EFE937 +IDFxc,#CEC819 +IDFxh_ID,#C1CB33 +IDFxh_WA,#DFDF27 +IDFxh1,#E8E983 +IDFxh2,#D7DA76 +IDFxh4,#EAE550 +IDFxk,#E0EC6D +IDFxm,#E0EC6D +IDFxm_CO,#D4CF29 +IDFxw,#E8E785 +IDFxx_MT,#E0DF7D +IDFxx_WA,#C3C82C +IDFxx1,#C8C654 +IDFxx2,#EDED2A +IGFdk_WA,#479EDC +IGFdw_OR,#4C9EDC +IGFmh_OR,#479FE7 +IGFmm_OR,#81B8D8 +IGFxm_OR,#ACD9E5 +IMAab,#DFF8F1 +IMAun,#E9E4F4 +IMAun_CO,#EAEAD9 +IMAun_ID,#E7DDD2 +IMAun_MT,#E5E9F3 +IMAun_OR,#DAE9EB +IMAun_UT,#EAE6F0 +IMAun_WA,#F2EFFE +IMAun_WY,#EBF3F3 +IMAunp,#EDECE1 +IWFdm_CO,#1BD79C +IWFdw_OR,#77D0AD +IWFxk_NV,#3AE3A8 +IWFxm_CA,#20DC85 +JPWdm_WY,#B08595 +JPWdw_UT,#A77274 +JPWmk_WY,#A57376 +JPWwm_CO,#AD737F +JPWxh_CA,#A87E86 +JPWxw_NV,#C37389 +MDCHun_NV,#BD2F12 +MGPdm,#BB8027 +MGPmg,#BB8F3D +MGPmw_MT,#A76E1F +MHdm_OR,#7F0FEF +MHds_OR,#9A4DEC +MHds_WA,#8D5A99 +MHmm_WA,#901B92 +MHmm1,#A75FEF +MHmm2,#984FCB +MHmmp,#9A6BCD +MHmmp_WA,#C77DE7 +MHms_WA,#A14EE4 +MHmsp_WA,#B849E0 +MHRFdm_OR,#74477A +MHRFds_CA,#80718A +MHRFdsp_CA,#602B83 +MHRFmm_OR,#805FB2 +MHRFmmp_OR,#5D1CD6 +MHun,#924DD3 +MHunp,#A748DA +MHwh,#B969D8 +MHwh1,#C17DE3 +MHwhp,#BB53EF +MSab,#D437A0 +MSabN,#D53C55 +MSabS,#CA2859 +MSdc1,#E760AF +MSdc2,#F066E0 +MSdc3,#CF2C5D +MSdh_MT,#E6858B +MSdh_UT,#D158A1 +MSdh_WY,#E02DAB +MSdk,#D23E90 +MSdk_CO,#E50F6F +MSdm_WA,#E03F9D +MSdm1,#E03A7A +MSdm2,#DB4FB8 +MSdm3,#D12785 +MSdv,#DC70AF +MSdw,#C96CAA +MSdw_MT,#DD0EA6 +MSmm_ID,#DF49C9 +MSmw1,#E421A0 +MSmw2,#EC89DE +MSSDun_NV,#807474 +MSxh_OR,#D266AE +MSxk_WA,#D720A9 +MSxk1,#DF82E3 +MSxk2,#E133E1 +MSxk3,#CD47BB +MSxm_CO,#E875AD +MSxv,#CB1B5E +MSxx_NV,#E88092 +OWun_CA,#C4BD7D +PPmx_WY,#EF9C15 +PPxh_CO,#F4A316 +PPxh_WA,#E7AB1D +PPxh1,#DB8B28 +PPxh2,#C36C09 +PPxh3,#E18112 +PPxk_OR,#D3730D +PPxm_OR,#E58714 +PPxw,#E78534 +PPxw_MT,#CD8F25 +PPxw_WY,#ED5F34 +PPxx_OR,#D28212 +SASbo,#2D4870 +SBAPcp,#7AC0DC +SBAPfp,#1DA5E8 +SBAPmw,#78E2E3 +SBPSdc,#2AD1E0 +SBPSmc,#3AC6CD +SBPSmk,#6AC6C9 +SBPSxc,#76E4E5 +SBSdh1,#2955E4 +SBSdh2,#129EE9 +SBSdk,#3B9BD6 +SBSdw1,#3EA8EA +SBSdw2,#0EBBE6 +SBSdw3,#5964E3 +SBSmc1,#55B5F0 +SBSmc2,#5E91C8 +SBSmc3,#2CB3EC +SBSmh,#86A7E0 +SBSmk1,#6D8CD4 +SBSmk2,#448CEA +SBSmm,#12B7D8 +SBSmw,#7AABD5 +SBSun,#2F93F0 +SBSvk,#1672C9 +SBSwk1,#1479F4 +SBSwk2,#437BC9 +SBSwk3,#4B70EA +SBSwk3a,#7A94E0 +SGPdm_CO,#DED479 +SWBmk,#92BEC2 +SWBmks,#79AEB6 +SWBun,#8DC4D2 +SWBuns,#80CCD4 +SWBvk,#A4BED3 +SWBvks,#ADD5DE +WJPxm_OR,#987610 +BGmw_OR,#C6330A +BGdw_OR,#F5453F +ESSFwvw,#D76CE5 +ESSFmkw,#B64FCF +ESSFmcw,#987DB7 diff --git a/inst/shiny/scripts/utils.R b/inst/shiny/scripts/utils.R new file mode 100644 index 00000000..bd141eb0 --- /dev/null +++ b/inst/shiny/scripts/utils.R @@ -0,0 +1,111 @@ +bcgov_theme <- function(action = c("install","remove")) { + action <- match.arg(action) + + # Injecting bcgov theme directly into bslib library + target <- find.package("bslib") + if (file.access(target,2) < 0) { + stop("This must be run with write access to the bslib package") + } + + src <- system.file("", package = "climr") + f <- dir(src, recursive = TRUE) |> grep("^fonts|^lib", x = _, value = TRUE) + + if (action == "install") { + lapply(file.path(target, unique(dirname(f))), dir.create, showWarnings = FALSE, recursive = TRUE) + file.copy(file.path(src, f), file.path(target, f)) + } + + if (action == "remove") { + unlink(file.path(target, f)) + } + + return(invisible()) + +} + +if (!"bcgov" %in% bslib::bootswatch_themes()) { + bcgov_theme("install") +} + +latlontopoly <- function(latlon) { + matrix(latlon, ncol = 2, byrow = TRUE) |> + as.data.frame() |> + sf::st_as_sf(coords = c(2,1), crs = sf::st_crs(4326)) |> + sf::st_combine() |> + sf::st_cast("POLYGON") +} + +boundstopoly <- function(b) { + if (abs(b$west) > 180 | abs(b$east) > 180 | abs(b$north) > 90 | abs(b$south) > 90) return(NULL) + res <- sf::st_polygon(list(rbind(c(b$west, b$north),c(b$east, b$north),c(b$east, b$south),c(b$west, b$south),c(b$west, b$north)))) |> + sf::st_sfc() + res <- sf::st_set_crs(res, sf::st_crs(4326)) + res +} + +##javascript source +wna_tileserver <- "https://tileserver.thebeczone.ca/data/WNA_MAP/{z}/{x}/{y}.pbf" +wna_tilelayer <- "WNA_MAP" + +plugins <- { + list( + vgplugin = + htmltools::htmlDependency( + name = "leaflet.vectorgrid", + version = "1.3.0", + src = "www/htmlwidgets", + script = "lfx-vgrid-prod.js" + ) + ) +} + +registerPlugin <- function(map, plugin) { + map$dependencies <- c(map$dependencies, list(plugin)) + map +} + +add_wna <- function(map) { + subzones_colours_ref <- data.table::fread("data/WNAv12_3_SubzoneCols.csv", key = "classification") + map <- registerPlugin(map, plugins$vgplugin) + map <- htmlwidgets::onRender(map, paste0(' + function(el, x, data) { + ', paste0("var subzoneColors = {", paste0("'", subzones_colours_ref$classification, "':'", subzones_colours_ref$colour,"'", collapse = ","), "}"), ' + + var vectorTileOptions=function(layerName, layerId, activ, + lfPane, colorMap, prop, id) { + return { + vectorTileLayerName: layerName, + interactive: activ, // makes it able to trigger js events like click + vectorTileLayerStyles: { + [layerId]: function(properties, zoom) { + return { + weight: 0, + fillColor: colorMap[properties[prop]], + fill: true, + fillOpacity: 0.3 + } + } + }, + pane : lfPane, + getFeatureId: function(f) { + return f.properties[id]; + } + } + + }; + + var subzLayer = L.vectorGrid.protobuf( + "', wna_tileserver, '", + vectorTileOptions("WNA BEC", "', wna_tilelayer, '", true, + "tilePane", subzoneColors, "MAP_LABEL", "MAP_LABEL") + ) + this.layerManager.addLayer(subzLayer, "tile", "WNA BEC", "WNA BEC"); + + subzLayer.bindTooltip(function(e) { + return e.properties.MAP_LABEL + }, {sticky: true, textsize: "10px", opacity: 1}); + subzLayer.bringToFront(); + }' + )) + map +} \ No newline at end of file diff --git a/inst/shiny/www/htmlwidgets/lfx-vgrid-prod.js b/inst/shiny/www/htmlwidgets/lfx-vgrid-prod.js new file mode 100644 index 00000000..1640f3dc --- /dev/null +++ b/inst/shiny/www/htmlwidgets/lfx-vgrid-prod.js @@ -0,0 +1,2 @@ +"use strict";function __$strToBlobUri(t,e,r){try{return window.URL.createObjectURL(new Blob([Uint8Array.from(t.split("").map(function(t){return t.charCodeAt(0)}))],{type:e}))}catch(i){return"data:"+e+(r?";base64,":",")+t}}function Pbf(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}function readVarintRemainder(t,e,r){var i,n,o=r.buf;if(n=o[r.pos++],i=(112&n)>>4,n<128)return toNum(t,i,e);if(n=o[r.pos++],i|=(127&n)<<3,n<128)return toNum(t,i,e);if(n=o[r.pos++],i|=(127&n)<<10,n<128)return toNum(t,i,e);if(n=o[r.pos++],i|=(127&n)<<17,n<128)return toNum(t,i,e);if(n=o[r.pos++],i|=(127&n)<<24,n<128)return toNum(t,i,e);if(n=o[r.pos++],i|=(1&n)<<31,n<128)return toNum(t,i,e);throw new Error("Expected varint not more than 10 bytes")}function readPackedEnd(t){return t.type===Pbf.Bytes?t.readVarint()+t.pos:t.pos+1}function toNum(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function writeBigVarint(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),4294967295^r?r=r+1|0:(r=0,i=i+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),writeBigVarintLow(r,i,e),writeBigVarintHigh(i,e)}function writeBigVarintLow(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}function writeBigVarintHigh(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}function makeRoomForExtraLength(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(7*Math.LN2));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function writePackedVarint(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function readInt32(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function readUtf8(t,e,r){for(var i="",n=e;n239?4:o>223?3:o>191?2:1;if(n+a>r)break;var u,h,l;1===a?o<128&&(s=o):2===a?128==(192&(u=t[n+1]))&&(s=(31&o)<<6|63&u)<=127&&(s=null):3===a?(u=t[n+1],h=t[n+2],128==(192&u)&&128==(192&h)&&((s=(15&o)<<12|(63&u)<<6|63&h)<=2047||s>=55296&&s<=57343)&&(s=null)):4===a&&(u=t[n+1],h=t[n+2],l=t[n+3],128==(192&u)&&128==(192&h)&&128==(192&l)&&((s=(15&o)<<18|(63&u)<<12|(63&h)<<6|63&l)<=65535||s>=1114112)&&(s=null)),null===s?(s=65533,a=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|1023&s),i+=String.fromCharCode(s),n+=a}return i}function writeUtf8(t,e,r){for(var i,n,o=0;o55295&&i<57344){if(!n){i>56319||o+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):n=i;continue}if(i<56320){t[r++]=239,t[r++]=191,t[r++]=189,n=i;continue}i=n-55296<<10|i-56320|65536,n=null}else n&&(t[r++]=239,t[r++]=191,t[r++]=189,n=null);i<128?t[r++]=i:(i<2048?t[r++]=i>>6|192:(i<65536?t[r++]=i>>12|224:(t[r++]=i>>18|240,t[r++]=i>>12&63|128),t[r++]=i>>6&63|128),t[r++]=63&i|128)}return r}function Point$1(t,e){this.x=t,this.y=e}function VectorTileFeature$2(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(readFeature,this,e)}function readFeature(t,e,r){1==t?e.id=r.readVarint():2==t?readTag(r,e):3==t?e.type=r.readVarint():4==t&&(e._geometry=r.pos)}function readTag(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}function VectorTile$1(t,e){this.layers=t.readFields(readTile,{},e)}function readTile(t,e,r){if(3===t){var i=new VectorTileLayer$1(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}!function(t){function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function i(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return v.iterable&&(e[Symbol.iterator]=function(){return e}),e}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function o(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function s(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function a(t){var e=new FileReader,r=s(e);return e.readAsArrayBuffer(t),r}function u(t){var e=new FileReader,r=s(e);return e.readAsText(t),r}function h(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i-1?e:t}function p(t,e){e=e||{};var r=e.body;if(t instanceof p){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new n(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function d(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}}),e}function y(t){var e=new n;return t.split(/\r?\n/).forEach(function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();e.append(i,n)}}),e}function m(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var v={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(v.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],b=function(t){return t&&DataView.prototype.isPrototypeOf(t)},w=ArrayBuffer.isView||function(t){return t&&g.indexOf(Object.prototype.toString.call(t))>-1};n.prototype.append=function(t,i){t=e(t),i=r(i);var n=this.map[t];this.map[t]=n?n+","+i:i},n.prototype.delete=function(t){delete this.map[e(t)]},n.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,i){this.map[e(t)]=r(i)},n.prototype.forEach=function(t,e){var r=this;for(var i in this.map)r.map.hasOwnProperty(i)&&t.call(e,r.map[i],i,r)},n.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),i(t)},n.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),i(t)},n.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),i(t)},v.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},c.call(p.prototype),c.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var x=[301,302,303,307,308];m.redirect=function(t,e){if(-1===x.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=p,t.Response=m,t.fetch=function(t,e){return new Promise(function(r,i){var n=new p(t,e),o=new XMLHttpRequest;o.onload=function(){var t={status:o.status,statusText:o.statusText,headers:y(o.getAllResponseHeaders()||"")};t.url="responseURL"in o?o.responseURL:t.headers.get("X-Request-URL");var e="response"in o?o.response:o.responseText;r(new m(e,t))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.open(n.method,n.url,!0),"include"===n.credentials&&(o.withCredentials=!0),"responseType"in o&&v.blob&&(o.responseType="blob"),n.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),o.send(void 0===n._bodyInit?null:n._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:void 0);var read=function(t,e,r,i,n){var o,s,a=8*n-i-1,u=(1<>1,l=-7,c=r?n-1:0,f=r?-1:1,p=t[e+c];for(c+=f,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=256*s+t[e+c],c+=f,l-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,i),o-=h}return(p?-1:1)*s*Math.pow(2,o-i)},write=function(t,e,r,i,n,o){var s,a,u,h=8*o-n-1,l=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,d=i?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+c>=1?f/u:f*Math.pow(2,1-c),e*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*u-1)*Math.pow(2,n),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[r+p]=255&a,p+=d,a/=256,n-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,h-=8);t[r+p-d]|=128*y},index$1={read:read,write:write},index=Pbf,ieee754=index$1;Pbf.Varint=0,Pbf.Fixed64=1,Pbf.Bytes=2,Pbf.Fixed32=5;var SHIFT_LEFT_32=4294967296,SHIFT_RIGHT_32=1/SHIFT_LEFT_32;Pbf.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){var i=this;for(r=r||this.length;this.pos>3,s=i.pos;i.type=7&n,t(o,e,i),i.pos===s&&i.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=readUInt32(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=readInt32(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=readUInt32(this.buf,this.pos)+readUInt32(this.buf,this.pos+4)*SHIFT_LEFT_32;return this.pos+=8,t},readSFixed64:function(){var t=readUInt32(this.buf,this.pos)+readInt32(this.buf,this.pos+4)*SHIFT_LEFT_32;return this.pos+=8,t},readFloat:function(){var t=ieee754.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ieee754.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,i=this.buf;return r=i[this.pos++],e=127&r,r<128?e:(r=i[this.pos++],e|=(127&r)<<7,r<128?e:(r=i[this.pos++],e|=(127&r)<<14,r<128?e:(r=i[this.pos++],e|=(127&r)<<21,r<128?e:(r=i[this.pos],e|=(15&r)<<28,readVarintRemainder(e,t,this)))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=readUtf8(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=this,i=readPackedEnd(this);for(t=t||[];this.pos127;);else if(e===Pbf.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Pbf.Fixed32)this.pos+=4;else{if(e!==Pbf.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0)return void writeBigVarint(t,this);this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=writeUtf8(this.buf,t,this.pos);var r=this.pos-e;r>=128&&makeRoomForExtraLength(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),ieee754.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ieee754.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=this,r=t.length;this.writeVarint(r),this.realloc(r);for(var i=0;i=128&&makeRoomForExtraLength(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Pbf.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,writePackedVarint,e)},writePackedSVarint:function(t,e){this.writeMessage(t,writePackedSVarint,e)},writePackedBoolean:function(t,e){this.writeMessage(t,writePackedBoolean,e)},writePackedFloat:function(t,e){this.writeMessage(t,writePackedFloat,e)},writePackedDouble:function(t,e){this.writeMessage(t,writePackedDouble,e)},writePackedFixed32:function(t,e){this.writeMessage(t,writePackedFixed32,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,writePackedSFixed32,e)},writePackedFixed64:function(t,e){this.writeMessage(t,writePackedFixed64,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,writePackedSFixed64,e)},writeBytesField:function(t,e){this.writeTag(t,Pbf.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Pbf.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Pbf.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Pbf.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Pbf.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Pbf.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Pbf.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Pbf.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Pbf.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Pbf.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var index$5=Point$1;Point$1.prototype={clone:function(){return new Point$1(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Point$1.convert=function(t){return t instanceof Point$1?t:Array.isArray(t)?new Point$1(t[0],t[1]):t};var Point=index$5,vectortilefeature=VectorTileFeature$2;VectorTileFeature$2.types=["Unknown","Point","LineString","Polygon"],VectorTileFeature$2.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,r=t.readVarint()+t.pos,i=1,n=0,o=0,s=0,a=[];t.pos>3}if(n--,1===i||2===i)o+=t.readSVarint(),s+=t.readSVarint(),1===i&&(e&&a.push(e),e=[]),e.push(new Point(o,s));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&a.push(e),a},VectorTileFeature$2.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,u=1/0,h=-1/0;t.pos>3}if(i--,1===r||2===r)n+=t.readSVarint(),o+=t.readSVarint(),na&&(a=n),oh&&(h=o);else if(7!==r)throw new Error("unknown command "+r)}return[s,u,a,h]},VectorTileFeature$2.prototype.toGeoJSON=function(t,e,r){function i(t){for(var e=0;e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new VectorTileFeature$1(this._pbf,e,this.extent,this._keys,this._values)};var VectorTileLayer$1=vectortilelayer,vectortile=VectorTile$1,VectorTile=vectortile;L.SVG.Tile=L.SVG.extend({initialize:function(t,e,r){L.SVG.prototype.initialize.call(this,r),this._tileCoord=t,this._size=e,this._initContainer(),this._container.setAttribute("width",this._size.x),this._container.setAttribute("height",this._size.y),this._container.setAttribute("viewBox",[0,0,this._size.x,this._size.y].join(" ")),this._layers={}},getCoord:function(){return this._tileCoord},getContainer:function(){return this._container},onAdd:L.Util.falseFn,addTo:function(t){if(this._map=t,this.options.interactive)for(var e in this._layers){var r=this._layers[e];r._path.style.pointerEvents="auto",this._map._targets[L.stamp(r._path)]=r}},removeFrom:function(t){if(this.options.interactive)for(var e in this._layers){var r=this._layers[e];delete this._map._targets[L.stamp(r._path)]}delete this._map},_initContainer:function(){L.SVG.prototype._initContainer.call(this);L.SVG.create("rect")},_addPath:function(t){this._rootGroup.appendChild(t._path),this._layers[L.stamp(t)]=t},_updateIcon:function(t){var e=t._path=L.SVG.create("image"),r=t.options.icon,i=r.options,n=L.point(i.iconSize),o=i.iconAnchor||n&&n.divideBy(2,!0),s=t._point.subtract(o);e.setAttribute("x",s.x),e.setAttribute("y",s.y),e.setAttribute("width",n.x+"px"),e.setAttribute("height",n.y+"px"),e.setAttribute("href",i.iconUrl)}}),L.svg.tile=function(t,e,r){return new L.SVG.Tile(t,e,r)};var Symbolizer=L.Class.extend({render:function(t,e){this._renderer=t,this.options=e,t._initPath(this),t._updateStyle(this)},updateStyle:function(t,e){this.options=e,t._updateStyle(this)},_getPixelBounds:function(){for(var t=this._parts,e=L.bounds([]),r=0;rn&&(i=r,n=o);n>a?(e[i][2]=n,c.push(l),c.push(i),l=i):(u=c.pop(),l=c.pop())}}function getSqSegDist(e,t,r){var n=t[0],o=t[1],i=r[0],a=r[1],s=e[0],l=e[1],u=i-n,c=a-o;if(0!==u||0!==c){var f=((s-n)*u+(l-o)*c)/(u*u+c*c);f>1?(n=i,o=a):f>0&&(n+=u*f,o+=c*f)}return u=s-n,c=l-o,u*u+c*c}function convert$1(e,t){var r=[];if("FeatureCollection"===e.type)for(var n=0;n1?1:n,[r,n,0]}function calcSize(e){for(var t,r,n=0,o=0,i=0;i=r&&s<=n)return e;if(a>n||s=r&&f<=n)l.push(p);else if(!(c>n||f=t&&s<=r&&o.push(a)}return o}function clipGeometry(e,t,r,n,o,i){for(var a=[],s=0;sr?(x.push(o(l,h,t),o(l,h,r)),i||(x=newSlice(a,x,g,d,v))):p>=t&&x.push(o(l,h,t)):f>r?pr&&(x.push(o(l,h,r)),i||(x=newSlice(a,x,g,d,v))));l=m[y-1],f=l[n],f>=t&&f<=r&&x.push(l),c=x[x.length-1],i&&c&&(x[0][0]!==c[0]||x[0][1]!==c[1])&&x.push(x[0]),newSlice(a,x,g,d,v)}return a}function newSlice(e,t,r,n,o){return t.length&&(t.area=r,t.dist=n,void 0!==o&&(t.outer=o),e.push(t)),[]}function wrap$1(e,t,r){var n=e,o=clip$2(e,1,-1-t,t,0,r,-1,2),i=clip$2(e,1,1-t,2+t,0,r,-1,2);return(o||i)&&(n=clip$2(e,1,-t,1+t,0,r,-1,2),o&&(n=shiftFeatureCoords(o,1).concat(n)),i&&(n=n.concat(shiftFeatureCoords(i,-1)))),n}function shiftFeatureCoords(e,t){for(var r=[],n=0;na.max[0]&&(a.max[0]=u[0]),u[1]>a.max[1]&&(a.max[1]=u[1])}return a}function addFeature(e,t,r,n){var o,i,a,s,l=t.geometry,u=t.type,c=[],f=r*r;if(1===u)for(o=0;of)&&(p.push(s),e.numSimplified++),e.numPoints++;3===u&&rewind(p,a.outer),c.push(p)}else e.numPoints+=a.length;c.length&&e.features.push({geometry:c,type:u,tags:t.tags||null})}function rewind(e,t){signedArea(e)<0===t&&e.reverse()}function signedArea(e){for(var t,r,n=0,o=0,i=e.length,a=i-1;o1)return!1;var i=o.geometry[0].length;if(5!==i)return!1;for(var a=0;a1&&console.time("creation"),m=s.tiles[h]=createTile(e,p,r,n,g,t===u.maxZoom),s.tileCoords.push({z:t,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,n,m.numFeatures,m.numPoints,m.numSimplified),console.timeEnd("creation"));var d="z"+t;s.stats[d]=(s.stats[d]||0)+1,s.total++}if(m.source=e,o){if(t===u.maxZoom||t===o)continue;var v=1<1&&console.time("clipping");var y,x,b,M,P,S,w=.5*u.buffer/u.extent,$=.5-w,C=.5+w,F=1+w;y=x=b=M=null,P=clip(e,p,r-w,r+C,0,intersectX,m.min[0],m.max[0]),S=clip(e,p,r+$,r+F,0,intersectX,m.min[0],m.max[0]),P&&(y=clip(P,p,n-w,n+C,1,intersectY,m.min[1],m.max[1]),x=clip(P,p,n+$,n+F,1,intersectY,m.min[1],m.max[1])),S&&(b=clip(S,p,n-w,n+C,1,intersectY,m.min[1],m.max[1]),M=clip(S,p,n+$,n+F,1,intersectY,m.min[1],m.max[1])),c>1&&console.timeEnd("clipping"),y&&l.push(y,t+1,2*r,2*n),x&&l.push(x,t+1,2*r,2*n+1),b&&l.push(b,t+1,2*r+1,2*n),M&&l.push(M,t+1,2*r+1,2*n+1)}else o&&(f=t)}return f},GeoJSONVT.prototype.getTile=function(e,t,r){var n=this,o=this.options,i=o.extent,a=o.debug,s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var u,c=e,f=t,p=r;!u&&c>0;)c--,f=Math.floor(f/2),p=Math.floor(p/2),u=n.tiles[toID(c,f,p)];if(!u||!u.source)return null;if(a>1&&console.log("found parent tile z%d-%d-%d",c,f,p),isClippedSquare(u,i,o.buffer))return transform.tile(u,i);a>1&&console.time("drilling down");var h=this.splitTile(u.source,c,f,p,e,t,r);if(a>1&&console.timeEnd("drilling down"),null!==h){var m=1<c&&(c=s[0]),s[1]f&&(f=s[1])}function r(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(r);break;case"Point":t(e.coordinates);break;case"MultiPoint":e.coordinates.forEach(t)}}var n=e.bbox;if(!n){var o,i,a=transform$3(e),s=new Array(2),l=1/0,u=l,c=-l,f=-l;e.arcs.forEach(function(e){for(var t=-1,r=e.length;++tc&&(c=s[0]),s[1]f&&(f=s[1])});for(i in e.objects)r(e.objects[i]);n=e.bbox=[l,u,c,f]}return n},reverse=function(e,t){for(var r,n=e.length,o=n-t;o<--n;)r=e[o],e[o++]=e[n],e[n]=r},feature=function(e,t){return"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return feature$1(e,t)})}:feature$1(e,t)},stitch=function(e,t){function r(t){var r,n=e.arcs[t<0?~t:t],o=n[0];return e.transform?(r=[0,0],n.forEach(function(e){r[0]+=e[0],r[1]+=e[1]})):r=n[n.length-1],t<0?[r,o]:[o,r]}function n(e,t){for(var r in e){var n=e[r];delete t[n.start],delete n.start,delete n.end,n.forEach(function(e){o[e<0?~e:e]=1}),s.push(n)}}var o={},i={},a={},s=[],l=-1;return t.forEach(function(r,n){var o,i=e.arcs[r<0?~r:r];i.length<3&&!i[1][0]&&!i[1][1]&&(o=t[++l],t[l]=r,t[n]=o)}),t.forEach(function(e){var t,n,o=r(e),s=o[0],l=o[1];if(t=a[s])if(delete a[t.end],t.push(e),t.end=l,n=i[l]){delete i[n.start];var u=n===t?t:t.concat(n);i[u.start=t.start]=a[u.end=n.end]=u}else i[t.start]=a[t.end]=t;else if(t=i[l])if(delete i[t.start],t.unshift(e),t.start=s,n=a[s]){delete a[n.end];var c=n===t?t:n.concat(t);i[c.start=n.start]=a[c.end=t.end]=c}else i[t.start]=a[t.end]=t;else t=[e],i[t.start=s]=a[t.end=l]=t}),n(a,i),n(i,a),t.forEach(function(e){o[e<0?~e:e]||s.push([e])}),s},bisect=function(e,t){for(var r=0,n=e.length;r>>1;e[o]Untitled-1 \ No newline at end of file diff --git a/inst/shiny/www/images/bcid-apple-touch-icon.png b/inst/shiny/www/images/bcid-apple-touch-icon.png new file mode 100644 index 00000000..8e5da752 Binary files /dev/null and b/inst/shiny/www/images/bcid-apple-touch-icon.png differ diff --git a/inst/shiny/www/images/bcid-favicon-16x16.png b/inst/shiny/www/images/bcid-favicon-16x16.png new file mode 100644 index 00000000..fec164d7 Binary files /dev/null and b/inst/shiny/www/images/bcid-favicon-16x16.png differ diff --git a/inst/shiny/www/images/bcid-favicon-32x32.png b/inst/shiny/www/images/bcid-favicon-32x32.png new file mode 100644 index 00000000..aa1c69ac Binary files /dev/null and b/inst/shiny/www/images/bcid-favicon-32x32.png differ diff --git a/inst/shiny/www/images/bcid-logo-en.svg b/inst/shiny/www/images/bcid-logo-en.svg new file mode 100644 index 00000000..345ac4a3 --- /dev/null +++ b/inst/shiny/www/images/bcid-logo-en.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/images/bcid-logo-fr.svg b/inst/shiny/www/images/bcid-logo-fr.svg new file mode 100644 index 00000000..ff520715 --- /dev/null +++ b/inst/shiny/www/images/bcid-logo-fr.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/images/bcid-logo-rev-en.svg b/inst/shiny/www/images/bcid-logo-rev-en.svg new file mode 100644 index 00000000..9b08a31c --- /dev/null +++ b/inst/shiny/www/images/bcid-logo-rev-en.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/images/bcid-logo-rev-fr.svg b/inst/shiny/www/images/bcid-logo-rev-fr.svg new file mode 100644 index 00000000..f80e9270 --- /dev/null +++ b/inst/shiny/www/images/bcid-logo-rev-fr.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/images/bcid-mstile-144x144.png b/inst/shiny/www/images/bcid-mstile-144x144.png new file mode 100644 index 00000000..5dfe753a Binary files /dev/null and b/inst/shiny/www/images/bcid-mstile-144x144.png differ diff --git a/inst/shiny/www/images/bcid-mstile-150x150.png b/inst/shiny/www/images/bcid-mstile-150x150.png new file mode 100644 index 00000000..9d208fba Binary files /dev/null and b/inst/shiny/www/images/bcid-mstile-150x150.png differ diff --git a/inst/shiny/www/images/bcid-mstile-310x150.png b/inst/shiny/www/images/bcid-mstile-310x150.png new file mode 100644 index 00000000..05e69368 Binary files /dev/null and b/inst/shiny/www/images/bcid-mstile-310x150.png differ diff --git a/inst/shiny/www/images/bcid-mstile-310x310.png b/inst/shiny/www/images/bcid-mstile-310x310.png new file mode 100644 index 00000000..e5ea3b85 Binary files /dev/null and b/inst/shiny/www/images/bcid-mstile-310x310.png differ diff --git a/inst/shiny/www/images/bcid-mstile-70x70.png b/inst/shiny/www/images/bcid-mstile-70x70.png new file mode 100644 index 00000000..34ec0953 Binary files /dev/null and b/inst/shiny/www/images/bcid-mstile-70x70.png differ diff --git a/inst/shiny/www/images/bcid-symbol-rev.svg b/inst/shiny/www/images/bcid-symbol-rev.svg new file mode 100644 index 00000000..2728284f --- /dev/null +++ b/inst/shiny/www/images/bcid-symbol-rev.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/images/bcid-symbol.svg b/inst/shiny/www/images/bcid-symbol.svg new file mode 100644 index 00000000..3091c45d --- /dev/null +++ b/inst/shiny/www/images/bcid-symbol.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny/www/script.js b/inst/shiny/www/script.js new file mode 100644 index 00000000..8ccd2481 --- /dev/null +++ b/inst/shiny/www/script.js @@ -0,0 +1 @@ +Shiny.addCustomMessageHandler("jsCode",function(message){eval(message.code);}); \ No newline at end of file diff --git a/inst/shiny/www/style.css b/inst/shiny/www/style.css new file mode 100644 index 00000000..28a6302b --- /dev/null +++ b/inst/shiny/www/style.css @@ -0,0 +1,9 @@ +div.outer { + position: fixed; + top: 56px; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + padding: 0; +} \ No newline at end of file