Commit 3ddad21b authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Préparation so.ii 1.0.26.0

No related merge requests found
Showing with 70 additions and 20 deletions
+70 -20
so.ii Version: 1.0.25.0 so.ii Version: 1.0.26.0
0 errors ✔ | 0 warnings ✔ | 0 notes ✔ 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
**Note de version** **Note de version**
* modification de map_so_ii * modification de map_so_ii
* nouvelle fonction interne adjust_terra_scale * nouvelle fonction interne calculate_terra_xy
**Détails** **Détails**
* La librairie terra a changé sa façon de faire la barre d'échelle avec * La librairie terra a changé sa façon de faire la barre d'échelle avec
sbar à partir de la version 1.7, de façon incompatible avec l'usage interne. sbar à partir de la version 1.7, de façon incompatible avec l'usage interne.
Une nouvelle fonction non exportée adjust_terra_scale est créé pour ne plus Une nouvelle fonction non exportée calculate_terra_xy est créée pour ne plus
dépendre des fonctionnalités de terra::sbar qui posent problème, lorsque dépendre des fonctionnalités de terra::sbar qui posent problème, et ne
les cartes sont en "lonlat". permettaient plus de faire un positionnement par mots clés.
# git tag -a v1.0.25.0 -F dev/tag-message # git tag -a v1.0.25.0 -F dev/tag-message
# git push --tags # git push --tags
......
Package: so.ii Package: so.ii
Title: Utilities very useful to share within so_ii team Title: Utilities very useful to share within so_ii team
Version: 1.0.25.0 Version: 1.0.26.0
Authors@R: Authors@R:
c( c(
person(given = "Frédéric", person(given = "Frédéric",
......
...@@ -12,7 +12,7 @@ adjust_terra_scale = function(d = NULL, lonlat = TRUE) { ...@@ -12,7 +12,7 @@ adjust_terra_scale = function(d = NULL, lonlat = TRUE) {
cbind(lon2, lat2)/toRad cbind(lon2, lat2)/toRad
} }
graph_box = graphics::par()$usr graph_box = graphics::par()[["usr"]]
if (lonlat) { if (lonlat) {
lat = mean(graph_box[3:4]) lat = mean(graph_box[3:4])
if (is.null(d)) { if (is.null(d)) {
...@@ -34,3 +34,53 @@ adjust_terra_scale = function(d = NULL, lonlat = TRUE) { ...@@ -34,3 +34,53 @@ adjust_terra_scale = function(d = NULL, lonlat = TRUE) {
} }
return(c(dd, d)) return(c(dd, d))
} }
calculate_terra_xy = function (xy, dx = 0, dy = 0, defpos = "bottomleft")
{
graph_box = graphics::par()[["usr"]]
if (is.null(xy)) {
xy = defpos
}
if (!is.character(xy)) {
return(cbind(xy[1], xy[2]))
}
xy = tolower(xy)
parrange = c(graph_box[2] - graph_box[1], graph_box[4] - graph_box[3])
pad = c(5, 5)/100
if (xy == "bottom") {
xy = c(graph_box[1] + 0.5 * parrange[1] - 0.5 * dx, graph_box[3] +
(pad[2] * parrange[2])) + c(0, dy)
}
else if (xy == "bottomleft") {
xy = c(graph_box[1] + (pad[1] * parrange[1]), graph_box[3] +
(pad[2] * parrange[2])) + c(0, dy)
}
else if (xy == "bottomright") {
xy = c(graph_box[2] - (pad[1] * parrange[1]), graph_box[3] +
(pad[2] * parrange[2])) - c(dx, -dy)
}
else if (xy == "topright") {
xy = c(graph_box[2] - (pad[1] * parrange[1]), graph_box[4] -
(pad[2] * parrange[2])) - c(dx, dy)
}
else if (xy == "top") {
xy = c(graph_box[1] + 0.5 * parrange[1] - 0.5 * dx, graph_box[4] -
(pad[2] * parrange[2])) - c(0, dy)
}
else if (xy == "topleft") {
xy = c(graph_box[1] + (pad[1] * parrange[1]), graph_box[4] -
(pad[2] * parrange[2])) - c(0, dy)
}
else if (xy == "left") {
xy = c(graph_box[1] + (pad[1] * parrange[1]), graph_box[3] +
0.5 * parrange[2] - 0.5 * dy)
}
else if (xy == "right") {
xy = c(graph_box[2] - (pad[1] * parrange[1]) - dx, graph_box[3] +
0.5 * parrange[2] - 0.5 * dy)
}
else {
stop("xy must be a coordinate pair (two numbers) or one of \"bottomleft\", \"bottom\", \"bottomright\", topleft\", \"top\", \"topright\"")
}
xy
}
\ No newline at end of file
File moved
File moved
File moved
...@@ -297,7 +297,7 @@ map_so_ii = function( ...@@ -297,7 +297,7 @@ map_so_ii = function(
# area = sf::st_area(sf::st_as_sfc(sf::st_bbox(scope))) # area = sf::st_area(sf::st_as_sfc(sf::st_bbox(scope)))
# d = max(pretty(units::set_units(sqrt(area) / 5, "km"))) # d = max(pretty(units::set_units(sqrt(area) / 5, "km")))
d = adjust_terra_scale() d = adjust_terra_scale()
xy = "bottomleft" xy = calculate_terra_xy("bottomleft")
# Magical adjustment when scope vary to have text readable # Magical adjustment when scope vary to have text readable
# 0.4788987 should correspond to longitude range for so.ii scope # 0.4788987 should correspond to longitude range for so.ii scope
adj = diff(graphics::par()$usr[3:4]) adj = diff(graphics::par()$usr[3:4])
......
File moved
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{clc_color} \name{clc_color}
\alias{clc_color} \alias{clc_color}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/current_version.r % Please edit documentation in R/current_version.R
\encoding{UTF-8} \encoding{UTF-8}
\name{current_version} \name{current_version}
\alias{current_version} \alias{current_version}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_catchment} \name{so_ii_catchment}
\alias{so_ii_catchment} \alias{so_ii_catchment}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_catnat} \name{so_ii_catnat}
\alias{so_ii_catnat} \alias{so_ii_catnat}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_clc} \name{so_ii_clc}
\alias{so_ii_clc} \alias{so_ii_clc}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_clc_crop} \name{so_ii_clc_crop}
\alias{so_ii_clc_crop} \alias{so_ii_clc_crop}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_collectivity} \name{so_ii_collectivity}
\alias{so_ii_collectivity} \alias{so_ii_collectivity}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_hydro} \name{so_ii_hydro}
\alias{so_ii_hydro} \alias{so_ii_hydro}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_inset} \name{so_ii_inset}
\alias{so_ii_inset} \alias{so_ii_inset}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_limit} \name{so_ii_limit}
\alias{so_ii_limit} \alias{so_ii_limit}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_montpellier} \name{so_ii_montpellier}
\alias{so_ii_montpellier} \alias{so_ii_montpellier}
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r % Please edit documentation in R/data.R
\docType{data} \docType{data}
\name{so_ii_onrn} \name{so_ii_onrn}
\alias{so_ii_onrn} \alias{so_ii_onrn}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment