Skip to content

Commit

Permalink
📝 Add documentation for ver 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NONONOexe committed Dec 15, 2024
1 parent 91c1d17 commit 7ecd22a
Show file tree
Hide file tree
Showing 20 changed files with 5,298 additions and 132,164 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
126 changes: 126 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].

For answers to common questions about this code of conduct, see the FAQ at
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.Rproj.user
.Rhistory
docs
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Package: rrstools
Title: What the Package Does (One Line, Title Case)
Title: Tools for Analyzing RoboCupRescue Simulation Data
Version: 0.0.1
Authors@R:
person("First", "Last", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
person("Keisuke", "ANDO",
email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0009-0002-4085-2067"))
Description: Provides functions for analyzing RoboCupRescue Simulation data.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand All @@ -16,3 +18,4 @@ Imports:
graphics,
sf,
xml2
URL: https://nononoexe.github.io/rrstools/
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,rrs_map)
export(read_rrs_map)
importFrom(graphics,par)
importFrom(sf,st_as_sf)
importFrom(sf,st_collection_extract)
importFrom(sf,st_linestring)
Expand Down
24 changes: 18 additions & 6 deletions R/read-rrs-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@
#'
#' @name read_rrs_map
#' @param gml Path to the GML file.
#' @param scale_data Logical. If `TRUE`, coordinates are scaled up by a factor
#' of 1000 to match the simulation environment, and adjusted such that
#' the minimum x and y values are 0. (Default: `TRUE`)
#' @return A list of `sf` objects: nodes, edges, buildings, and roads.
#' @examples
#' gml <- system.file("extdata", "map.gml", package = "rrstools")
#' gml <- system.file("extdata", "map-test.gml", package = "rrstools")
#' map_data <- read_rrs_map(gml)
#' map_data
NULL

# Parse nodes from the XML and return a sf object
parse_nodes <- function(xml) {
parse_nodes <- function(xml, scale_data) {
nodes <- xml_find_all(xml, ".//gml:Node")
coordinates <- strsplit(xml_text(nodes), ",")

x <- as.numeric(sapply(coordinates, "[[", 1))
y <- as.numeric(sapply(coordinates, "[[", 2))
if (scale_data) {
x <- x * 1000
y <- y * 1000
x <- x - min(x)
y <- y - min(y)
}

return(st_as_sf(
data.frame(id = xml_attr(nodes, "id"), x, y),
Expand Down Expand Up @@ -89,18 +98,21 @@ parse_faces <- function(xml, edge_sf, type = c("building", "road")) {
# Read a GML map and extract nodes, edges, buildings, and roads
#' @rdname read_rrs_map
#' @export
read_rrs_map <- function(gml) {
read_rrs_map <- function(gml, scale_data = FALSE) {
xml <- read_xml(gml)

node_sf <- parse_nodes(xml)
node_sf <- parse_nodes(xml, scale_data)
edge_sf <- parse_edges(xml, node_sf)
building_sf <- parse_faces(xml, edge_sf, "building")
road_sf <- parse_faces(xml, edge_sf, "road")

return(list(
rrs_map <- list(
nodes = node_sf,
edges = edge_sf,
buildings = building_sf,
roads = road_sf
))
)
class(rrs_map) <- c("rrs_map", "list")

return(rrs_map)
}
38 changes: 38 additions & 0 deletions R/rrs-map.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' Plot a rrs map
#'
#' This function plots a rrs map
#' @param x An object class `rrs_map`.
#' @param building_colour The colour of the buildings.
#' @param building_border The border colour of the buildings.
#' @param road_colour The colour of the roads.
#' @param road_border The border colour of the roads.
#' @param background_colour The background colour of the plot.
#' @param ... Additional arguments passed to `par`.
#' @examples
#' gml <- system.file("extdata", "map-test.gml", package = "rrstools")
#' map_data <- read_rrs_map(gml)
#' plot(map_data)
#' @export
plot.rrs_map <- function(x,
building_colour = "#f0e7d8",
building_border = "#121212",
road_colour = "#dbdbdb",
road_border = "#121212",
background_colour = NA,
...) {
par(...)
plot(
x$buildings$geometry,
col = building_colour,
border = building_border,
bg = background_colour
)
plot(
x$roads$geometry,
col = road_colour,
border = road_border,
add = TRUE
)

return(invisible(NULL))
}
1 change: 1 addition & 0 deletions R/rrstools-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom graphics par
#' @importFrom sf st_as_sf
#' @importFrom sf st_collection_extract
#' @importFrom sf st_linestring
Expand Down
71 changes: 71 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# rrstools <img src="man/figures/logo.png" align="right" height="138"/>

<!-- badges: start -->

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/rrstools)](https://CRAN.R-project.org/package=rrstools)

<!-- badges: end -->

## Installation

You can install the development version of rrstools using the following methods:

### Using `install.packages()` (R-universe)

``` r
# Enable the R-universe
options(repos = c(
nononoexe = "https://nononoexe.r-universe.dev",
cran = "https://cloud.r-project.org"
))

# Install the package
install.packages("rrstools")
```

### Using `pak`

``` r
# install.packages("pak)
pak::pak("nononoexe/rrstools")
```

## Usage

This package provides functions to read and plot RRS map data.

```{r example}
library(rrstools)
# Sample GML file
gml <- system.file("extdata", "map-test.gml", package = "rrstools")
# Read the map data from the GML file
map_data <- read_rrs_map(gml)
# Print the map data
map_data
# Plot the map data
plot(map_data)
```

## Code of conduct

Please note that this project is released with a [Contributor Code of Conduct](https://nononoexe.github.io/rrstools/CODE_OF_CONDUCT.html).
By participating in this project you agree to abide by its terms.
Loading

0 comments on commit 7ecd22a

Please sign in to comment.