Skip to content

Commit

Permalink
0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
choonghyunryu committed Feb 5, 2023
1 parent f5bf374 commit 5da6953
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 15 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: bitSpatial
Type: Package
Title: Tools for Spatial Analysis in Korean Regions
Version: 0.2.1.9000
Date: 2023-02-02
Version: 0.2.2.9000
Date: 2023-02-04
Authors@R: c(
person("Choonghyun", "Ryu",, "[email protected]", role = c("aut", "cre"))
)
Expand All @@ -21,6 +21,8 @@ Imports:
here,
purrr,
rlang,
showtext,
sysfonts,
tibble,
tmaptools
LazyData: true
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import(ggplot2)
import(sf)
importFrom(classInt,classIntervals)
importFrom(purrr,map_df)
importFrom(rlang,enquo)
importFrom(rlang,sym)
importFrom(showtext,showtext_auto)
importFrom(sysfonts,font_add)
importFrom(sysfonts,font_add_google)
importFrom(tibble,tibble)
importFrom(tmaptools,get_asp_ratio)
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# bitSpatial 0.2.2

## NEW FEATURES

* 한글폰트 추가 및 주제도에 적용. (#17).
- 나눔스퀘어 폰트
- thematic_map()에 적용

## BUG FIXS

* 주제도에서 값의 범위를 커버 못하는 그라데이션 오류 수정. (#19).
- thematic_map()



# bitSpatial 0.2.1

## NEW FEATURES
Expand Down
25 changes: 12 additions & 13 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ theme_custom_map <- function(base_size = 11,
#' @param legend_pos character. 주제도의 범례를 출력할 위치로 stat 인수를 지정할
#' 경우에만 효력이 있음. 이 인수를 지정하지 않으면 범례를 출력하지 않음.
#' "none", "left", "right", "bottom", "top"에서 선택.
#' @param base_family character. 주제도에 출력할 문자 폰트 패밀리.
#' 기본값은 나눔스퀘어 폰트인 "NanumSquare"이며, 온라인 환경에서는 본고딕인
#' "Noto Sans Korean"을 지정할 수 있음.
#' @details
#' 통계의 종류는 shpinfo 데이터 프레임에 32개가 정의되어 있음.
#' 이중 stat_code 변수를 stat 인수에 사용해야 함.
Expand Down Expand Up @@ -120,7 +123,7 @@ theme_custom_map <- function(base_size = 11,
#' @export
#' @import dplyr
#' @import ggplot2
#' @importFrom rlang sym
#' @importFrom rlang sym enquo
#' @importFrom classInt classIntervals
thematic_map <- function(
zoom = c("mega", "cty", "admi")[1], subset = NULL, stat = NULL,
Expand All @@ -134,15 +137,8 @@ thematic_map <- function(
map_df <- eval(get(zoom))

if (!missing(subset)) {
x <- map_df

e <- substitute(!!subset)
r <- eval(e, x)

if (!is.logical(r))
stop("'subset' must be logical")

map_df <- map_df[r & !is.na(r), ]
map_df <- map_df %>%
filter(!!rlang::enquo(subset))
}

if (is.null(stat) & length(stat %in% names(map_df)) == 0) {
Expand All @@ -155,10 +151,12 @@ thematic_map <- function(
pull()

suppressWarnings({
brks <- classInt::classIntervals(stats, n = col_cnt, style = "pretty")$brks
stats2 <- c(min(stats) - .00001, stats)

brks <- classInt::classIntervals(stats2, n = col_cnt, style = "pretty")$brks

if (length(brks) > col_cnt) {
brks <- classInt::classIntervals(stats, n = col_cnt, style = "quantile")
brks <- classInt::classIntervals(stats2, n = col_cnt, style = "quantile")
brks <- unique(round(brks$brks))
}
})
Expand Down Expand Up @@ -210,7 +208,8 @@ thematic_map <- function(
p <- p +
ggrepel ::geom_label_repel(
aes(label = label_string, geometry = geometry),
stat = "sf_coordinates")
stat = "sf_coordinates",
family = base_family)
}
}

Expand Down
28 changes: 28 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' @importFrom sysfonts font_add_google font_add
#' @importFrom showtext showtext_auto
.onAttach <- function(libname, pkgname) {
tryCatch(
expr = {
# Online Korean font
sysfonts::font_add_google(name = "Noto Sans KR",
family = "Noto Sans Korean")

options(is_offline = FALSE)
},
error = function(e) {
options(is_offline = TRUE)

packageStartupMessage("Because it is an offline environment, only offline fonts are imported.")
},
finally = {
# Offline Korean font
font_path <- system.file("fonts", "NanumSquare", package = "bitSpatial")
sysfonts::font_add(
family = "NanumSquare",
regular = paste(font_path, "NanumSquareOTF_acR.otf", sep = "/")
)
}
)

showtext::showtext_auto()
}
Binary file added inst/fonts/NanumSquare/NanumSquareOTF_acR.otf
Binary file not shown.
4 changes: 4 additions & 0 deletions man/thematic_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5da6953

Please sign in to comment.