├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ └── pkgdown.yaml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── 000_cMESH.R ├── 00_arc.R ├── 00_coord.R ├── 00_edge.R ├── 00_node.R ├── 00_object.R ├── 00_path.R ├── 00_segment.R ├── 00_triangle.R ├── 00_uid.R ├── 00_vertex.R ├── ARC-model.R ├── PATH-model.R ├── PATH0-model.R ├── SC-model.R ├── SC0-model.R ├── TIN.R ├── TRI-model.R ├── TRI0-model.R ├── compact-indexes.R ├── dplyr.R ├── earcut.R ├── get-projection.R ├── plot.R ├── print.R ├── silicate-package.R ├── silicate.R ├── spatial-builder.R ├── sysdata.rda ├── triangles.R ├── utils-pipe.R ├── utils.R └── zzz.R ├── README.Rmd ├── README.md ├── cran-comments.md ├── data-raw ├── ear.R ├── flight_tracks.R ├── inlandwaters.gpkg ├── inlandwaters.r ├── internal-data.R ├── lga_border.R ├── minimal-mesh.r ├── polymesh.R ├── routes.R ├── sf-data-zoo.r └── triangle-testbed.r ├── data ├── ear_gc.rda ├── flight_tracks.rda ├── inlandwaters.rda ├── minimal_mesh.rda ├── mmesh.rda ├── polymesh.rda ├── routes.rda ├── sfgc.rda └── sfzoo.rda ├── inst ├── arcs │ └── tg.r ├── examples │ ├── badpoly.R │ ├── edge_norm │ │ └── edge_norm.R │ ├── filter_path.R │ ├── goals-short.Rmd │ ├── graph_segment.R │ ├── grouped_polygonize │ │ ├── group_polygonize.R │ │ └── line_to_poly.R │ ├── inner_edges.R │ ├── leaflet-normalize.R │ ├── osmdata │ │ ├── doc.rds │ │ ├── read_pbf.R │ │ ├── readosm.R │ │ ├── readosm.html │ │ └── rsconnect │ │ │ └── documents │ │ │ └── readosm.R │ │ │ └── rpubs.com │ │ │ └── rpubs │ │ │ └── Document.dcf │ ├── proto-spdep.R │ ├── scheme-columbus.R │ ├── scheme.R │ ├── sf-segments-plot.R │ ├── simplefy.R │ ├── snap.rmd │ └── stateUS.R ├── extdata │ ├── file.geojson │ ├── flight_tracks │ │ ├── flight_tracks.R │ │ ├── tracks.dbf │ │ ├── tracks.prj │ │ ├── tracks.shp │ │ └── tracks.shx │ └── lga_border.gpkg ├── misc │ ├── ARC-data.R │ ├── geospatialsci-2018.md │ ├── geospatialsci-2018.pdf │ ├── imagick.R │ ├── makefile │ ├── old-readme.rmd │ ├── validity.R │ └── whatabouting.Rmd ├── primitives │ └── explore_primitives.R └── topojson │ ├── tj.html │ └── tj.rmd ├── man ├── ARC.Rd ├── PATH.Rd ├── PATH0.Rd ├── SC.Rd ├── SC0.Rd ├── TRI.Rd ├── TRI0.Rd ├── dplyr-methods.Rd ├── ear_gc.Rd ├── flight_tracks.Rd ├── inlandwaters.Rd ├── minimal_mesh.Rd ├── mmesh.Rd ├── pipe.Rd ├── plot.SC.Rd ├── polymesh.Rd ├── print.sc.Rd ├── routes.Rd ├── sc_arc.Rd ├── sc_colours.Rd ├── sc_coord.Rd ├── sc_edge.Rd ├── sc_node.Rd ├── sc_object.Rd ├── sc_path.Rd ├── sc_segment.Rd ├── sc_uid.Rd ├── sc_vertex.Rd ├── sfzoo.Rd ├── silicate.Rd └── tri_area.Rd ├── revdep ├── README.md ├── checks │ └── libraries.csv ├── data.sqlite ├── failures.md ├── library │ └── silicate │ │ ├── new │ │ ├── pillar │ │ │ ├── DESCRIPTION │ │ │ ├── INDEX │ │ │ ├── Meta │ │ │ │ ├── Rd.rds │ │ │ │ ├── features.rds │ │ │ │ ├── hsearch.rds │ │ │ │ ├── links.rds │ │ │ │ ├── nsInfo.rds │ │ │ │ └── package.rds │ │ │ ├── NAMESPACE │ │ │ ├── NEWS.md │ │ │ ├── R │ │ │ │ ├── pillar │ │ │ │ ├── pillar.rdb │ │ │ │ └── pillar.rdx │ │ │ ├── help │ │ │ │ ├── AnIndex │ │ │ │ ├── aliases.rds │ │ │ │ ├── figures │ │ │ │ │ ├── colours.png │ │ │ │ │ ├── lifecycle-archived.svg │ │ │ │ │ ├── lifecycle-defunct.svg │ │ │ │ │ ├── lifecycle-deprecated.svg │ │ │ │ │ ├── lifecycle-experimental.svg │ │ │ │ │ ├── lifecycle-maturing.svg │ │ │ │ │ ├── lifecycle-questioning.svg │ │ │ │ │ ├── lifecycle-retired.svg │ │ │ │ │ ├── lifecycle-soft-deprecated.svg │ │ │ │ │ └── lifecycle-stable.svg │ │ │ │ ├── paths.rds │ │ │ │ ├── pillar.rdb │ │ │ │ └── pillar.rdx │ │ │ └── html │ │ │ │ ├── 00Index.html │ │ │ │ └── R.css │ │ ├── rlang │ │ │ ├── DESCRIPTION │ │ │ ├── INDEX │ │ │ ├── Meta │ │ │ │ ├── Rd.rds │ │ │ │ ├── features.rds │ │ │ │ ├── hsearch.rds │ │ │ │ ├── links.rds │ │ │ │ ├── nsInfo.rds │ │ │ │ └── package.rds │ │ │ ├── NAMESPACE │ │ │ ├── NEWS.md │ │ │ ├── R │ │ │ │ ├── rlang │ │ │ │ ├── rlang.rdb │ │ │ │ └── rlang.rdx │ │ │ ├── backtrace-ver │ │ │ ├── help │ │ │ │ ├── AnIndex │ │ │ │ ├── aliases.rds │ │ │ │ ├── figures │ │ │ │ │ ├── lifecycle-archived.svg │ │ │ │ │ ├── lifecycle-defunct.svg │ │ │ │ │ ├── lifecycle-deprecated.svg │ │ │ │ │ ├── lifecycle-experimental.svg │ │ │ │ │ ├── lifecycle-maturing.svg │ │ │ │ │ ├── lifecycle-questioning.svg │ │ │ │ │ ├── lifecycle-retired.svg │ │ │ │ │ ├── lifecycle-soft-deprecated.svg │ │ │ │ │ ├── lifecycle-stable.svg │ │ │ │ │ └── rlang.png │ │ │ │ ├── paths.rds │ │ │ │ ├── rlang.rdb │ │ │ │ └── rlang.rdx │ │ │ ├── html │ │ │ │ ├── 00Index.html │ │ │ │ └── R.css │ │ │ └── libs │ │ │ │ └── rlang.so │ │ └── silicate │ │ │ ├── DESCRIPTION │ │ │ ├── INDEX │ │ │ ├── Meta │ │ │ ├── Rd.rds │ │ │ ├── data.rds │ │ │ ├── features.rds │ │ │ ├── hsearch.rds │ │ │ ├── links.rds │ │ │ ├── nsInfo.rds │ │ │ └── package.rds │ │ │ ├── NAMESPACE │ │ │ ├── NEWS.md │ │ │ ├── R │ │ │ ├── silicate │ │ │ ├── silicate.rdb │ │ │ ├── silicate.rdx │ │ │ ├── sysdata.rdb │ │ │ └── sysdata.rdx │ │ │ ├── arcs │ │ │ └── tg.r │ │ │ ├── data │ │ │ ├── Rdata.rdb │ │ │ ├── Rdata.rds │ │ │ └── Rdata.rdx │ │ │ ├── extdata │ │ │ ├── file.geojson │ │ │ └── flight_tracks │ │ │ │ ├── flight_tracks.R │ │ │ │ ├── tracks.dbf │ │ │ │ ├── tracks.prj │ │ │ │ ├── tracks.shp │ │ │ │ └── tracks.shx │ │ │ ├── help │ │ │ ├── AnIndex │ │ │ ├── aliases.rds │ │ │ ├── paths.rds │ │ │ ├── silicate.rdb │ │ │ └── silicate.rdx │ │ │ ├── html │ │ │ ├── 00Index.html │ │ │ └── R.css │ │ │ ├── misc │ │ │ ├── ARC-data.R │ │ │ ├── geospatialsci-2018.md │ │ │ ├── geospatialsci-2018.pdf │ │ │ ├── imagick.R │ │ │ ├── makefile │ │ │ ├── old-readme.rmd │ │ │ ├── validity.R │ │ │ └── whatabouting.Rmd │ │ │ ├── primitives │ │ │ └── explore_primitives.R │ │ │ └── topojson │ │ │ ├── tj.html │ │ │ └── tj.rmd │ │ └── old │ │ └── silicate │ │ ├── DESCRIPTION │ │ ├── INDEX │ │ ├── Meta │ │ ├── Rd.rds │ │ ├── data.rds │ │ ├── features.rds │ │ ├── hsearch.rds │ │ ├── links.rds │ │ ├── nsInfo.rds │ │ ├── package.rds │ │ └── vignette.rds │ │ ├── NAMESPACE │ │ ├── NEWS.md │ │ ├── R │ │ ├── silicate │ │ ├── silicate.rdb │ │ ├── silicate.rdx │ │ ├── sysdata.rdb │ │ └── sysdata.rdx │ │ ├── arcs │ │ └── tg.r │ │ ├── data │ │ ├── Rdata.rdb │ │ ├── Rdata.rds │ │ └── Rdata.rdx │ │ ├── doc │ │ ├── index.html │ │ ├── silicate-data-model.R │ │ ├── silicate-data-model.Rmd │ │ ├── silicate-data-model.html │ │ ├── silicate_topology_01.R │ │ ├── silicate_topology_01.Rmd │ │ └── silicate_topology_01.html │ │ ├── extdata │ │ ├── file.geojson │ │ └── flight_tracks │ │ │ ├── flight_tracks.R │ │ │ ├── tracks.dbf │ │ │ ├── tracks.prj │ │ │ ├── tracks.shp │ │ │ └── tracks.shx │ │ ├── help │ │ ├── AnIndex │ │ ├── aliases.rds │ │ ├── paths.rds │ │ ├── silicate.rdb │ │ └── silicate.rdx │ │ ├── html │ │ ├── 00Index.html │ │ └── R.css │ │ ├── misc │ │ ├── ARC-data.R │ │ ├── geospatialsci-2018.md │ │ ├── geospatialsci-2018.pdf │ │ ├── imagick.R │ │ ├── makefile │ │ ├── old-readme.rmd │ │ ├── validity.R │ │ └── whatabouting.Rmd │ │ ├── primitives │ │ └── explore_primitives.R │ │ └── topojson │ │ ├── tj.html │ │ └── tj.rmd └── problems.md ├── tests ├── testthat.R └── testthat │ ├── test-arc.R │ ├── test-as_tibble.R │ ├── test-degenerate.R │ ├── test-dplyr.R │ ├── test-earcut.R │ ├── test-generic-data.R │ ├── test-geometry-dim.R │ ├── test-multi-custom.R │ ├── test-path0-sanity.R │ ├── test-plot.R │ ├── test-print.R │ ├── test-projection.R │ ├── test-round-trip.R │ ├── test-sc-sanity.R │ ├── test-sc.R │ ├── test-sc0-sanity.R │ ├── test-sc_coord.R │ ├── test-sc_object.R │ ├── test-segment-creation.R │ ├── test-sf-PRIMITIVE.R │ ├── test-sf-decomposition.R │ ├── test-spatial-build.R │ ├── test-tri-sanity.R │ ├── test-triangles.R │ ├── test-trip.R │ └── test-valid-inputs.R └── vignettes ├── .gitignore ├── silicate-data-model.Rmd ├── silicate_topology_01.R ├── silicate_topology_01.Rmd └── silicate_topology_01.html /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CODE_OF_CONDUCT\.md$ 2 | ^cran-comments\.md$ 3 | ^.*\.Rproj$ 4 | ^\.Rproj\.user$ 5 | ^data-raw$ 6 | ^docs$ 7 | ^README\.Rmd$ 8 | ^\.travis\.yml$ 9 | ^codecov\.yml$ 10 | ^appveyor\.yml$ 11 | ^inst/examples 12 | ^R/old 13 | ^silicate\.Rproj$ 14 | ^silicate\.Rcheck$ 15 | ^silicate.*\.tar\.gz$ 16 | ^silicate.*\.tgz$ 17 | ^CRAN-RELEASE$ 18 | ^revdep$ 19 | ^\.github$ 20 | 21 | ^CRAN-SUBMISSION$ 22 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | - master 6 | 7 | name: pkgdown 8 | 9 | jobs: 10 | pkgdown: 11 | runs-on: macOS-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: r-lib/actions/setup-r@v1 18 | 19 | - uses: r-lib/actions/setup-pandoc@v1 20 | 21 | - name: Query dependencies 22 | run: | 23 | install.packages('remotes') 24 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 25 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 26 | shell: Rscript {0} 27 | 28 | - name: Cache R packages 29 | uses: actions/cache@v2 30 | with: 31 | path: ${{ env.R_LIBS_USER }} 32 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 33 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 34 | 35 | - name: Install dependencies 36 | run: | 37 | remotes::install_deps(dependencies = TRUE) 38 | install.packages("pkgdown", type = "binary") 39 | shell: Rscript {0} 40 | 41 | - name: Install package 42 | run: R CMD INSTALL . 43 | 44 | - name: Deploy package 45 | run: | 46 | git config --local user.email "actions@github.com" 47 | git config --local user.name "GitHub Actions" 48 | Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | *.Rproj 5 | inst/doc 6 | silicate.Rcheck/ 7 | silicate*.tar.gz 8 | silicate*.tgz 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (http://contributor-covenant.org), version 1.0.0, available at 25 | http://contributor-covenant.org/version/1/0/0/ 26 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: silicate 2 | Title: Common Forms for Complex Hierarchical and Relational Data Structures 3 | Version: 0.7.1.9001 4 | Authors@R: c(person("Michael D.","Sumner", role = c("aut", "cre"), email = "mdsumner@gmail.com"), 5 | person("John", "Corbett", role = "ctb", comment = "the original inspiration"), 6 | person("Simon", "Wotherspoon", role = "ctb"), 7 | person("Kent", "Johnson", role = "dtc"), 8 | person("Mark", "Padgham", role = "aut") 9 | ) 10 | Description: Generate common data forms for complex data suitable for conversions and 11 | transmission by decomposition as paths or primitives. Paths are sequentially-linked records, 12 | primitives are basic atomic elements and both can model many forms and be grouped into hierarchical 13 | structures. The universal models 'SC0' (structural) and 'SC' (labelled, relational) are composed of 14 | edges and can represent any hierarchical form. Specialist models 'PATH', 'ARC' and 'TRI' provide the 15 | most common intermediate forms used for converting from one form to another. The methods are 16 | inspired by the simplicial complex and 17 | provide intermediate forms that relate spatial data structures to this mathematical construct. 18 | Depends: 19 | R (>= 3.4.0) 20 | License: GPL-3 21 | Encoding: UTF-8 22 | LazyData: true 23 | Suggests: 24 | covr, 25 | knitr, 26 | rmarkdown, 27 | sp, 28 | testthat (>= 2.1.0), 29 | trip, 30 | vdiffr 31 | Imports: 32 | dplyr, 33 | gibble (>= 0.4.0), 34 | methods, 35 | purrr, 36 | rlang, 37 | decido, 38 | tibble, 39 | unjoin (>= 0.1.0), 40 | grDevices, 41 | graphics, 42 | stats, 43 | magrittr, 44 | gridBase, 45 | crsmeta (>= 0.3.0) 46 | VignetteBuilder: knitr 47 | Roxygen: list(markdown = TRUE) 48 | URL: https://github.com/hypertidy/silicate, https://hypertidy.github.io/silicate/ 49 | BugReports: https://github.com/hypertidy/silicate/issues 50 | RoxygenNote: 7.2.3 51 | -------------------------------------------------------------------------------- /R/000_cMESH.R: -------------------------------------------------------------------------------- 1 | ## MDSumner 2018-09-29 2 | ## bash at a vector type with a shared vertex pool 3 | 4 | 5 | # library(silicate) 6 | # sc <- silicate::TRI(minimal_mesh) 7 | # x1 <- c_MESH(lapply(split(tibble::as_tibble(matrix(match(as.matrix(sc$triangle[1:3]), sc$vertex$vertex_), ncol = 3)), 1:nrow(sc$triangle)), si_triangle), vertex_pool = sc$vertex[1:2]) 8 | # x2 <- c_MESH(si_triangle(tibble::tibble(V1 = 6, V2 = 7, V3 = 14)), 9 | # si_triangle(tibble::tibble(V1 = 14, V2 = 13, V3 = 6)), vertex_pool = sc$vertex[1:2]) 10 | # 11 | # plot(x1) 12 | # plot(x2, add = TRUE, border = "blue") 13 | 14 | 15 | # nocov start 16 | 17 | ## atomic index element 18 | si_triangle <- function(x) { 19 | structure(tibble::as_tibble(x), class = c("MESH", "tbl_df", "data.frame")) 20 | } 21 | 22 | ## vector of atomic index elements 23 | c_MESH <- function(..., vertex_pool = NULL) { 24 | UseMethod("c_MESH") 25 | } 26 | c_MESH.default <- function(..., vertex_pool = NULL) { 27 | stopifnot(is.data.frame(vertex_pool)) 28 | structure(list(...), class = c("cMESH"), vertex_pool = vertex_pool) 29 | } 30 | c_MESH.list <- function(..., vertex_pool = NULL) { 31 | structure(list(...)[[1]], class = c("cMESH"), vertex_pool = vertex_pool) 32 | } 33 | vpool <- function(x) attr(x, "vertex_pool") 34 | print.cMESH <- function(x, ...) { 35 | cat(sprintf("object of class: %s\n", class(x)[1])) 36 | cat(sprintf(" primitives: %i\n", length(x))) 37 | cat(sprintf(" vertices: %i\n", nrow(vpool(x)))) 38 | 39 | } 40 | remove_inner_borders <- function(x, ...) { 41 | 42 | } 43 | #' @importFrom graphics polygon 44 | plot.cMESH <- function(x, ..., add = FALSE, inner_borders = TRUE) { 45 | pool <- vpool(x) 46 | if (!add) plot(pool, type = "n") 47 | if (inner_borders) { 48 | graphics::polygon(pool[do.call(rbind, lapply(x, function(a) t(cbind(as.matrix(a)[, c(1, 2, 3, 1), drop = FALSE], NA)))), ], ...) 49 | } else { 50 | x <- remove_inner_borders(x) 51 | } 52 | invisible(NULL) 53 | } 54 | 55 | # nocov end 56 | 57 | 58 | -------------------------------------------------------------------------------- /R/00_node.R: -------------------------------------------------------------------------------- 1 | #' Nodes for arc-node topology. 2 | #' 3 | #' Nodes are the vertices in the graph that are shared by "arcs". 4 | #' 5 | #' @param x input object 6 | #' @param ... arguments for methods 7 | #' @return data frame of the nodes 8 | #' @export 9 | #' @importFrom rlang .data 10 | #' @examples 11 | #' sc_node(ARC(minimal_mesh)) 12 | sc_node <- function(x, ...) { 13 | UseMethod("sc_node") 14 | } 15 | #' @name sc_node 16 | #' @export 17 | #' @examples 18 | #' sc <- SC(routes) 19 | #' library(dplyr) 20 | #' plot(sc) 21 | #' sc_node(sc) %>% inner_join(sc$vertex) %>% select(x_, y_) %>% points() 22 | sc_node.SC <- function(x, ...) { 23 | alledge <- tibble::tibble(v = c(x$edge$.vx0, x$edge$.vx1), 24 | e = c(x$edge$edge_, x$edge$edge_)) 25 | v0 <- alledge %>% group_by("v") %>% tally() %>% filter(!n == 2) 26 | tibble::tibble(vertex_ = sort(unique(v0$v))) 27 | } 28 | #' @name sc_node 29 | #' @export 30 | sc_node.SC0 <- function(x, ...) { 31 | sc <- SC(x) 32 | nodes_id <- sc_node(sc) 33 | nodes_id %>% 34 | dplyr::inner_join(sc$vertex, "vertex_") %>% 35 | dplyr::select(-"vertex_") 36 | } 37 | #' @name sc_node 38 | #' @export 39 | sc_node.default <- function(x, ...) { 40 | x <- SC(x) 41 | sc_node(x) 42 | } 43 | #' @name sc_node 44 | #' @export 45 | sc_node.PATH <- function(x, ...) { 46 | sc_node_base(sc_edge(x), x[["vertex"]]) 47 | } 48 | #' @name sc_node 49 | #' @export 50 | sc_node.ARC <- function(x, ...) { 51 | ## remove all non-noded arcs 52 | x$arc_link_vertex %>% 53 | dplyr::add_count("vertex_") %>% 54 | dplyr::filter("n" > 2) %>% 55 | dplyr::distinct("vertex_") 56 | } 57 | 58 | sc_node_base <- function(unique_edges, vertex, ...) { 59 | nodes <- dplyr::bind_rows(vertex %>% dplyr::select("vertex_") %>% 60 | dplyr::inner_join(unique_edges, c("vertex_" = ".vx0")), 61 | vertex %>% dplyr::select("vertex_") %>% 62 | dplyr::inner_join(unique_edges, c("vertex_" = ".vx1"))) %>% 63 | dplyr::distinct("edge_", "vertex_") %>% 64 | dplyr::group_by("vertex_") %>% dplyr::tally() %>% dplyr::ungroup() %>% 65 | dplyr::filter("n" > 2) %>% dplyr::distinct("vertex_") 66 | nodes 67 | } 68 | -------------------------------------------------------------------------------- /R/00_segment.R: -------------------------------------------------------------------------------- 1 | #' Given a `PATH`` model decompose to 1-dimensional primitives (or 0-dimensional). 2 | #' 3 | #' @param x input object 4 | #' @param ... arguments passed to methods 5 | #' @importFrom dplyr %>% inner_join mutate 6 | #' @name sc_segment 7 | #' @return data frame of the segments, each occurence of an edge and its order 8 | #' @export 9 | #' @examples 10 | #' sc_segment(SC(minimal_mesh)) 11 | sc_segment <- function(x, ...) UseMethod("sc_segment") 12 | #' @name sc_segment 13 | #' @export 14 | sc_segment.default <- function(x, ...) { 15 | x <- SC(x) 16 | sc_segment(x, ...) 17 | } 18 | sc_segment.SC <- function(x, ...) { 19 | ## expand all instances of edges 20 | segments <- x$object_link_edge %>% 21 | dplyr::inner_join(x$edge, "edge_") 22 | 23 | ## and badge them as segments 24 | segments$segment_ <- sc_uid(nrow(segments)) 25 | segments 26 | } 27 | #' @name sc_segment 28 | #' @export 29 | sc_segment.PATH <- function(x, ...) { 30 | sc_segment_base(x[["path_link_vertex"]]) 31 | } 32 | 33 | 34 | sc_segment_base <- function(path_link_vertex) { 35 | ## how many vertices on each path? 36 | frle <- rle(path_link_vertex[["path_"]]) 37 | if (all(frle$lengths == 1L)) { 38 | return(tibble::tibble(.vx0 = path_link_vertex$vertex_, 39 | .vx1 = ".vx0", 40 | path_ = path_link_vertex$path_, 41 | segment_ = sc_uid(nrow(path_link_vertex)), 42 | edge_ = sc_uid(length(unique(".vx0")))[factor(".vx0")])) 43 | } 44 | ## push into segments 45 | segtab <- path_to_segment(path_link_vertex[["vertex_"]]) 46 | if (length(frle$values) > 1L) { 47 | ## this fails if there's only one path in the whole set 48 | ## fixes https://github.com/hypertidy/silicate/issues/40 49 | segtab <- segtab[-utils::head(cumsum(frle$lengths), -1L), ] 50 | } 51 | segtab[["path_"]] <- rep(frle$values, frle$lengths - 1) 52 | segtab[["segment_"]] <- sc_uid(nrow(segtab)) 53 | edge <- paste(pmin(segtab[[".vx0"]], segtab[[".vx1"]]), pmax(segtab[[".vx0"]], segtab[[".vx1"]]), sep = "_") 54 | f <- factor(edge) 55 | segtab[["edge_"]] <- sc_uid(nlevels(f))[f] 56 | segtab 57 | } 58 | -------------------------------------------------------------------------------- /R/00_triangle.R: -------------------------------------------------------------------------------- 1 | ## this all stuff belongs in silicate (rgl) 2 | ## pondering sc_quad (or just sc_primitive, because quads can be triangles) 3 | 4 | 5 | 6 | sc_triangle <- function(x, ...) { 7 | UseMethod("sc_triangle") 8 | } 9 | 10 | sc_triangle.default <- function(x, ...) { 11 | sc_triangle(silicate::TRI0(x), ...) 12 | } 13 | 14 | sc_triangle.TRI0 <- function(x, ...) { 15 | obj <- sc_object(x) 16 | topol <- obj$topology_ 17 | for (i in seq_along(topol)) { 18 | topol[[i]][["object_"]] <- as.character(i) 19 | } 20 | do.call(rbind, topol) 21 | } 22 | 23 | sc_triangle.TRI <- function(x, ...) { 24 | x[["triangle"]] 25 | } 26 | 27 | sc_triangle.mesh3d <- function(x, ...) { 28 | tri <- x[["it"]] 29 | if (is.null(tri)) stop("no triangles in this model") ## could convert quads, though 30 | 31 | tibble::tibble(.vx0 = tri[1L, ], 32 | .vx1 = tri[2L, ], 33 | .vx2 = tri[3L, ]) ## visible = TRUE, object_ = 1 ?? 34 | } 35 | -------------------------------------------------------------------------------- /R/00_uid.R: -------------------------------------------------------------------------------- 1 | 2 | #' Unique labels 3 | #' 4 | #' Find unique labels for entities, or create them 5 | #' if not present. 6 | #' 7 | #' If 'integers' default we generate sequential integers, it's assumed that all IDs are created 8 | #' at one time, we are not adding to an existing set. Code that adds IDs should find 9 | #' the largest existing ID and offset these by that value. 10 | #' 11 | #' Using 'silicate.uid.type="uuid"' is the default. Using 'silicate.uid.type="integer"' is considered experimental. 12 | #' By default UIDs are a mix of letters, LETTERS and digits of length `getOption("silicate.uid.size")` which defaults to 6. 13 | #' 14 | #' See `ids` package for `random_id` used if option 'silicate.uid.type="uuid"'. 15 | #' @param x number of unique IDs to generate 16 | #' @param ... reserved for future use 17 | #' @param uid_nchar number of raw characters to paste as a uuid, default is 6 (only if silicate.uid.type is "uuid", see Details) 18 | #' @export 19 | #' @return vector of unique id values for elements in the input 20 | #' @examples 21 | #' sc_uid(data.frame(1:10)) 22 | sc_uid <- function(x, ..., uid_nchar = NULL) { 23 | UseMethod("sc_uid") 24 | } 25 | #' @export 26 | sc_uid.numeric <- function(x, ..., uid_nchar = NULL) { 27 | op <- getOption("silicate.uid.type") 28 | tst <- valid_uid_type(op) 29 | if (op == "uuid") { 30 | if (is.null(uid_nchar)) { 31 | uid_nchar <- getOption("silicate.uid.size") 32 | } 33 | out <- uuid_id(x[1], uid_nchar = uid_nchar) 34 | } 35 | if (op == "integer") { 36 | out <- seq.int(1, x[1]) 37 | } 38 | out 39 | } 40 | #' @export 41 | sc_uid.data.frame <- function(x, ..., uid_nchar = NULL) { 42 | sc_uid(nrow(x), uid_nchar = uid_nchar) 43 | } 44 | #' @export 45 | sc_uid.Spatial <- function(x, ..., uid_nchar = NULL) { 46 | nr <- if (methods::.hasSlot(x, "data")(x)) dim(x)[1L] else length(x) 47 | sc_uid(nr, uid_nchar = uid_nchar) 48 | } 49 | 50 | uuid_id <- function(x, ..., uid_nchar = NULL) { 51 | #ids::random_id(x, bytes = bytes) 52 | unlist(lapply(split(sample(raw_chars, x * uid_nchar, replace = TRUE), 53 | rep(seq.int(x), each = nchar)), paste, collapse = ""), use.names = FALSE) 54 | 55 | } 56 | 57 | valid_uid_type <- function(x) { 58 | if (!x %in% c("integer", "uuid")) { 59 | stop(sprintf("option 'silicate.uid.type = \"%s\"' not known (use 'integer' or 'uuid')", x)) 60 | } 61 | x 62 | } 63 | -------------------------------------------------------------------------------- /R/00_vertex.R: -------------------------------------------------------------------------------- 1 | #' Extract unique vertices 2 | #' 3 | #' @param x model 4 | #' @param ... passed to methods 5 | #' @return data frame of only the unique coordinates 6 | #' @export 7 | #' @examples 8 | #' sc_vertex(minimal_mesh) 9 | #' sc_vertex(SC0(minimal_mesh)) 10 | sc_vertex <- function(x, ...) { 11 | UseMethod("sc_vertex") 12 | } 13 | #' @name sc_vertex 14 | #' @export 15 | sc_vertex.default <- function(x, ...) { 16 | SC0(x)[["vertex"]] 17 | } 18 | 19 | #' @name sc_vertex 20 | #' @export 21 | sc_vertex.SC <- function(x, ...) { 22 | x[["vertex"]] 23 | } 24 | #' @name sc_vertex 25 | #' @export 26 | sc_vertex.SC0 <- function(x, ...) { 27 | x[["vertex"]] 28 | } 29 | #' @name sc_vertex 30 | #' @export 31 | sc_vertex.ARC <- function(x, ...) { 32 | x[["vertex"]] 33 | } 34 | #' @name sc_vertex 35 | #' @export 36 | sc_vertex.TRI <- function(x, ...) { 37 | x[["vertex"]] 38 | } 39 | #' @name sc_vertex 40 | #' @export 41 | sc_vertex.TRI0 <- function(x, ...) { 42 | x[["vertex"]] 43 | } 44 | 45 | #' @name sc_vertex 46 | #' @export 47 | sc_vertex.PATH <- function(x, ...) { 48 | x[["vertex"]] 49 | } 50 | #' @name sc_vertex 51 | #' @export 52 | sc_vertex.PATH0 <- function(x, ...) { 53 | x[["vertex"]] 54 | } 55 | 56 | #' @name sc_vertex 57 | #' @export 58 | sc_vertex.pslg <- function(x, ...) { 59 | tibble::tibble(x_ = x$P[,1L], y_ = x$P[,2L]) 60 | } 61 | -------------------------------------------------------------------------------- /R/PATH-model.R: -------------------------------------------------------------------------------- 1 | 2 | #' PATH model. 3 | #' 4 | #' A PATH model is a direct translation of a simple features-alike 5 | #' object to normal form. This is four tables with the three kinds of entities, 6 | #' "objects" (or "features"), "paths" (or "parts") and "vertices", and a table 7 | #' to link the one-to-many relation between paths and vertices. 8 | #' 9 | #' In a data set with no parts touching their neighbours, the only normalization of the vertices 10 | #' will be the removal of the duplicated closing coordinate on any polygon ring, and on 11 | #' any self-intersecting case within a single path. 12 | #' 13 | #' `PATH()$path` should always have columns `object_ path_ subobject ncoords_` 14 | #' @inheritParams SC 15 | #' @name PATH 16 | #' @return a PATH model, with tables 'object', 'path', 'path_link_vertex' and 'vertex' 17 | #' @seealso `sc_path`, `sc_coord` 18 | #' @export 19 | PATH <- function(x, ...) UseMethod("PATH") 20 | 21 | PATH.PATH <- function(x, ...) x 22 | #' @name PATH 23 | #' @export 24 | PATH.SC <- function(x, ...) { 25 | stop("PATH not yet implemented for SC") 26 | } 27 | #' @name PATH 28 | #' @export 29 | PATH.TRI <- function(x, ...) { 30 | stop("PATH not yet implemented for TRI") 31 | } 32 | 33 | #' @name PATH 34 | #' @export 35 | #' @importFrom dplyr bind_cols mutate 36 | #' @importFrom tibble tibble 37 | #' @importFrom unjoin unjoin 38 | PATH.default <- function(x, ...) { 39 | ## get the main stuff 40 | o <- sc_object(x) 41 | o[["object_"]] <- sc_uid(nrow(o)) 42 | b <- sc_path(x, ids = o[["object_"]]) 43 | 44 | v <- sc_coord(x) 45 | V_names <- names(v) 46 | v <- dplyr::mutate(v, path_ = rep(b$path_, b$ncoords_)) 47 | key_col <- "vertex_" 48 | maindata <- unjoin::unjoin(v, V_names, key_col = key_col) 49 | dd <- maindata[["data"]] 50 | id <- sc_uid(dd) 51 | v <- dplyr::mutate(maindata[[key_col]], vertex_ = id[maindata[[key_col]][[key_col]]]) 52 | bXv <- dplyr::mutate(maindata[["data"]], vertex_ = id[dd[[key_col]]]) 53 | #v[[key_col]] <- bXv[[key_col]] <- NULL 54 | join_ramp <- tabnames <- c("object", "path", "path_link_vertex", "vertex") 55 | meta <- tibble(proj = get_projection(x), ctime = format(Sys.time(), tz = "UTC")) 56 | structure(list(object = o, path = b,path_link_vertex = bXv, vertex = v, meta = meta), 57 | class = c("PATH", "sc"), 58 | join_ramp = join_ramp) 59 | } 60 | 61 | join_ramp <- function(x) attr(x, "join_ramp") 62 | 63 | globalVariables(".idx0") 64 | -------------------------------------------------------------------------------- /R/TIN.R: -------------------------------------------------------------------------------- 1 | # https://github.com/hypertidy/silicate/issues/118 2 | # tin <- sf::st_as_sfc("TIN Z (((0 0 0, 0 0 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 0 0 0)))") 3 | 4 | tri_to_sf <- function(x, ...) { 5 | x <- TRI0(x) 6 | d <- sc_vertex(x)[as.vector(t(as.matrix(do.call(rbind, x$object$topology_)[, c(".vx0", ".vx1", ".vx2")]))), ] 7 | d <- as.matrix(d) 8 | if (dim(d)[2L] == 2) { 9 | d <- cbind(d, 0) 10 | } 11 | colnames(d) <- NULL 12 | template <- structure(list(matrix(0.0, ncol = 3L, nrow = 4L)), 13 | class = c("XYZ", "TRIANGLE", "sfg")) 14 | ntriangles <- dim(d)[1]/3 15 | out <- replicate(ntriangles, template, simplify = FALSE) 16 | for (i in seq_along(out)) { 17 | triplet <- c(1L, 2L, 3L, 1L) + (i - 1) * 3 18 | out[[i]][[1]] <- d[triplet, ] 19 | } 20 | 21 | rl <- unlist(lapply(x$object$topology_, function(x) dim(x)[1])) 22 | outlist <- lapply(split(out, rep(seq_along(rl), rl)), 23 | function(x) structure(x, class = c("XYZ", "TIN", "sfg"))) 24 | structure(outlist, n_empty = 0L, 25 | crs = structure(list(input = NA_character_, wkt = NA_character_), class = "crs"), class = c("sfc_TIN","sfc"), 26 | precision = 0, bbox = structure(c(xmin = min(d[,1L]), ymin = min(d[,2L]), xmax = max(d[,1L]), ymax = max(d[,2L])), 27 | class = "bbox"), 28 | z_range = structure(c(zmin = min(d[,3L]), zmax = max(d[,3L])), class = "z_range")) 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /R/dplyr.R: -------------------------------------------------------------------------------- 1 | 2 | #' Dplyr methods for silicate objects 3 | #' 4 | #' Filter an SC model, currently only `dplyr::filter` for `SC` is available. 5 | #' 6 | #' Apply expressions as if used on the `object` table. See `sc_object(x)` for that form. 7 | #' 8 | #' Currently all the vertices are still kept, so the model (and any plots) include the filtered edges as well 9 | #' as undifferentiated points. This is likely to change ... 10 | #' @param .data data object of class SC 11 | #' @param ... passed to `dplyr::filter` 12 | #' @name dplyr-methods 13 | #' @aliases filter 14 | #' @export 15 | #' @importFrom dplyr filter 16 | #' @export filter 17 | #' @return an [SC()] model, with some parts filtered out 18 | #' @examples 19 | #' library(dplyr) 20 | #' sc <- SC(inlandwaters) 21 | #' plot(filter(sc, Province == "Tasmania")) 22 | #' plot(filter(sc, Province %in% c("Victoria", "South Australia", "New South Wales"))) 23 | #' 24 | #' plot(filter(SC(minimal_mesh), a == 1)) 25 | filter.SC <- function(.data, ...) { 26 | .data[["object"]] <- dplyr::filter(.data[["object"]], ...) 27 | .data[["object_link_edge"]] <- dplyr::semi_join(.data[["object_link_edge"]], 28 | .data[["object"]], "object_") 29 | .data[["edge"]] <- dplyr::semi_join(.data[["edge"]], 30 | .data[["object_link_edge"]], "edge_") 31 | .data[["vertex"]] <- .data[["vertex"]][.data$vertex$vertex_ %in% as.vector(as.matrix("edge"[c(".vx0", ".vx1")])), ] 32 | # tabs <- c("object", "object_link_edge", "edge") 33 | # .data[tabs] <- semi_cascade0(.data[tabs], tables = tabs) 34 | .data 35 | } 36 | 37 | semi_cascade0 <- function (x, ..., tables = c("o", "b", "bXv", "v")) { 38 | itab <- tables[1L] 39 | first <- dplyr::filter(x[[itab]], ...) 40 | x[[itab]] <- last <- first 41 | tables <- tables[-1] 42 | for (itab in tables) { 43 | x[[itab]] <- last <- semi_join_1(x[[itab]], 44 | last) 45 | } 46 | x 47 | } 48 | 49 | semi_join_1 <- 50 | function (x, y, by = NULL, copy = FALSE, ...) 51 | { 52 | comm <- base::intersect(names(x), names(y)) 53 | if (length(comm) == 1L) { 54 | by <- comm 55 | } 56 | dplyr::semi_join(x, y, by = by, copy = copy, ...) 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /R/earcut.R: -------------------------------------------------------------------------------- 1 | ## internal function 2 | earcut_PATH <- function(x, ...) { 3 | holes <- NULL 4 | path <- silicate::sc_path(x) 5 | path_link_vertex <- x$path_link_vertex 6 | vertex <- x$vertex 7 | if (nrow(vertex) < 3) stop("need at least 3 coordinates") 8 | if (anyNA(vertex$x_)) stop("missing values in x_") 9 | if (anyNA(vertex$y_)) stop("missing values in y_") 10 | ## here we need a new "object", analogous to polygon 11 | ## can be temporary 12 | path$hole <- duplicated(path$object_) 13 | #path$object_ <- as.integer(factor(path$object_)) 14 | tri <- unlist(lapply(unname(split(path, path$object_)), function(apath) { 15 | x <- dplyr::inner_join(apath, path_link_vertex, "path_") %>% 16 | dplyr::inner_join(vertex, "vertex_") %>% 17 | dplyr::select("x_", "y_", "vertex_", "path_") 18 | x <- x[!duplicated(x["vertex_"]), ] 19 | holes <- which(abs(diff(as.integer(factor(x$path_)))) > 0) 20 | if (length(holes) < 1) holes <- 0 21 | idx <- decido::earcut(cbind(x[["x_"]], x[["y_"]]), holes, ...) 22 | out <- match(x$vertex_[idx], vertex$vertex_) 23 | out 24 | })) 25 | tri 26 | } 27 | 28 | -------------------------------------------------------------------------------- /R/get-projection.R: -------------------------------------------------------------------------------- 1 | ## this all belongs in a core shared package 2 | get_projection <- function(x, ...) UseMethod("get_projection") 3 | get_projection.default <- function(x, ...) { 4 | ## same as anglr:::get_proj 2020-03-24 5 | x_na <- NA_character_ 6 | proj <- crsmeta::crs_proj(x) 7 | if (is.na(proj) || is.null(proj) || nchar(proj) < 1) { 8 | proj <- crsmeta::crs_input(x) 9 | } 10 | if (is.na(proj) || is.null(proj) || nchar(proj) < 1) { 11 | return(x_na) 12 | } 13 | proj 14 | } 15 | -------------------------------------------------------------------------------- /R/silicate.R: -------------------------------------------------------------------------------- 1 | # nocov start 2 | include_nn <- function(x, y, name) { 3 | if (!is.null(y)) x[[name]] <- tibble::as_tibble(y) 4 | x 5 | } 6 | has_thing <- function(x, thing) { 7 | thing %in% names(x) && tibble::is_tibble(x[[thing]]) 8 | } 9 | has_vertex <- function(x) { 10 | has_thing(x, "vertex") 11 | } 12 | 13 | has_edge <- function(x) { 14 | has_thing(x, "edge") 15 | } 16 | has_path <- function(x) { 17 | has_thing(x, "path") 18 | } 19 | has_object <- function(x) { 20 | has_thing(x, "object") 21 | } 22 | 23 | silicate <- function(vertex = NULL, edge = NULL, path = NULL, object = NULL, model = NULL) { 24 | x <- model %||% list() 25 | x <- include_nn(x, vertex, "vertex") 26 | x <- include_nn(x, edge, "edge") 27 | x <- include_nn(x, path, "path") 28 | x <- include_nn(x, object, "object") 29 | 30 | if (length(x) == 0L) warning("empty silicate shell") 31 | structure(x, class = "sc") 32 | } 33 | 34 | # nocov end 35 | -------------------------------------------------------------------------------- /R/sysdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/R/sysdata.rda -------------------------------------------------------------------------------- /R/triangles.R: -------------------------------------------------------------------------------- 1 | 2 | tri_ix <- function(x) { 3 | offset <- rep(seq(0, nrow(x) - 1, by = 3), each = 3) 4 | c(3L, 1L, 2L) + offset 5 | } 6 | 7 | tri_jx <- function(x) { 8 | offset <- rep(seq(0, nrow(x) - 1, by = 3), each = 3) 9 | c(1L, 2L, 3L) + offset 10 | } 11 | 12 | 13 | #' Area of triangles 14 | #' 15 | #' Input is x,y matrix in triplets, with 3 rows per triangle vertex. 16 | #' 17 | #' @param x matrix of triangle coordinates 18 | #' 19 | #' @return numeric, area of triangles 20 | #' @export 21 | #' @examples 22 | #' pts <- structure(c(5L, 3L, 1L, 4L, 4L, 8L, 6L, 9L), .Dim = c(4L, 2L)) 23 | #' tri <- c(2, 1, 3, 2, 4, 1) 24 | #' (a <- tri_area(pts[tri, ])) 25 | #' plot(pts) 26 | #' polygon(pts[head(as.vector(rbind(matrix(tri, nrow = 3), NA)), -1), ]) 27 | #' text(tapply(pts[tri,1], rep(1:2, each = 3), mean), 28 | #' tapply(pts[tri,2], rep(1:2, each = 3), mean), labels = sprintf("area: %0.1f", a)) 29 | tri_area <- function(x) { 30 | ix <- tri_ix(x) 31 | jx <- tri_jx(x) 32 | abs(colSums(matrix((x[ix, 1] + x[jx, 1]) * (x[ix, 2] - x[jx, 2]), nrow = 3L))/2) 33 | } 34 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% 10 | #' @usage lhs \%>\% rhs 11 | NULL 12 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | # Defaults for NULL values 2 | `%||%` <- function(a, b) if (is.null(a)) b else a 3 | 4 | 5 | 6 | #' @importFrom utils tail 7 | path_to_segment <- function(x) tibble::as_tibble(list(.vx0 = utils::head(x, -1L), 8 | .vx1 = utils::tail(x, -1))) 9 | 10 | 11 | ## duplicated in anglr, originally from quadmesh::trianglate_quads 12 | .quad2tri <- function (quad_index, clockwise = FALSE) 13 | { 14 | if (clockwise) { 15 | matrix(rbind(quad_index[c(1L, 2L, 4L), ], quad_index[c(2L, 16 | 3L, 4L), ]), 3L) 17 | } 18 | else { 19 | matrix(rbind(quad_index[c(1L, 4L, 2L), ], quad_index[c(4L, 20 | 3L, 2L), ]), 3L) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | # from: https://github.com/r-spatial/sf/blob/2d4a08d5e18ad3a0ca839b509383bb2cca77125a/R/tidyverse.R#L373 2 | # "2018-10-30 23:36:40 UTC" 3 | #nocov start 4 | # register_s3_method <- function(pkg, generic, class, fun = NULL) { 5 | # stopifnot(is.character(pkg), length(pkg) == 1) 6 | # stopifnot(is.character(generic), length(generic) == 1) 7 | # stopifnot(is.character(class), length(class) == 1) 8 | # 9 | # if (is.null(fun)) { 10 | # fun <- get(paste0(generic, ".", class), envir = parent.frame()) 11 | # } else { 12 | # stopifnot(is.function(fun)) 13 | # } 14 | # 15 | # if (pkg %in% loadedNamespaces()) { 16 | # registerS3method(generic, class, fun, envir = asNamespace(pkg)) 17 | # } 18 | # 19 | # # Always register hook in case package is later unloaded & reloaded 20 | # setHook( 21 | # packageEvent(pkg, "onLoad"), 22 | # function(...) { 23 | # registerS3method(generic, class, fun, envir = asNamespace(pkg)) 24 | # } 25 | # ) 26 | # } 27 | # # nocov end 28 | # 29 | .onLoad <- function(...) { 30 | #register_s3_method("dplyr", "filter", "SC") 31 | op <- getOption("silicate.uid.type") 32 | 33 | if (is.null(op) || is.na(op) || length(op) < 1) { 34 | op <- "uuid" ## or "integer" 35 | options(silicate.uid.type = op) 36 | } 37 | op.size <- getOption("silicate.uid.size") 38 | if (is.null(op.size) || is.na(op.size) || length(op.size) < 1) { 39 | 40 | options(silicate.uid.size = 6L) 41 | } 42 | invisible() 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | # silicate 0.7.1 2 | 3 | Better conditional handling of suggested packages in tests. 4 | 5 | 6 | Thank you very much. 7 | 8 | ## Test environments 9 | 10 | * local ubuntu 11 | * win-builder (devel and release) 12 | 13 | ## R CMD check results 14 | 15 | 0 errors | 0 warnings | 0 notes 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /data-raw/flight_tracks.R: -------------------------------------------------------------------------------- 1 | 2 | flight_tracks <- silicate::PATH(sf::read_sf(system.file("extdata", "flight_tracks", "tracks.shp", package = "silicate"))) 3 | devtools::use_data(flight_tracks) 4 | -------------------------------------------------------------------------------- /data-raw/inlandwaters.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data-raw/inlandwaters.gpkg -------------------------------------------------------------------------------- /data-raw/inlandwaters.r: -------------------------------------------------------------------------------- 1 | f <- "https://github.com/r-gris/polyggon/raw/master/inst/extdata/inlandwaters.gpkg" 2 | lfile <- file.path("data-raw", basename(f)) 3 | if (!file.exists(lfile)){ 4 | download.file(f, lfile, mode = "wb") 5 | } 6 | 7 | library(sf) 8 | library(dplyr) 9 | inlandwaters <- st_read(file.path("data-raw", basename(f)), 10 | stringsAsFactors = FALSE) %>% 11 | slice(c(1, 2, 3, 6, 7, 8)) 12 | plot(inlandwaters) 13 | class(inlandwaters$geom) <- c("sfc_MULTIPOLYGON", "sfc" , "list") 14 | 15 | usethis::use_data(inlandwaters, compress = "xz", overwrite = TRUE) 16 | -------------------------------------------------------------------------------- /data-raw/lga_border.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | 3 | lga <- ozmaps::abs_lga 4 | oz <- ozmaps::abs_ste 5 | nsw <- unlist(lapply(st_intersects(lga, oz %>% dplyr::filter(NAME == "New South Wales")), length) > 0) 6 | vic <- unlist(lapply(st_intersects(lga, oz %>% dplyr::filter(NAME == "Victoria")), length) > 0) 7 | nsw_vic <- lga[nsw & vic, ] 8 | ## if your centroid is in the state, you are in 9 | nsw2 <- unlist(lapply(st_intersects(st_centroid(nsw_vic), oz %>% dplyr::filter(NAME == "New South Wales")), length) > 0) 10 | vic2 <- unlist(lapply(st_intersects(st_centroid(nsw_vic), oz %>% dplyr::filter(NAME == "Victoria")), length) > 0) 11 | # plot(nsw_vic[nsw2 | vic2, ], reset = F) 12 | # plot(oz, add = T, col = "transparent") 13 | sfx <- nsw_vic[nsw2 | vic2, ] 14 | 15 | 16 | sfx <- sfx[st_coordinates(st_centroid(sfx))[,1] < 142.3, ] 17 | sf::st_write(sfx, "inst/extdata/lga_border.gpkg") 18 | 19 | -------------------------------------------------------------------------------- /data-raw/minimal-mesh.r: -------------------------------------------------------------------------------- 1 | p1 <- cbind(x = c(0, 0, 0.75, 1, 0.5, 0.8, 0.69, 0), 2 | y = c(0, 1, 1, 0.8, 0.7, 0.6, 0, 0)) 3 | p2 <- cbind(x = c(0.2, 0.2, 0.3, 0.5, 0.5, 0.2), 4 | y = c(0.2, 0.4, 0.6, 0.4, 0.2, 0.2)) 5 | p4 <- cbind(x = c(0.69, 0.8, 1.1, 1.23, 0.69), 6 | y = c(0, 0.6, 0.63, 0.3, 0)) 7 | pp <- rbind(p1, NA, p2[nrow(p2):1, ]) 8 | #plot(rbind(pp, p4), cex = 1.3, main = "two polygons, shared edge") 9 | #polypath(pp, col = "grey") 10 | #polypath(p4, col = "firebrick") 11 | 12 | library(sf) 13 | minimal_mesh <- st_sf(a = 1:2, 14 | geom = st_sfc(list(st_multipolygon(list(list(p1, p2[rev(seq(nrow(p2))), ]))), 15 | st_multipolygon(list(list(p4)))))) 16 | class(minimal_mesh$geom) <- c("sfc_MULTIPOLYGON", "sfc" , "list") 17 | #plot(x, col = c("grey", "firebrick")) 18 | usethis::use_data(minimal_mesh, overwrite = TRUE) 19 | 20 | ## this object will be removed once dodgr takes over 21 | #mmesh <- PRIMITIVE(minimal_mesh) 22 | #devtools::use_data(mmesh, overwrite = TRUE) 23 | -------------------------------------------------------------------------------- /data-raw/polymesh.R: -------------------------------------------------------------------------------- 1 | library(raster) 2 | 3 | 4 | r <- (raster(matrix(seq_len(12*15), 12)) %/% 40) * raster(matrix(seq_len(12*15), 12, byrow = TRUE)) %/% 40 5 | library(dplyr) 6 | library(sf) 7 | polymesh <- st_cast(spex::polygonize(r) %>% group_by(layer) %>% summarize(), 8 | "MULTIPOLYGON") 9 | 10 | class(polymesh$geometry) <- c("sfc_MULTIPOLYGON", "sfc" , "list") 11 | usethis::use_data(polymesh, overwrite = TRUE) 12 | 13 | 14 | 15 | # 16 | # library(dplyr) 17 | # library(silicate) 18 | # x <- PATH(polymesh) 19 | # unique_edges <- dplyr::distinct(silicate:::sc_segment_base(x$path_link_vertex), edge, .keep_all = TRUE) 20 | # vertex <- x$vertex 21 | # nodes <- silicate:::sc_node_base(unique_edges, vertex) 22 | # 23 | # arcs <- silicate:::sc_arc_base(x$path_link_vertex, nodes) 24 | # distinct(arcs, arc) 25 | # 26 | # 27 | # sarcs <- split(arcs, arcs$arc) 28 | # for (i in seq_along(sarcs)) { 29 | # plot(sf::st_cast(st_geometry(polymesh), "MULTILINESTRING"), col = "black") 30 | # lines(sarcs[[i]] %>% inner_join(x$vertex) %>% dplyr::select(x_, y_), col = "firebrick", lwd = 2) 31 | # scan("", 1) 32 | # } 33 | -------------------------------------------------------------------------------- /data-raw/routes.R: -------------------------------------------------------------------------------- 1 | library(stplanr) 2 | library(sf) 3 | routes <- routes_fast_sf[as.numeric(st_length(routes_fast_sf)) > 0, "ID"] 4 | class(routes$geometry) <- c("sfc_LINESTRING", "sfc" , "list") 5 | usethis::use_data(routes, overwrite = TRUE) 6 | -------------------------------------------------------------------------------- /data-raw/sf-data-zoo.r: -------------------------------------------------------------------------------- 1 | sf.zoo <- function() { 2 | 3 | x <- sf::st_point(c(1,2)) 4 | 5 | p <- rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)) 6 | mp <- sf::st_multipoint(p) 7 | s1 <- rbind(c(0,3),c(0,4),c(1,5),c(2,5)) 8 | ls <- sf::st_linestring(s1) 9 | s2 <- rbind(c(0.2,3), c(0.2,4), c(1,4.8), c(2,4.8)) 10 | s3 <- rbind(c(0,4.4), c(0.6,5)) 11 | mls <- sf::st_multilinestring(list(s1,s2,s3)) 12 | p1 <- rbind(c(0,0), c(1,0), c(3,2), c(2,4), c(1,4), c(0,0)) 13 | p2 <- rbind(c(1,1), c(1,2), c(2,2), c(1,1)) 14 | pol <-sf::st_polygon(list(p1,p2)) 15 | p3 <- rbind(c(3,0), c(4,0), c(4,1), c(3,1), c(3,0)) 16 | p4 <- rbind(c(3.3,0.3), c(3.8,0.3), c(3.8,0.8), c(3.3,0.8), c(3.3,0.3))[5:1,] 17 | p5 <- rbind(c(3,3), c(4,2), c(4,3), c(3,3)) 18 | mpol <- sf::st_multipolygon(list(list(p1,p2), list(p3,p4), list(p5))) 19 | #gc <- sf::st_geometrycollection(list(mp, mpol, ls)) 20 | 21 | list(point = x, multipoint = mp, linestring = ls, multilinestring = mls, polygon = pol, 22 | multipolygon = mpol) 23 | } 24 | sf.geomc <- function() { 25 | sf::st_geometrycollection(sf.zoo()) 26 | } 27 | 28 | sfzoo <- sf.zoo() 29 | sfgc <- sf.geomc() 30 | devtools::use_data(sfzoo, compress = "xz") 31 | devtools::use_data(sfgc, compress = "xz") -------------------------------------------------------------------------------- /data-raw/triangle-testbed.r: -------------------------------------------------------------------------------- 1 | library(sf) 2 | nc <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE) 3 | library(maptools); data(wrld_simpl) 4 | x <- nc #st_as_sf(wrld_simpl) 5 | ## this is internal code of primitives 6 | ## used to investigate the fastest ways to build a GC of triangles 7 | ## ANSWERE: st_polygon is slow because it does a lot of checking, we don't need any checking to make a triangle POLYGON here 8 | coords <- a.primitives:::objects_as_df(x) 9 | coords[["vertex_"]] <- as.integer(factor(paste(coords[["x"]], coords[["y"]], sep = "-"))) 10 | b_link_v <- coords[, c("path_", "vertex_")] 11 | vertices <- coords[!duplicated(b_link_v[["vertex_"]]), c("x", "y", "vertex_")] 12 | vertices <- vertices[order(vertices[["vertex_"]]), ] 13 | 14 | segments <- do.call(rbind, lapply(split(b_link_v[["vertex_"]], b_link_v[["path_"]]), 15 | function(x) a.primitives:::path_to_seg(x)) 16 | ) 17 | ## do we need to remove duplicated segments?? 18 | bad <- duplicated(cbind(pmin(segments[, 1], segments[, 2]), pmax(segments[, 1], segments[, 2]))) 19 | ps <- RTriangle::pslg(P = as.matrix(vertices[, c("x", "y")]), S = segments[!bad, ]) 20 | tr <- RTriangle::triangulate(ps) 21 | # this is slow 22 | system.time({ 23 | g <- st_sfc(lapply(split(as.vector(t(tr$T)), rep(seq_len(nrow(tr$T)), each = 3)), 24 | function(x) st_polygon(list(tr$P[c(x, x[1L]), ]))), crs = st_crs(x)) 25 | }) 26 | 27 | ## this is not slow 28 | system.time({ 29 | g <- st_sfc(lapply(split(as.vector(t(tr$T)), rep(seq_len(nrow(tr$T)), each = 3)), 30 | function(x) structure(list(tr$P[c(x, x[1L]), ]), class = c("XY", "POLYGON", "sfg"))), crs = st_crs(x)) 31 | }) 32 | 33 | 34 | -------------------------------------------------------------------------------- /data/ear_gc.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/ear_gc.rda -------------------------------------------------------------------------------- /data/flight_tracks.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/flight_tracks.rda -------------------------------------------------------------------------------- /data/inlandwaters.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/inlandwaters.rda -------------------------------------------------------------------------------- /data/minimal_mesh.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/minimal_mesh.rda -------------------------------------------------------------------------------- /data/mmesh.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/mmesh.rda -------------------------------------------------------------------------------- /data/polymesh.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/polymesh.rda -------------------------------------------------------------------------------- /data/routes.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/routes.rda -------------------------------------------------------------------------------- /data/sfgc.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/sfgc.rda -------------------------------------------------------------------------------- /data/sfzoo.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/data/sfzoo.rda -------------------------------------------------------------------------------- /inst/arcs/tg.r: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(scsf) 3 | nc <- st_read(system.file("shape/nc.shp", package="sf")) 4 | prim <- PRIMITIVE(minimal_mesh)#[c(9, 15, 24, 5, 16, 31), ]) 5 | library(scgraph) 6 | library(igraph) 7 | library(ggraph) 8 | # ig <- scgraph::sc_as_igraph(prim) 9 | # ## this is unlikely to be the right order 10 | # E(ig)$segment <- prim$segment$segment_ 11 | # 12 | # ggraph(ig) + ggraph::geom_edge_link(aes(label = segment_)) 13 | 14 | ## find vertices that are nodes 15 | nodes <- sc_node(prim) 16 | 17 | split_at <- function(x, vertex) { 18 | x$order <- seq(nrow(x)) 19 | test <- x$vertex_ %in% vertex 20 | if (!any(test)) return(list(x)) 21 | segs <- c(1, cumsum(abs(diff(test)))) 22 | split(x, segs) 23 | } 24 | library(tidyverse) 25 | arcs <- bind_rows(unlist(lapply(prim$path_link_vertex %>% split(.$path_), function(x) split_at(x, nodes$vertex_)), recursive = FALSE), .id = "arc") 26 | #arcs <- arcs %>% distinct(path_, vertex_, .keep_all = TRUE) 27 | ggplot(arcs %>% left_join(prim$vertex) %>% arrange(arc, order), 28 | aes(x_, y_, group = arc, colour = arc)) + geom_path(lwd = 3) + guides(colour = FALSE) 29 | 30 | plot(igraph::induced_subgraph(ig, nodes$vertex_) ) 31 | # ## process all paths into arcs 32 | # 33 | # all_paths <- sc_path(prim) %>% select(path_, object_) #distinct(path_) 34 | # for (ipath in seq_len(nrow(all_paths))) { 35 | # all_paths %>% slice(ipath) %>% left_join(prim$path_link_vertex) %>% inner_join(nodes) 36 | # } -------------------------------------------------------------------------------- /inst/examples/badpoly.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | bad_poly <- matrix(c(0.5, 0.5, 3 | 0.4, 5.2, 4 | 9.8, 1.1, 5 | 7.6, 8.5, 6 | 9.5, 8.0, 7 | 9.4, 6.1, 8 | 7.4, 0.7, 9 | 0.5, 0.5), ncol = 2, byrow = TRUE) %>% 10 | st_polygon(x = list(.)) %>% 11 | st_sfc() %>% 12 | st_sf() 13 | ## add nodes and re-polygonize 14 | x <- st_cast(bad_poly, "MULTILINESTRING") %>% 15 | st_node() %>% 16 | st_polygonize() 17 | st_set_geometry(x, st_sfc(purrr::map(x$geometry, st_multipolygon))) 18 | 19 | 20 | ## doh 21 | plot(st_buffer(bad_poly, dist = 0)) 22 | 23 | library(sfdct) 24 | plot(st_buffer(ct_triangulate(bad_poly), dist = .5)) 25 | 26 | -------------------------------------------------------------------------------- /inst/examples/edge_norm/edge_norm.R: -------------------------------------------------------------------------------- 1 | 2 | library(silicate) 3 | library(raster) 4 | library(sf) 5 | 6 | ## need quadmesh >= 0.2.0.9002 for https://github.com/hypertidy/quadmesh/issues/18 7 | g <- SC0(sf::st_cast(spex::polygonize(raster(matrix(1:12, 3))), "LINESTRING")) 8 | 9 | l2 <- SC0(SpatialLines(list(Lines(list(Line(list(rbind(c(0.2, 0.2), c(0.5, 0.5), c(0.6, 0.8), c(0.9, 0.9), c(0.2, 0.3), c(0, 0))))), "1")))) 10 | plot(g) 11 | plot(l2, add = TRUE, col = 1:5) 12 | #plot(c(l2, g)) 13 | all_list <- list(l2, g) 14 | # - collate all end point indices and vertices 15 | all_edge <- purrr::map(all_list, 16 | ~dplyr::bind_rows(tidyr::unnest(.x$object["topology_"]), .id = "object")) 17 | # - increment end points by merge-logic (+cumul row count) 18 | for (i in seq_along(all_edge)) { 19 | if (i > 1) all_edge[[i]] <- all_edge[[i]] %>% dplyr::mutate_if(is.numeric, dplyr::funs(. + nrow(all_edge[[i - 1]]))) 20 | } 21 | 22 | edge <- dplyr::bind_rows(all_edge, .id = "input_layer") 23 | # - de-duplicate vertices 24 | dvert <- purrr::map_df(all_list, ~.x$vertex) %>% unjoin::unjoin("x_", "y_") 25 | 26 | # - map new end point indices 27 | -------------------------------------------------------------------------------- /inst/examples/filter_path.R: -------------------------------------------------------------------------------- 1 | # select.PATH <- function(x, ...) { 2 | # x$object <- dpylr::select(x$object, ...) 3 | # x 4 | # } 5 | 6 | filter.PATH <- function(x, ...) { 7 | x$object <- dplyr::filter(x$object, ...) 8 | anglr:::semi_cascade(x, tables = c("object", "path", "path_link_vertex", "vertex")) 9 | } 10 | filter.PATH(p, AREA > 0.124) 11 | library(ggplot2) 12 | library(dplyr) 13 | plot.PATH <- function(x, ...) { 14 | ggplot(purrr::reduce(x[c("object", "path", "path_link_vertex", "vertex")], inner_join)) + 15 | geom_polygon(aes(x_, y_, fill = object_, group = path_)) + guides(colour = FALSE, fill = FALSE) 16 | } 17 | plot(filter(g, PERIMETER > 1.5)) 18 | 19 | 20 | library(dplyr) 21 | read_shp <- function(pattern, ext = NULL) { 22 | out <- sf::read_sf(raadfiles::thelist_files(format = "shp", pattern = pattern) %>% 23 | pull(fullname)) #%>% silicate::PATH() 24 | if (!is.null(ext)) { 25 | out <- st_intersection(out, ext) 26 | } 27 | out 28 | } 29 | #ex <- drawExtent() 30 | ex <- st_as_sf(as(ex, "SpatialPolygons")) 31 | st_crs(ex) <- st_crs("+proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs") 32 | parcels <- read_shp("parcels_hobart", ex) 33 | contours <- read_shp("5m_contours_hobart", ex) 34 | 35 | parcels <- st_cast(parcels, "MULTIPOLYGON") 36 | library(anglr) 37 | a <- anglr(parcels, z = "MEAS_AREA") 38 | b <- anglr(contours, z = "ELEVATION") 39 | 40 | -------------------------------------------------------------------------------- /inst/examples/goals-short.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ## silicate 3 | 4 | The goals of silicate can be summed up by asking what is the right way to think about these two polygons: 5 | 6 | 7 | ```{r polygons, include=FALSE} 8 | plot(minimal_mesh$geom, col = c("dodgerblue", "firebrick")) 9 | ``` 10 | Are there 11 | 12 | * two partitions of the plane, differentiated by colour? 13 | * three linear sequences of coordinates (paths) with a rule about nesting inside and out? 14 | * fifteen linear segments? 15 | * fourteen triangles? 16 | * three shared boundaries? 17 | 18 | The answer is all of the above! The PATH model knows about three linear sequences of coordinates. 19 | 20 | ```{r PATH} 21 | (p <- PATH(minimal_mesh)) 22 | plot(p, col = viridis::viridis(2)) 23 | ``` 24 | 25 | The SC model knows about the segments. 26 | 27 | ```{r SC} 28 | (sc <- SC(minimal_mesh)) 29 | plot(sc, col = viridis::viridis(15)) 30 | ``` 31 | 32 | The TRI model knows about the triangles. 33 | 34 | ```{r TRI} 35 | (tri <- TRI(minimal_mesh)) 36 | plot(tri, col = viridis::viridis(14)) 37 | ``` 38 | 39 | Finally, the ARC model knows about the shared boundaries, although only in 40 | this special case of neighbouring triangles. 41 | 42 | ```{r ARC} 43 | 44 | ``` 45 | -------------------------------------------------------------------------------- /inst/examples/graph_segment.R: -------------------------------------------------------------------------------- 1 | columbus <- rgdal::readOGR(system.file("etc/shapes/columbus.shp", 2 | package="spdep")) 3 | rook <- spdep::poly2nb(columbus, queen = FALSE) 4 | 5 | prim <- silicate::PRIMITIVE(columbus) 6 | library(tidyverse) 7 | prim$segment %>% select(path, segment_) %>% 8 | inner_join(prim$path) %>% select(segment_, object) %>% 9 | group_by(segment_) 10 | 11 | 12 | x <- PATH(columbus) 13 | sc_primitive(x) 14 | all_coordinates <- function(vertex, path_link_vertex) { 15 | dplyr::inner_join(path_link_vertex, vertex, "vertex_") 16 | } 17 | graph_segments <- function(x, ...) { 18 | ## assume this is the path_segments .vertex0, .vertex1, path, segment_ 19 | ## so we need another table to link segment to path 20 | 21 | } 22 | segment_split_path <- function(allcoords) { 23 | dplyr::bind_rows(lapply(split(allcoords, allcoords$path), 24 | function(x) path_to_segment(x$vertex_, x$path[1L]))) 25 | } 26 | path_segments <- function(x, ...) { 27 | allcoords <- all_coordinates(x$vertex, x$path_link_vertex) 28 | ## what if we had points 29 | if (nrow(x$path_link_vertex) == nrow(distinct_(x$path_link_vertex, "path"))) { 30 | return(dplyr::transmute_(allcoords, .vertex0 = quote(vertex_), path = quote("path"))) 31 | } 32 | ## this is a subset of RTriangle::pslg (because the original target was RTriangle::triangulate) 33 | #pstraight_lgraph <- list(P = as.matrix(v[, c("x_", "y_")]), 34 | ## only need S for 1D 35 | segment_pairs <- segment_split_path(allcoords) 36 | segment_pairs[["segment_"]] <- sc_uid(n = nrow(segment_pairs)) 37 | segment_pairs 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /inst/examples/grouped_polygonize/line_to_poly.R: -------------------------------------------------------------------------------- 1 | ## four polygon rings, two islands 2 | ## (copy the first island translated to give ) 3 | a1 <- cbind(c(-1, -1, 1, 1, -1), 4 | c(-1, 1, 1, -1, -1)) 5 | h1 <- cbind(c(-0.5, -0.5, 0, -0.5), 6 | c(0, -0.5, -0.5, 0)) 7 | h2 <- h1 + 0.6 8 | a3 <- a1 + 6 9 | library(sf) 10 | ## this is the "target" 11 | #mpol <- st_multipolygon(list(list(a1, h1, h2), 12 | # list(a1 + 3, h1 + 3, h2 + 3), 13 | # list(a3))) 14 | 15 | # 16 | mlin <- st_multilinestring(list(a1, h1, h2, 17 | a1 + 3, h1 + 3, h2 + 3, 18 | a3)) 19 | g <- st_polygonize(mlin) 20 | 21 | ## see how h1 and h2 are present as both holes and islands 22 | # GEOMETRYCOLLECTION ( 23 | # POLYGON ((-1 -1, -1 1, 1 1, 1 -1, -1 -1), 24 | # (-0.5 0, -0.5 -0.5, 0 -0.5, -0.5 0), 25 | # (0.1 0.6, 0.1 0.1, 0.6 0.1, 0.1 0.6)), 26 | # POLYGON ((-0.5 0, 0 -0.5, -0.5 -0.5, -0.5 0)), 27 | # POLYGON ((0.1 0.6, 0.6 0.1, 0.1 0.1, 0.1 0.6)), 28 | ## and see how the pattern is clear, we simply get the holes as fill 29 | # POLYGON ((2 2, 2 4, 4 4, 4 2, 2 2), 30 | # (2.5 3, 2.5 2.5, 3 2.5, 2.5 3), 31 | # (3.1 3.6, 3.1 3.1, 3.6 3.1, 3.1 3.6)), 32 | # POLYGON ((2.5 3, 3 2.5, 2.5 2.5, 2.5 3)), 33 | # POLYGON ((3.1 3.6, 3.6 3.1, 3.1 3.1, 3.1 3.6)), 34 | # POLYGON ((5 5, 5 7, 7 7, 7 5, 5 5))) 35 | 36 | library(dplyr) 37 | gpolygon <- lapply(g, function(x) st_polygon(x)) 38 | gatomic <- unlist(gpolygon, recursive = FALSE) 39 | 40 | ## ALL THIS WORK is pointless, we have inferred the policy 41 | ## of the GC returned from GEOS, it should just be explicit 42 | ## so we have some clarity from that lib 43 | 44 | ## make a map of where we are going 45 | gmap <- gibble::gibble(gpolygon) %>% 46 | group_by(object) %>% 47 | mutate(hole = cumsum(subobject) > 1) %>% ungroup() %>% 48 | mutate(id = "") 49 | ## loop over paths, digest in assumed clockwise order 50 | for (i in seq_len(nrow(gmap))) { 51 | mat <- gatomic[[i]] 52 | ## pretty sure GEOS will reliably return holes reversed compared to islands 53 | if (gmap$hole[i]) mat <- mat[rev(seq_len(nrow(mat))), ] 54 | gmap$id[[i]] <- digest::digest(mat) 55 | } 56 | ## gmap where not-hole, but duplicate is to be removed 57 | bad <- (!gmap$hole) & duplicated(gmap$id) 58 | if (any(bad)) gpolygon <- gpolygon[-which(bad[!gmap$hole])] 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /inst/examples/inner_edges.R: -------------------------------------------------------------------------------- 1 | ## topology for simple features 2 | ## - must be added in 3 | ## - is ever needed 4 | 5 | ## rmapshaper has a very specific function to get the "inner lines" of a 6 | ## polygon mesh, but it's just the geometry no identity of which object 7 | ## or part its from 8 | library(sf) 9 | xsf <- sf::read_sf(system.file("shape/nc.shp", package="sf")) 10 | ib <- rmapshaper::ms_innerlines(xsf) 11 | 12 | plot(ib, col = sample(viridis::viridis(length(ib)))) 13 | 14 | ## here we use the silicate PATH model and the new functions sc_segment 15 | ## with its edge classification to reconstruct an sf object where all 16 | ## individual line segments know their parent/s from the PATH model 17 | system.time({ 18 | 19 | library(tidyr) 20 | library(silicate) 21 | path <- PATH(xsf) 22 | library(dplyr) 23 | ## arcs are all rings, not just shared 24 | #arc <- sc_arc(path) 25 | ## segments are all instances, classified by edge groups 26 | ## and these are what we want 27 | segs <- sc_segment(path) %>% 28 | group_by(edge_) %>% mutate(n_edge = n()) %>% 29 | dplyr::filter(n_edge > 1) %>% ungroup() 30 | segs 31 | ## we only want to draw them once, but knowing which of two paths we belong to 32 | ## is key 33 | shared <- segs %>% select(path_, edge_) %>% 34 | group_by(edge_) %>% 35 | mutate(i = sprintf("path%i", row_number())) %>% spread(i, path_) 36 | 37 | build_sf_from_path <- function(x) { 38 | g <- tibble::tibble(vertex_ = unlist(x[c(".vertex0", ".vertex1")])) %>% 39 | inner_join(path$vertex, "vertex_") %>% dplyr::select(x_, y_) %>% as.matrix() %>% sf::st_linestring() 40 | sf::st_sf(edge = x$edge_, path1 = x$path1, path2 = x$path2, geometry = st_sfc(g)) 41 | } 42 | }) 43 | 44 | ## reconstruct the inner edges 45 | d <- do.call(rbind, shared %>% inner_join(segs, "edge_") %>% 46 | purrr::transpose() %>% purrr::map(build_sf_from_path)) 47 | 48 | ## consider now that we know path1 and path2 for every edge, but they don't 49 | ## necessarily identify closed rings (since there are two choices for that) 50 | library(ggplot2) 51 | st_crs(d) <- st_crs(xsf) 52 | ggplot(d) + geom_sf(aes(colour = path1)) + coord_sf(datum = NA) + guides(colour = FALSE) 53 | ggplot(d) + geom_sf(aes(colour = path2)) + coord_sf(datum = NA) + guides(colour = FALSE) 54 | 55 | ## a second plot with the original boundaries first, because it looks neat 56 | ggplot(xsf) + geom_sf() + geom_sf(data = d, aes(colour = path1)) + coord_sf(datum = NA) + guides(colour = FALSE) 57 | 58 | 59 | -------------------------------------------------------------------------------- /inst/examples/leaflet-normalize.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | example(st_read) 3 | library(silicate) 4 | to_leaflet <- function(x, ...) { 5 | coord <- sc_coord(x) 6 | path <- sc_path(x) 7 | object <- sc_object(x) 8 | object$object_ <- unique(path$object) 9 | glist <- vector("list", length(unique(object$object_))) 10 | ind <- rep(seq_len(nrow(path)), path$ncoords_) 11 | coords_in <- path %>% dplyr::select(-type, -ncol) %>% 12 | dplyr::slice(ind) %>% dplyr::bind_cols(coord) 13 | ufeature <- object$object_ 14 | 15 | for (ifeature in seq_along(ufeature)) { 16 | gm0 <- path %>% dplyr::filter(object == ufeature[ifeature]) 17 | type <- gm0$type[1] 18 | coord0 <- coords_in %>% dplyr::filter(object == ufeature[ifeature]) 19 | ## object becomes sub-feature element (not a hole, that is "part") 20 | coord0$object <- rep(seq_len(nrow(gm0)), gm0$ncoords_) 21 | glist[[ifeature]] <- switch(type, 22 | POINT = as.list(coord0 %>% dplyr::transmute(lat = y_, lng = x_)), 23 | MULTIPOINT = as.list(coord0 %>% dplyr::transmute(lat = y_, lng = x_)), 24 | LINESTRING = as.list(coord0 %>% dplyr::transmute(lat = y_, lng = x_)), 25 | MULTILINESTRING = lapply(split(coord0 %>% dplyr::transmute(lat = y_, lng = x_), coord0$object), as.list), 26 | POLYGON = lapply(split(coord0 %>% dplyr::transmute(lat = y_, lng = x_), coord0$object), as.list), 27 | MULTIPOLYGON = lapply(split(coord0 %>% dplyr::select(x_, y_, subobject), coord0$object), 28 | function(subobject) lapply(split(subobject %>% 29 | dplyr::transmute(lat = y_, lng = x_), subobject$subobject), as.list))) 30 | } 31 | glist 32 | } 33 | 34 | -------------------------------------------------------------------------------- /inst/examples/osmdata/doc.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/examples/osmdata/doc.rds -------------------------------------------------------------------------------- /inst/examples/osmdata/read_pbf.R: -------------------------------------------------------------------------------- 1 | td <- "~" 2 | u = "http://download.geofabrik.de/europe/albania-latest.osm.pbf" 3 | f <- normalizePath(file.path(td, basename(u))) 4 | #download.file(u, f, mode = "wb") 5 | x <- vapour::vapour_read_geometry(f, 4) 6 | #f <- list.files(basename(tempdir()), recursive = TRUE, pattern = "pbf$") 7 | read_pbf_geometry <- function(file) { 8 | layers <- sf::st_layers(file)$name 9 | setNames(purrr::map(layers, 10 | ~sf::read_sf(file, .x)), layers) 11 | } 12 | x <- read_pbf_geometry(f) 13 | 14 | purrr::map_int(x, nrow) 15 | purrr::map_int(x, ncol) 16 | 17 | 18 | 19 | download.file(u, f, mode = "wb") 20 | msg = "osmconvert albania.osh.pbf >albania.osm") 21 | system(msg) 22 | osmdata_xml(input_file = "albania.osh.pbf", filename = "albania.osm") 23 | q = add_feature(opq("Albania"), "highway") 24 | albanian_roads = osmdata_sf(q, doc = "albania.osm") -------------------------------------------------------------------------------- /inst/examples/osmdata/rsconnect/documents/readosm.R/rpubs.com/rpubs/Document.dcf: -------------------------------------------------------------------------------- 1 | name: Document 2 | title: 3 | username: 4 | account: rpubs 5 | server: rpubs.com 6 | hostUrl: rpubs.com 7 | appId: https://api.rpubs.com/api/v1/document/309493/468af06b9fe24fcc8be6f0ff516804e0 8 | bundleId: https://api.rpubs.com/api/v1/document/309493/468af06b9fe24fcc8be6f0ff516804e0 9 | url: http://rpubs.com/publish/claim/309493/41c6a41844d74ed8b10fef043fe31ff0 10 | when: 1505800207.4105 11 | -------------------------------------------------------------------------------- /inst/examples/sf-segments-plot.R: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(dplyr) 3 | library(p5) 4 | library(silicate) 5 | f <- raadfiles::thelist_files(format = "shp", pattern = "transport_segments") 6 | x <- do.call(rbind, purrr::map(f$fullname, sf::read_sf)) 7 | #edge <- silicate::SC(x) 8 | system.time({ 9 | coord <- sc_coord(x) 10 | path <- sc_path(x) 11 | path_index <- rep(seq_len(nrow(path)), path$ncoords_) 12 | p2s <- function(x) cbind(head(x, -1L), tail(x, -1L)) 13 | segs <- do.call(rbind, lapply(split(seq_len(nrow(coord)), path_index), 14 | p2s)) 15 | 16 | xy1 <- coord[segs[,1], ] %>% 17 | transmute(x = x_, y = y_) %>% scaler(nr, nc) 18 | xy2 <- coord[segs[,2], ] %>% 19 | transmute(x = x_, y = y_) %>% scaler(nr, nc) 20 | }) 21 | nr <- 350 22 | nc <- 350 23 | exag_fact = 1 24 | plot(range(c(xy1$x, xy2$x)), range(c(xy1$y, xy2$y))) 25 | system.time(segments(xy1$x, xy1$y, xy2$x, xy2$y)) 26 | 27 | dim(xy1) 28 | pryr::object_size(list(xy1, xy2)) 29 | #p5() %>% createCanvas(nr * exag_fact, nc * exag_fact, renderer = NULL) %>% 30 | # line(x1 = segs[,1], y1 = segs[,3], x2 = segs[,2], y2 = segs[,4]) 31 | 32 | 33 | -------------------------------------------------------------------------------- /inst/examples/simplefy.R: -------------------------------------------------------------------------------- 1 | # Let's have a crack at topological simplification. 2 | 3 | library(silicate) 4 | library(sf) 5 | x <- inlandwaters[c(3, 6), ] 6 | plot(x[1]) 7 | 8 | sc_arc(x) 9 | 10 | remove_pc <- function(x, pc = 0.5) { 11 | ## keep the first and last 12 | idx <- seq(2, nrow(x) - 1) 13 | if (nrow(x) == 2) return(x) 14 | idx <- seq(2, nrow(x) - 1, length = nrow(x) * pc) 15 | x[c(1, idx, nrow(x)), ] 16 | } 17 | 18 | approx_pc <- function(x, pc = 0.1) { 19 | ii <- seq_len(nrow(x)) 20 | xf <- approxfun(ii, x$x_) 21 | yf <- approxfun(ii, x$y_) 22 | idx <- seq(1, nrow(x), length = nrow(x) * pc) 23 | tibble::tibble(x_ = xf(idx), y_ = yf(idx)) 24 | } 25 | 26 | length_weight_pc <- function(x, pc = 0.1) { 27 | lengs <- sp::spDists(as.matrix(x), segment = TRUE) 28 | ord <- rev(order(lengs[-c(1, length(lengs))])) + 1 29 | minlen <- 3 30 | len <- length(lengs) * pc 31 | idx <- c(1, sort(ord[seq_len(pmax(minlen, len))]), length(lengs)) 32 | x[idx, ] 33 | } 34 | a_rea <- function(x) { 35 | (x[1, 1] - x[2, 1])^2 * (x[1, 2] - x[2, 2])^2 36 | } 37 | eff_area <- function(x) { 38 | unlist(lapply(split(as.vector(t(head(matrix(seq_len(nrow(x) - 1), nrow(x), 3), -3))), 39 | rep(1:(nrow(x)-3), each= 3)), 40 | function(a) a_rea(x[a, ])/2)) 41 | } 42 | vis <- function(x, pc = 0.1) { 43 | area <- eff_area(as.matrix(x)) 44 | ord <- order(area) 45 | ord <- ord[ord > (pc *nrow(x))] 46 | x[ord] 47 | } 48 | ## we also need to rebuild from arcs 49 | arc_sf <- function(arc, v, pc = 0.1) { 50 | if (!pc > 0) stop("pc must be > 0 (and < 1)") 51 | if (!pc < 1) stop("pc must be < 1 (and > 0)") 52 | sf::st_sfc( arc %>% split(.$arc_) %>% 53 | purrr::map(~inner_join(.x, v, "vertex_") %>% 54 | dplyr::select(x_, y_) %>% 55 | # remove_pc(pc = pc) %>% 56 | #length_weight_pc(pc = pc) %>% 57 | vis(pc = pc) %>% 58 | as.matrix() %>% 59 | sf::st_linestring()) 60 | ) 61 | } 62 | example(st_read) 63 | x <- nc 64 | x <- inlandwaters 65 | p <- PATH(x) 66 | 67 | ## original line string 68 | lstr <- st_cast(st_geometry(x), "MULTILINESTRING") 69 | ## simplified line string 70 | slstr <- arc_sf(sc_arc(p), p$v, pc = 0.5) 71 | st_crs(slstr) <- st_crs(lstr) 72 | plot(slstr, col = viridis::viridis(20)) 73 | pryr::object_size(lstr) 74 | pryr::object_size(slstr) 75 | -------------------------------------------------------------------------------- /inst/examples/stateUS.R: -------------------------------------------------------------------------------- 1 | library(rgdal) 2 | library(rgeos) 3 | library(igraph) 4 | 5 | # Read states layer from a GeoJSON file 6 | #url = "https://raw.githubusercontent.com/alignedleft/d3-book/master/chapter_12/us-states.json" 7 | url <- "https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json" 8 | #download.file(url, basename(url), mode = "wb") 9 | state = readOGR( 10 | dsn = url, 11 | layer = "us-states", 12 | stringsAsFactors = FALSE, 13 | verbose = FALSE 14 | ) 15 | 16 | # Transform to US-Atlas projection 17 | state = spTransform( 18 | state, 19 | "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs" 20 | ) 21 | 22 | # Assign state names to 'row.names' 23 | row.names(state) = state$name 24 | -------------------------------------------------------------------------------- /inst/extdata/file.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { "type": "Feature", "properties": { "a": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 0.75, 1.0 ], [ 1.0, 0.8 ], [ 0.5, 0.7 ], [ 0.8, 0.6 ], [ 0.69, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.2, 0.2 ], [ 0.5, 0.2 ], [ 0.5, 0.4 ], [ 0.3, 0.6 ], [ 0.2, 0.4 ], [ 0.2, 0.2 ] ] ] ] } }, 5 | { "type": "Feature", "properties": { "a": 2 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.69, 0.0 ], [ 0.8, 0.6 ], [ 1.1, 0.63 ], [ 1.23, 0.3 ], [ 0.69, 0.0 ] ] ] ] } } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /inst/extdata/flight_tracks/flight_tracks.R: -------------------------------------------------------------------------------- 1 | #from https://github.com/r-spatial/mapview/issues/99#issuecomment-328711275 2 | 3 | #> Attached is a zipped shapefile containing 144 flight tracks of aircraft #departing runway 4 | #> 33L at Boston Logan airport on June 28, 2017. Data is from an ADS-B recorder so it is 5 | #> kind of rough. Each point includes lat, lon, altitude in feet and time in EDT. #Unzip and 6 | #> read > with 7 | #> st_read('tracks.shp') 8 | #> 9 | 10 | #saved as inst/exdata/flight_tracks/tracks.shp/prj/dbf/shx 11 | 12 | -------------------------------------------------------------------------------- /inst/extdata/flight_tracks/tracks.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/extdata/flight_tracks/tracks.dbf -------------------------------------------------------------------------------- /inst/extdata/flight_tracks/tracks.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /inst/extdata/flight_tracks/tracks.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/extdata/flight_tracks/tracks.shp -------------------------------------------------------------------------------- /inst/extdata/flight_tracks/tracks.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/extdata/flight_tracks/tracks.shx -------------------------------------------------------------------------------- /inst/extdata/lga_border.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/extdata/lga_border.gpkg -------------------------------------------------------------------------------- /inst/misc/ARC-data.R: -------------------------------------------------------------------------------- 1 | v <- sf::read_sf(raadfiles::thelist_files(pattern = "transport_segments_hobart")$fullname[1]) 2 | 3 | library(silicate) 4 | n <- 2697 5 | sfx <- v[sort(unique(c(n, unlist(sf::st_touches(sf::st_geometry(v)[n], sf::st_geometry(v)))))), ] 6 | 7 | sfy <- spex::polygonize(raster::raster(matrix(1:2, ncol = 2))) 8 | 9 | library(sf) 10 | sc <- SC0(sfx) 11 | plot(sc, col = rgb(0, 0, 0, 0.5), lwd = 15, asp = 1) 12 | plot(sfx[1], lwd = 3, reset = FALSE) 13 | text(sc$vertex, lab = 1:nrow(sc$vertex), pos = 1:4, cex = 0.8, offset = 0.3) 14 | 15 | 16 | 17 | ## on creation, SC0 has all edge instances in the order they occur 18 | sc$object$object_ <- seq_len(nrow(sc$object)) 19 | edge <- tidyr::unnest(sc$object[c("object_", "topology_")]) 20 | 21 | 22 | v_0 <- pmin(edge$.vx0, edge$.vx1) 23 | v_1 <- pmax(edge$.vx0, edge$.vx1) 24 | edge$native_ <- v_0 == edge$.vx0 ## if TRUE the orientation is how it came in 25 | 26 | uedge <- edge 27 | ## we now have ordered edges 28 | uedge[[".uvx0"]] <- v_0 29 | uedge[[".uvx1"]] <- v_1 30 | 31 | uedge[["u_edge"]] <- dplyr::group_indices(dplyr::group_by(uedge, ".uvx0", ".uvx1")) 32 | 33 | 34 | uedge %>% group_by(.uvx0, .uvx1) %>% tally() %>% print(n = Inf) 35 | ## nodes that occur twice or more 36 | shared_verts <- uedge$.uvx0[which(!match(uedge$.uvx1, uedge$.uvx0) == (seq_len(nrow(uedge)) - 1))] 37 | 38 | 39 | ## nodes that occur only once (for lines) 40 | terminal_verts <- tibble::tibble(vertex_ = as.vector(t(as.matrix(edge[c(".vx0", ".vx1")])))) %>% 41 | dplyr::count("vertex_") %>% dplyr::filter(n == 1) %>% dplyr::pull("vertex_") 42 | 43 | plot(sfx[1], lwd = c(10, 2), reset = FALSE) 44 | if (length(shared_verts) > 0) points(sc$vertex[shared_verts, c("x_", "y_")], col = "red", cex = 1.5) 45 | if (length(terminal_verts) > 0) points(sc$vertex[terminal_verts, c("x_", "y_")], col = "green", cex = 1, pch = 19) 46 | 47 | points(sc$vertex[c("x_", "y_")], pch = sample(1:23), cex = c(1:3)) 48 | -------------------------------------------------------------------------------- /inst/misc/geospatialsci-2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/inst/misc/geospatialsci-2018.pdf -------------------------------------------------------------------------------- /inst/misc/makefile: -------------------------------------------------------------------------------- 1 | FILE=geospatialsci-2018 2 | TEMPLATE=template 3 | PREFLAGS=--variable geometry="margin=2.54cm" \ 4 | --variable linestretch=1.6 \ 5 | --variable mainfont="Times New Roman" 6 | POSTFLAGS= 7 | 8 | all: pdf 9 | 10 | pdf: $(FILE).md 11 | pandoc -s $(PREFLAGS) $(FILE).md -o $(FILE).pdf $(POSTFAGS) 12 | 13 | open: $(FILE).pdf 14 | xdg-open $(FILE).pdf & 15 | -------------------------------------------------------------------------------- /inst/misc/validity.R: -------------------------------------------------------------------------------- 1 | tri_fix <- function(x) { 2 | sf::st_cast(sfdct::ct_triangulate(x)) %>% sf::st_is_valid() 3 | } 4 | 5 | sil_fix <- function(x) { 6 | sc <- silicate::SC(x) 7 | seg <- silicate::sc_segment(x) 8 | 9 | } 10 | #A 'bowtie' polygon: 11 | 12 | bowtie <- "POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))" 13 | x <- sf::st_as_sfc(bowtie) 14 | sf::st_is_valid(x) 15 | tri_fix(x) 16 | 17 | #' Square with wrong orientation: 18 | 19 | sq_wo <- "POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))" 20 | x <- sf::st_as_sfc(sq_wo) 21 | sf::st_is_valid(x) 22 | tri_fix(x) 23 | 24 | #' Inner ring with one edge sharing part of an edge of the outer ring: 25 | ir_share <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 2,5 7,10 7, 10 2, 5 2))" 26 | x <- sf::st_as_sfc(ir_share) 27 | sf::st_is_valid(x) 28 | tri_fix(x) 29 | 30 | 31 | #' Dangling edge: 32 | 33 | de <- "POLYGON((0 0, 10 0, 15 5, 10 0, 10 10, 0 10, 0 0))" 34 | x <- sf::st_as_sfc(de) 35 | sf::st_is_valid(x) 36 | tri_fix(x) 37 | 38 | #' Outer ring not closed: 39 | 40 | ornc <- "POLYGON((0 0, 10 0, 10 10, 0 10))" 41 | x <- sf::st_as_sfc(ornc) 42 | sf::st_is_valid(x) 43 | tri_fix(x) 44 | 45 | ## sfdct currently can't fix this one, but 46 | sc <- silicate::SC(x) 47 | 48 | p <- RTriangle::pslg(S = matrix(match(as.matrix(sc$edge %>% dplyr::select(.vertex0, .vertex1)), sc$vertex$vertex_), ncol = 2), 49 | P = as.matrix(sc$vertex %>% dplyr::select(x_, y_))) 50 | tr <- RTriangle::triangulate(p, a = 1) 51 | purrr::transpose(sc$edge) %>% 52 | purrr::map(~tibble::tibble(vertex_ = unlist(.x[c(".vertex0", ".vertex1")])) %>% 53 | dplyr::inner_join(sc$vertex)) 54 | 55 | #Two adjacent inner rings: 56 | 57 | tr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 8, 3 8, 3 1, 1 1), (3 1, 3 8, 5 8, 5 1, 3 1))" 58 | x <- sf::st_as_sfc(tr) 59 | sf::st_is_valid(x) 60 | tri_fix(x) 61 | 62 | #Polygon with an inner ring inside another inner ring: 63 | 64 | pr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (2 8, 5 8, 5 2, 2 2, 2 8), (3 3, 4 3, 3 4, 3 3))" 65 | x <- sf::st_as_sfc(pr) 66 | sf::st_is_valid(x) 67 | tri_fix(x) 68 | 69 | -------------------------------------------------------------------------------- /inst/primitives/explore_primitives.R: -------------------------------------------------------------------------------- 1 | # I think we should use nested data frames, as an analogue to sf but that is 2 | # able to utilize the tidyr nest/unnest facilities. It's also a straightforward 3 | # switch from data.frame to list for leaflet and so on. It makes no sense to me 4 | # that POINT is a vector, that only causes problems and requires exceptional 5 | # handling compared to all other cases. But sf is not designed for developers, 6 | # it's designed. I wish we had an agreed central standard for hierarchical data, 7 | # but there seems to be no appetite for it. It will come to us from the 8 | # tidyverse with separated tables that allow linking between structures, without 9 | # needlessly copying repeated elements. 10 | # 11 | # I plan to write these sf-geometry analogues, since then it's a simple step to 12 | # the tidyverse nested ways. Turning nested dataframes inside out also provides 13 | 14 | library(sf) 15 | library(scsf) 16 | x <- minimal_mesh 17 | ## sc_coord and sc_path are bound together 18 | ## coord is all instances of vertices 19 | ## each path row has the vertex count, effectively an sequential index into coord 20 | sc_coord(x) 21 | sc_path(x) 22 | 23 | ## sp, sf, spatstat objects are PATHs 24 | 25 | ## icosa, rgl, deldir, RTriangle, objects are not PATHs 26 | 27 | # the pathway to PATH is 28 | 29 | GENERAL: 30 | sc_object(x) 31 | sc_path(x, ids= ) 32 | sc_coord(x) 33 | 34 | PRIM-1D: find cycles, express as winded paths 35 | 36 | ## the pathway to PRIMITIVE is 37 | 38 | PATH: create segments/edges 39 | 40 | PRIM-1D: create PRIM-2D 41 | 42 | mesh: express as PRIM-1D (hexagons, segments, quads, triangulations) 43 | 44 | 45 | sc_segment are the PRIM-1D elements 46 | sc_vertex the unique vertices 47 | 48 | 49 | segment and/or edge need to differentiate oriented and non-oriented 50 | 51 | 52 | 53 | library(icosa) 54 | x <- trigrid() 55 | 56 | sc_segment <- function(x, ...) { 57 | UseMethod("sc_segment") 58 | } 59 | sc_segment.trigrid <- function(x, ...) { 60 | ## these are non-oriented 61 | setNames(tibble::as_tibble(x@edges), c(".vertex0", ".vertex1")) 62 | } 63 | sc_vertex <- function(x, ...) { 64 | UseMethod("sc_vertex") 65 | } 66 | sc_vertex.trigrid <- function(x, ...) { 67 | vids <- rownames(x@vertices) 68 | dplyr::mutate(setNames(tibble::as_tibble(x@vertices), c("x_", "y_", "z_")), vertex_ = vids) 69 | } 70 | sc_segment(x) 71 | sc_vertex(x) 72 | 73 | PRIMITIVE.trigrid <- function(x, ...) { 74 | 75 | } 76 | plot3d(x) 77 | -------------------------------------------------------------------------------- /man/ARC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ARC-model.R 3 | \name{ARC} 4 | \alias{ARC} 5 | \alias{ARC.default} 6 | \alias{ARC.PATH} 7 | \title{ARC model} 8 | \usage{ 9 | ARC(x, ...) 10 | 11 | \method{ARC}{default}(x, ...) 12 | 13 | \method{ARC}{PATH}(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{input model} 17 | 18 | \item{...}{arguments passed to methods} 19 | } 20 | \value{ 21 | ARC model 22 | } 23 | \description{ 24 | Arcs are unique paths that connect nodes. In a polygon layer with shared boundaries, the 25 | arcs are the linear features that have no branches. 26 | } 27 | \details{ 28 | Nodes are the vertices where three or more arcs meet. An arc can exist without including 29 | any nodes, a path that has no neighbouring relationship with another path. 30 | 31 | This is \emph{not} the same terminology as used by other systems, such as "arc-node". The 32 | \code{arc_link_vertex} mapping is inherently ordered, but we don't consider order of arcs. 33 | Duplicated arcs (i.e. complementary turns around neighbouring polygons) are not kept. 34 | The \code{object_link_arc} mapping records which arc belongs to the objects, so feature polygons 35 | can in theory be reconstructed within objects by tracing \code{arc_link_vertex} start and end point 36 | identity. 37 | } 38 | \examples{ 39 | a <- ARC(minimal_mesh) 40 | sc_arc(a) 41 | sc_arc(minimal_mesh) 42 | } 43 | -------------------------------------------------------------------------------- /man/PATH.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/PATH-model.R 3 | \name{PATH} 4 | \alias{PATH} 5 | \alias{PATH.SC} 6 | \alias{PATH.TRI} 7 | \alias{PATH.default} 8 | \title{PATH model.} 9 | \usage{ 10 | PATH(x, ...) 11 | 12 | \method{PATH}{SC}(x, ...) 13 | 14 | \method{PATH}{TRI}(x, ...) 15 | 16 | \method{PATH}{default}(x, ...) 17 | } 18 | \arguments{ 19 | \item{x}{input model} 20 | 21 | \item{...}{arguments passed to methods} 22 | } 23 | \value{ 24 | a PATH model, with tables 'object', 'path', 'path_link_vertex' and 'vertex' 25 | } 26 | \description{ 27 | A PATH model is a direct translation of a simple features-alike 28 | object to normal form. This is four tables with the three kinds of entities, 29 | "objects" (or "features"), "paths" (or "parts") and "vertices", and a table 30 | to link the one-to-many relation between paths and vertices. 31 | } 32 | \details{ 33 | In a data set with no parts touching their neighbours, the only normalization of the vertices 34 | will be the removal of the duplicated closing coordinate on any polygon ring, and on 35 | any self-intersecting case within a single path. 36 | 37 | \code{PATH()$path} should always have columns \verb{object_ path_ subobject ncoords_} 38 | } 39 | \seealso{ 40 | \code{sc_path}, \code{sc_coord} 41 | } 42 | -------------------------------------------------------------------------------- /man/PATH0.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/PATH0-model.R 3 | \name{PATH0} 4 | \alias{PATH0} 5 | \alias{PATH0.default} 6 | \alias{PATH0.PATH0} 7 | \alias{PATH0_from_df} 8 | \title{Path model in structural form} 9 | \usage{ 10 | PATH0(x, ...) 11 | 12 | \method{PATH0}{default}(x, ...) 13 | 14 | \method{PATH0}{PATH0}(x, ...) 15 | 16 | PATH0_from_df( 17 | x, 18 | ..., 19 | path_ = "path_", 20 | object_ = "object_", 21 | subobject_ = "subobject_", 22 | x_ = "x", 23 | y_ = "y" 24 | ) 25 | } 26 | \arguments{ 27 | \item{x}{data frame with at least x, y columns} 28 | 29 | \item{...}{ignored} 30 | 31 | \item{path_}{path identifier, these should identify individual paths} 32 | 33 | \item{object_}{object identifier (like group in ggplot)} 34 | 35 | \item{subobject_}{subobject identifier (like polygon_id with multipolygons in sfheaders)} 36 | 37 | \item{x_}{optional name for x column (assumed to be x)} 38 | 39 | \item{y_}{optional name for x column (assumed to be y)} 40 | } 41 | \value{ 42 | PATH0 model with tables 'object' and 'vertex' 43 | } 44 | \description{ 45 | Structural form requires only tables 'object' and 'vertex'. 46 | 47 | Minimal columns is x,y but can be grouped by path_ for separate paths, then subobject_ and object_ for full polygon support. 48 | } 49 | \details{ 50 | This function exists as a special-case for non-format input for \code{\link[=PATH0]{PATH0()}}. It's expected there 51 | are columns x, y, and optionally object_, subobject_, and path_. These correspond to 52 | names in sfheaders, multipolygon_id, polygon_id, and linestring_id. (subobject is optional if 53 | not multipolygon). 54 | } 55 | \examples{ 56 | (p <- PATH0(minimal_mesh)) 57 | 58 | p$object$topology_ 59 | PATH0_from_df(data.frame(x = runif(10), y = runif(10))) 60 | } 61 | -------------------------------------------------------------------------------- /man/SC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SC-model.R 3 | \name{SC} 4 | \alias{SC} 5 | \alias{SC.default} 6 | \alias{SC.TRI} 7 | \alias{SC.pslg} 8 | \title{The universal model} 9 | \usage{ 10 | SC(x, ...) 11 | 12 | \method{SC}{default}(x, ...) 13 | 14 | \method{SC}{TRI}(x, ...) 15 | 16 | \method{SC}{pslg}(x, ...) 17 | } 18 | \arguments{ 19 | \item{x}{input model} 20 | 21 | \item{...}{arguments passed to methods} 22 | } 23 | \value{ 24 | SC model with tables 'object', 'object_link_edge', 'edge', and 'vertex' 25 | } 26 | \description{ 27 | The universal model \code{SC} is coordinates and binary relations between 28 | pairs of coordinates. This is purely an edge (or segment) model, with all 29 | higher level structures recorded as groupings of edges. 30 | } 31 | \examples{ 32 | ## we can produce a high quality triangulation from a low quality one 33 | ## see how the TRI edges are maintained (we can't yet filter out holes from DEL) 34 | tri <- TRI(minimal_mesh) 35 | plot(tri) 36 | plot(SC(tri)) 37 | } 38 | -------------------------------------------------------------------------------- /man/SC0.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SC0-model.R 3 | \name{SC0} 4 | \alias{SC0} 5 | \alias{SC0.default} 6 | \alias{SC0.pslg} 7 | \title{Pure edge model, structural form} 8 | \usage{ 9 | SC0(x, ...) 10 | 11 | \method{SC0}{default}(x, ...) 12 | 13 | \method{SC0}{pslg}(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{an object understood by silicate} 17 | 18 | \item{...}{reserved for methods} 19 | } 20 | \value{ 21 | SC0 model with tables 'object' and 'vertex' 22 | } 23 | \description{ 24 | \code{SC0} is the simplest and most general of all silicate models. Composed of 25 | an \code{object} and \code{vertex} table linked by nested vertex-index pairs. 26 | } 27 | \examples{ 28 | SC0(minimal_mesh) 29 | SC0(minimal_mesh) 30 | } 31 | -------------------------------------------------------------------------------- /man/TRI.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/TRI-model.R, R/plot.R 3 | \name{TRI} 4 | \alias{TRI} 5 | \alias{TRI.sfc_GEOMETRYCOLLECTION} 6 | \alias{plot.TRI} 7 | \title{TRI model, triangulations} 8 | \usage{ 9 | TRI(x, ...) 10 | 11 | \method{TRI}{sfc_GEOMETRYCOLLECTION}(x, ...) 12 | 13 | \method{plot}{TRI}(x, ..., add = FALSE) 14 | } 15 | \arguments{ 16 | \item{x}{object understood by silicate (sf, sp, a silicate model, etc.)} 17 | 18 | \item{...}{current unused} 19 | 20 | \item{add}{logical create new plot (default), or add to existing} 21 | } 22 | \value{ 23 | TRI model with tables 'object', 'triangle', 'vertex' 24 | } 25 | \description{ 26 | TRI creates a constrained triangulation using 'ear-cutting', or 'ear-clipping' of 27 | polygons. The model is a 'relational' form in that the underlying tables are 28 | linked implicitly by unique identifiers. 29 | Ear-cutting is inherently path-based, so this model is only available for 30 | path-based structures, like simple features, \code{\link[=PATH]{PATH()}}, \code{\link[=PATH0]{PATH0()}} and \code{\link[=ARC]{ARC()}}. 31 | } 32 | \examples{ 33 | tri <- TRI(minimal_mesh) 34 | plot(tri) 35 | } 36 | -------------------------------------------------------------------------------- /man/dplyr-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dplyr.R 3 | \name{dplyr-methods} 4 | \alias{dplyr-methods} 5 | \alias{filter.SC} 6 | \alias{filter} 7 | \title{Dplyr methods for silicate objects} 8 | \usage{ 9 | \method{filter}{SC}(.data, ...) 10 | } 11 | \arguments{ 12 | \item{.data}{data object of class SC} 13 | 14 | \item{...}{passed to \code{dplyr::filter}} 15 | } 16 | \value{ 17 | an \code{\link[=SC]{SC()}} model, with some parts filtered out 18 | } 19 | \description{ 20 | Filter an SC model, currently only \code{dplyr::filter} for \code{SC} is available. 21 | } 22 | \details{ 23 | Apply expressions as if used on the \code{object} table. See \code{sc_object(x)} for that form. 24 | 25 | Currently all the vertices are still kept, so the model (and any plots) include the filtered edges as well 26 | as undifferentiated points. This is likely to change ... 27 | } 28 | \examples{ 29 | library(dplyr) 30 | sc <- SC(inlandwaters) 31 | plot(filter(sc, Province == "Tasmania")) 32 | plot(filter(sc, Province \%in\% c("Victoria", "South Australia", "New South Wales"))) 33 | 34 | plot(filter(SC(minimal_mesh), a == 1)) 35 | } 36 | -------------------------------------------------------------------------------- /man/ear_gc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{ear_gc} 5 | \alias{ear_gc} 6 | \title{Geometry collection of triangles} 7 | \description{ 8 | A 'sfc_GEOMETRYCOLLECTION' of four-cornered triangles ('POLYGON') 9 | created by ear cutting the North Carolina polygon from sf. 10 | } 11 | \examples{ 12 | TRI0(ear_gc) 13 | } 14 | -------------------------------------------------------------------------------- /man/flight_tracks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{flight_tracks} 5 | \alias{flight_tracks} 6 | \title{Flight tracks} 7 | \description{ 8 | A data set flight tracks in XYZM form, a form of 4D tracks. Primarily to 9 | explore the use of \code{silicate} as able to represent this topologically, and to experiment with 10 | auto-time-based plotting in \code{anglr}. 11 | } 12 | \details{ 13 | Provided by Kent Johnson (kent37) in a 14 | \href{https://github.com/r-spatial/mapview/issues/99#issuecomment-328711275}{github discusion} 15 | where the data was attached in a zip file. 16 | 17 | Original form (in extdata/flight_tracks) is a XYZM LINESTRING shapefile 18 | containing 144 flight tracks of aircraft departing runway 33L at Boston Logan 19 | airport on January 27, 2017. Data is from an ADS-B recorder. Each point includes 20 | lat, lon, altitude in feet and time in North American Eastern Standard Time 21 | (EST). 22 | 23 | Converted via \code{sf} into \code{silicate::PATH} normal form, see (data-raw/flight_tracks.R). 24 | } 25 | -------------------------------------------------------------------------------- /man/inlandwaters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{inlandwaters} 5 | \alias{inlandwaters} 6 | \title{Inland waters, for parts of Australia, and New Caledonia.} 7 | \description{ 8 | The inland waters are lakes and inland waters presenting as holes 9 | within the bounded regions of Australian (and New Caledonian) provinces. 10 | } 11 | \details{ 12 | This is an extract from the old Manifold DVD. It is in \code{sf} format\verb{. The features have variables }ID\code{and}Province` they are (in order): 13 | \itemize{ 14 | \item{"103841"}{Australian Capital Territory} 15 | \item{"103842"}{New Caledonia} 16 | \item{"103843"}{New South Wales} 17 | \item{"103846"}{South Australia} 18 | \item{"103847"}{Tasmania} 19 | \item{"103848"}{Victoria} 20 | } 21 | There's no good reason that New Caledonia is included and not Queensland (for example) 22 | it's just what happened doing a quick crop and extract with the mouse. Lord Howe Island and 23 | Macquarie Island are both present, as part of New South Wales and Tasmania respectively. 24 | } 25 | \examples{ 26 | \donttest{ 27 | path <- PATH(inlandwaters) 28 | plot(path) 29 | obj <- split(path$path_link_vertex, path$path_link_vertex$path_) 30 | cl <- grDevices::colors()[-1L] 31 | cols <- sample(cl, length(obj), replace = length(obj) > length(cl)) 32 | op <- par(mfrow = grDevices::n2mfrow(length(obj)), mar = rep(0, 4)) 33 | funplot <- function(ob, vert, col) { 34 | vx <- c("x_", "y_") 35 | plot(dplyr::inner_join(ob, vert, "vertex_")[vx], col = col, type = "l", axes = FALSE) 36 | } 37 | junk <- lapply(seq_along(obj), 38 | function(a) { 39 | funplot(obj[[a]], path$vertex, cols[a]) 40 | invisible(NULL) 41 | }) 42 | par(op) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /man/minimal_mesh.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{minimal_mesh} 5 | \alias{minimal_mesh} 6 | \title{Minimal mesh.} 7 | \description{ 8 | The simplest pairing of two polygons with one shared edge. One polygon 9 | contains a hole and a concavity, the other is a simply convex. This is 10 | composed of four "arcs", one around each polygon, one for the shared edge, and 11 | one for the isolated hole. There are two nodes, the endpoints of the single shared edge. 12 | } 13 | \examples{ 14 | arc <- ARC(minimal_mesh) 15 | plot(arc) 16 | sc_arc(arc) 17 | sc_node(arc) 18 | } 19 | -------------------------------------------------------------------------------- /man/mmesh.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{mmesh} 5 | \alias{mmesh} 6 | \title{Deprecated data set.} 7 | \description{ 8 | This data set is in legacy format and will be removed. 9 | A couple of polygons with a single shared edge between them, in 10 | PRIMITIVE form. 11 | } 12 | -------------------------------------------------------------------------------- /man/pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-pipe.R 3 | \name{\%>\%} 4 | \alias{\%>\%} 5 | \title{Pipe operator} 6 | \usage{ 7 | lhs \%>\% rhs 8 | } 9 | \description{ 10 | See \code{magrittr::\link[magrittr]{\%>\%}} for details. 11 | } 12 | \keyword{internal} 13 | -------------------------------------------------------------------------------- /man/plot.SC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{plot.SC} 4 | \alias{plot.SC} 5 | \alias{plot.SC0} 6 | \title{Plot silicate} 7 | \usage{ 8 | \method{plot}{SC}(x, ..., add = FALSE) 9 | 10 | \method{plot}{SC0}(x, ..., add = FALSE) 11 | } 12 | \arguments{ 13 | \item{x}{sc object} 14 | 15 | \item{...}{arguments passed to lower level plotting functions} 16 | 17 | \item{add}{if \code{TRUE} add to current plot} 18 | } 19 | \description{ 20 | Basic edge plot, all the standard base graphics facilities for line segments are available. 21 | } 22 | \details{ 23 | The 'col' argument is passed directly to \code{\link[=segments]{segments()}} or \code{\link[=polypath]{polypath()}} as needed, in the usual 24 | one-to-one or recycling way. 25 | 26 | Graphical parameters are not able to be passed to the initial plot setup, but a plot 27 | can be set up and then added to with this method. 28 | } 29 | -------------------------------------------------------------------------------- /man/polymesh.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{polymesh} 5 | \alias{polymesh} 6 | \title{Polygonal mesh} 7 | \description{ 8 | A simple set of \code{sf} neighbouring polygons, with redundant vertices created 9 | from polygonizing a raster. 10 | } 11 | \examples{ 12 | arc <- ARC(polymesh) 13 | plot(arc) 14 | sc <- SC(polymesh) 15 | plot(sc) 16 | } 17 | -------------------------------------------------------------------------------- /man/print.sc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.R 3 | \name{print.sc} 4 | \alias{print.sc} 5 | \title{Methods for silicate} 6 | \usage{ 7 | \method{print}{sc}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{object inheriting from 'sc' class} 11 | 12 | \item{...}{ignore currently} 13 | } 14 | \description{ 15 | Print a silicate model. 16 | } 17 | \details{ 18 | Simple summary of type and content of a silicate model. 19 | } 20 | \examples{ 21 | print(TRI(minimal_mesh)) 22 | print(SC(minimal_mesh)) 23 | print(PATH(minimal_mesh)) 24 | print(SC(TRI(minimal_mesh))) 25 | print(ARC(minimal_mesh)) 26 | print(SC0(minimal_mesh)) 27 | } 28 | -------------------------------------------------------------------------------- /man/routes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{routes} 5 | \alias{routes} 6 | \title{Transport routes} 7 | \description{ 8 | Routing data set stolen from stplanr 9 | see data-raw/routes.R 10 | } 11 | -------------------------------------------------------------------------------- /man/sc_arc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_arc.R 3 | \name{sc_arc} 4 | \alias{sc_arc} 5 | \alias{sc_arc.default} 6 | \alias{sc_arc.ARC} 7 | \title{Arc-node topology.} 8 | \usage{ 9 | sc_arc(x, ...) 10 | 11 | \method{sc_arc}{default}(x, ...) 12 | 13 | \method{sc_arc}{ARC}(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{input object} 17 | 18 | \item{...}{arguments for methods} 19 | } 20 | \value{ 21 | a data frame with only the identities of the shared boundaries (arcs) 22 | } 23 | \description{ 24 | Return a label and vertex count of each arc. 25 | } 26 | \details{ 27 | Arcs are unbranched paths within the line segment graph. Nodes are the vertices where three or more arcs meet. 28 | 29 | As with the \code{PATH} and \code{SC} models the arc id values will only be relevant when 30 | those entities are identified and labelled. Running \code{sc_arc} on a simple features model (for example) will 31 | identify them and return a summary, but without having any record of what they refer to. Use \code{ARC(x)} first to 32 | work with models that don't included labels. 33 | } 34 | \examples{ 35 | sc_arc(minimal_mesh) 36 | ARC(minimal_mesh)[["arc"]] 37 | 38 | arc <- ARC(minimal_mesh) 39 | plot(arc) 40 | points(arc$vertex[match(sc_node(arc)$vertex_, arc$vertex$vertex_), c("x_", "y_")]) 41 | 42 | arc <- ARC(polymesh) 43 | plot(arc) 44 | title("arcs and nodes") 45 | points(arc$vertex[match(sc_node(arc)$vertex_, arc$vertex$vertex_), c("x_", "y_")]) 46 | } 47 | -------------------------------------------------------------------------------- /man/sc_colours.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{sc_colours} 4 | \alias{sc_colours} 5 | \title{Silicate colours} 6 | \usage{ 7 | sc_colours(x = 16, ..., viridis = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{number of colours to generate} 11 | 12 | \item{...}{currently ignored} 13 | 14 | \item{viridis}{use viridis, TRUE or FALSE} 15 | } 16 | \value{ 17 | vector of colours 18 | } 19 | \description{ 20 | Simple set of colours for discrete palette. 21 | } 22 | \examples{ 23 | sc_colours(10) 24 | } 25 | -------------------------------------------------------------------------------- /man/sc_edge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_edge.R 3 | \name{sc_edge} 4 | \alias{sc_edge} 5 | \alias{sc_start} 6 | \alias{sc_end} 7 | \alias{sc_edge.default} 8 | \alias{sc_edge.PATH} 9 | \alias{sc_start.SC} 10 | \alias{sc_start.SC0} 11 | \alias{sc_start.PATH} 12 | \alias{sc_end.PATH} 13 | \alias{sc_start.PATH0} 14 | \alias{sc_end.PATH0} 15 | \alias{sc_start.ARC} 16 | \alias{sc_start.TRI} 17 | \alias{sc_end.SC} 18 | \alias{sc_end.SC0} 19 | \alias{sc_end.ARC} 20 | \alias{sc_end.TRI} 21 | \title{Edges.} 22 | \usage{ 23 | sc_edge(x, ...) 24 | 25 | \method{sc_edge}{default}(x, ...) 26 | 27 | \method{sc_edge}{PATH}(x, ...) 28 | 29 | sc_start(x, ...) 30 | 31 | \method{sc_start}{SC}(x, ...) 32 | 33 | \method{sc_start}{SC0}(x, ...) 34 | 35 | \method{sc_start}{PATH}(x, ...) 36 | 37 | \method{sc_end}{PATH}(x, ...) 38 | 39 | \method{sc_start}{PATH0}(x, ...) 40 | 41 | \method{sc_end}{PATH0}(x, ...) 42 | 43 | \method{sc_start}{ARC}(x, ...) 44 | 45 | \method{sc_start}{TRI}(x, ...) 46 | 47 | sc_end(x, ...) 48 | 49 | \method{sc_end}{SC}(x, ...) 50 | 51 | \method{sc_end}{SC0}(x, ...) 52 | 53 | \method{sc_end}{ARC}(x, ...) 54 | 55 | \method{sc_end}{TRI}(x, ...) 56 | } 57 | \arguments{ 58 | \item{x}{input object} 59 | 60 | \item{...}{arguments for methods} 61 | } 62 | \value{ 63 | data frame of edge identity, or start/end coordinates 64 | } 65 | \description{ 66 | Simple binary relationships, a primitive composed of two vertices. 67 | } 68 | \details{ 69 | Edges are unique, undirected line segments. Compare to \code{sc_segment} which refers to all 70 | instances of edges. 71 | 72 | \code{sc_start} and \code{sc_end} are convenience functions that provide the obvious 73 | start and end coordinates by joining on the appropriate edge vertex label, \code{.vx0} 74 | or \code{.vx1}. Currently this returns the ordered segments, along with their unique (unordered) \code{edge_}, as 75 | well as unique \code{segment}, a \code{object_} labels. 76 | } 77 | -------------------------------------------------------------------------------- /man/sc_node.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_node.R 3 | \name{sc_node} 4 | \alias{sc_node} 5 | \alias{sc_node.SC} 6 | \alias{sc_node.SC0} 7 | \alias{sc_node.default} 8 | \alias{sc_node.PATH} 9 | \alias{sc_node.ARC} 10 | \title{Nodes for arc-node topology.} 11 | \usage{ 12 | sc_node(x, ...) 13 | 14 | \method{sc_node}{SC}(x, ...) 15 | 16 | \method{sc_node}{SC0}(x, ...) 17 | 18 | \method{sc_node}{default}(x, ...) 19 | 20 | \method{sc_node}{PATH}(x, ...) 21 | 22 | \method{sc_node}{ARC}(x, ...) 23 | } 24 | \arguments{ 25 | \item{x}{input object} 26 | 27 | \item{...}{arguments for methods} 28 | } 29 | \value{ 30 | data frame of the nodes 31 | } 32 | \description{ 33 | Nodes are the vertices in the graph that are shared by "arcs". 34 | } 35 | \examples{ 36 | sc_node(ARC(minimal_mesh)) 37 | sc <- SC(routes) 38 | library(dplyr) 39 | plot(sc) 40 | sc_node(sc) \%>\% inner_join(sc$vertex) \%>\% select(x_, y_) \%>\% points() 41 | } 42 | -------------------------------------------------------------------------------- /man/sc_object.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_object.R, R/TRI-model.R 3 | \name{sc_object} 4 | \alias{sc_object} 5 | \alias{sc_object.default} 6 | \alias{sc_object.sf} 7 | \alias{sc_object.sfc} 8 | \alias{sc_object.TRI} 9 | \title{Objects, features} 10 | \usage{ 11 | sc_object(x, ...) 12 | 13 | \method{sc_object}{default}(x, ...) 14 | 15 | \method{sc_object}{sf}(x, ...) 16 | 17 | \method{sc_object}{sfc}(x, ...) 18 | 19 | \method{sc_object}{TRI}(x, ...) 20 | } 21 | \arguments{ 22 | \item{x}{input object} 23 | 24 | \item{...}{arguments passed to methods} 25 | } 26 | \value{ 27 | data frame of the object values 28 | } 29 | \description{ 30 | The objects are the front end entities, the usual "GIS contract" objects, 31 | or features. 32 | 33 | The objects are the front end entities, the usual "GIS contract" objects, 34 | the features. 35 | } 36 | \examples{ 37 | sc_object(minimal_mesh) 38 | sc_object(SC0(minimal_mesh)) 39 | } 40 | \seealso{ 41 | \code{sc_coord} for the coordinates part of the model, \code{sc_path} for 42 | the central part of the model, and \code{PATH} for the full model. 43 | 44 | \code{sc_coord} for the coordinates part of the model, \code{sc_path} for 45 | the central part of the model, and \code{PATH} for the full model. 46 | } 47 | -------------------------------------------------------------------------------- /man/sc_segment.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_segment.R 3 | \name{sc_segment} 4 | \alias{sc_segment} 5 | \alias{sc_segment.default} 6 | \alias{sc_segment.PATH} 7 | \title{Given a `PATH`` model decompose to 1-dimensional primitives (or 0-dimensional).} 8 | \usage{ 9 | sc_segment(x, ...) 10 | 11 | \method{sc_segment}{default}(x, ...) 12 | 13 | \method{sc_segment}{PATH}(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{input object} 17 | 18 | \item{...}{arguments passed to methods} 19 | } 20 | \value{ 21 | data frame of the segments, each occurence of an edge and its order 22 | } 23 | \description{ 24 | Given a `PATH`` model decompose to 1-dimensional primitives (or 0-dimensional). 25 | } 26 | \examples{ 27 | sc_segment(SC(minimal_mesh)) 28 | } 29 | -------------------------------------------------------------------------------- /man/sc_uid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_uid.R 3 | \name{sc_uid} 4 | \alias{sc_uid} 5 | \title{Unique labels} 6 | \usage{ 7 | sc_uid(x, ..., uid_nchar = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{number of unique IDs to generate} 11 | 12 | \item{...}{reserved for future use} 13 | 14 | \item{uid_nchar}{number of raw characters to paste as a uuid, default is 6 (only if silicate.uid.type is "uuid", see Details)} 15 | } 16 | \value{ 17 | vector of unique id values for elements in the input 18 | } 19 | \description{ 20 | Find unique labels for entities, or create them 21 | if not present. 22 | } 23 | \details{ 24 | If 'integers' default we generate sequential integers, it's assumed that all IDs are created 25 | at one time, we are not adding to an existing set. Code that adds IDs should find 26 | the largest existing ID and offset these by that value. 27 | 28 | Using 'silicate.uid.type="uuid"' is the default. Using 'silicate.uid.type="integer"' is considered experimental. 29 | By default UIDs are a mix of letters, LETTERS and digits of length \code{getOption("silicate.uid.size")} which defaults to 6. 30 | 31 | See \code{ids} package for \code{random_id} used if option 'silicate.uid.type="uuid"'. 32 | } 33 | \examples{ 34 | sc_uid(data.frame(1:10)) 35 | } 36 | -------------------------------------------------------------------------------- /man/sc_vertex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00_vertex.R 3 | \name{sc_vertex} 4 | \alias{sc_vertex} 5 | \alias{sc_vertex.default} 6 | \alias{sc_vertex.SC} 7 | \alias{sc_vertex.SC0} 8 | \alias{sc_vertex.ARC} 9 | \alias{sc_vertex.TRI} 10 | \alias{sc_vertex.TRI0} 11 | \alias{sc_vertex.PATH} 12 | \alias{sc_vertex.PATH0} 13 | \alias{sc_vertex.pslg} 14 | \title{Extract unique vertices} 15 | \usage{ 16 | sc_vertex(x, ...) 17 | 18 | \method{sc_vertex}{default}(x, ...) 19 | 20 | \method{sc_vertex}{SC}(x, ...) 21 | 22 | \method{sc_vertex}{SC0}(x, ...) 23 | 24 | \method{sc_vertex}{ARC}(x, ...) 25 | 26 | \method{sc_vertex}{TRI}(x, ...) 27 | 28 | \method{sc_vertex}{TRI0}(x, ...) 29 | 30 | \method{sc_vertex}{PATH}(x, ...) 31 | 32 | \method{sc_vertex}{PATH0}(x, ...) 33 | 34 | \method{sc_vertex}{pslg}(x, ...) 35 | } 36 | \arguments{ 37 | \item{x}{model} 38 | 39 | \item{...}{passed to methods} 40 | } 41 | \value{ 42 | data frame of only the unique coordinates 43 | } 44 | \description{ 45 | Extract unique vertices 46 | } 47 | \examples{ 48 | sc_vertex(minimal_mesh) 49 | sc_vertex(SC0(minimal_mesh)) 50 | } 51 | -------------------------------------------------------------------------------- /man/sfzoo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{data} 4 | \name{sfzoo} 5 | \alias{sfzoo} 6 | \alias{sfgc} 7 | \title{Simple features zoo.} 8 | \description{ 9 | Basic examples of each type of simple feature geometry. \code{sfzoo} is a list 10 | with each of \emph{point}, \emph{multipoin}, \emph{linestring}, \emph{multilinestring}, \emph{polygon} and 11 | \emph{multipolygon}. \code{sfgc} is a \emph{GEOMETRYCOLLECTION} of all the types in \code{sfzoo}. 12 | } 13 | \examples{ 14 | lapply(sfzoo, sc_coord) 15 | lapply(sfzoo, sc_path) 16 | 17 | ## unsure how useful this is ... 18 | sc_path(sfgc) 19 | } 20 | -------------------------------------------------------------------------------- /man/silicate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/silicate-package.R 3 | \docType{package} 4 | \name{silicate} 5 | \alias{silicate} 6 | \alias{silicate-package} 7 | \title{silicate} 8 | \description{ 9 | Decomposes spatial data (of various formats) into simpler forms, including 10 | paths, triangles or segments. A development tool for exploring the underlying 11 | structures of spatial data, and for converting it to something else. The models 12 | \code{\link[=PATH]{PATH()}}, \code{\link[=TRI]{TRI()}}, \code{\link[=SC]{SC()}} and \code{\link[=ARC]{ARC()}} provide relational tables of all underlying 13 | entities, and more specialist versions \code{\link[=PATH0]{PATH0()}}, \code{\link[=TRI0]{TRI0()}} and \code{\link[=SC0]{SC0()}} provide more 14 | efficient topological representations of polygons or lines. 15 | } 16 | -------------------------------------------------------------------------------- /man/tri_area.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/triangles.R 3 | \name{tri_area} 4 | \alias{tri_area} 5 | \title{Area of triangles} 6 | \usage{ 7 | tri_area(x) 8 | } 9 | \arguments{ 10 | \item{x}{matrix of triangle coordinates} 11 | } 12 | \value{ 13 | numeric, area of triangles 14 | } 15 | \description{ 16 | Input is x,y matrix in triplets, with 3 rows per triangle vertex. 17 | } 18 | \examples{ 19 | pts <- structure(c(5L, 3L, 1L, 4L, 4L, 8L, 6L, 9L), .Dim = c(4L, 2L)) 20 | tri <- c(2, 1, 3, 2, 4, 1) 21 | (a <- tri_area(pts[tri, ])) 22 | plot(pts) 23 | polygon(pts[head(as.vector(rbind(matrix(tri, nrow = 3), NA)), -1), ]) 24 | text(tapply(pts[tri,1], rep(1:2, each = 3), mean), 25 | tapply(pts[tri,2], rep(1:2, each = 3), mean), labels = sprintf("area: \%0.1f", a)) 26 | } 27 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Platform 2 | 3 | |field |value | 4 | |:--------|:----------------------------| 5 | |version |R version 3.6.3 (2020-02-29) | 6 | |os |Ubuntu 18.04.4 LTS | 7 | |system |x86_64, linux-gnu | 8 | |ui |X11 | 9 | |language |(EN) | 10 | |collate |en_AU.UTF-8 | 11 | |ctype |en_AU.UTF-8 | 12 | |tz |Australia/Hobart | 13 | |date |2020-05-11 | 14 | 15 | # Dependencies 16 | 17 | |package |old |new |Δ | 18 | |:--------|:-----|:-----|:--| 19 | |silicate |0.4.0 |0.6.0 |* | 20 | |pillar |NA |1.4.4 |* | 21 | |rlang |NA |0.4.6 |* | 22 | 23 | # Revdeps 24 | 25 | ## Failed to check (3) 26 | 27 | |package |version |error |warning |note | 28 | |:------------|:-------|:-----|:-------|:----| 29 | |anglr |? | | | | 30 | |eixport |? | | | | 31 | |tabularaster |? | | | | 32 | 33 | -------------------------------------------------------------------------------- /revdep/checks/libraries.csv: -------------------------------------------------------------------------------- 1 | package,old,new,delta 2 | silicate,0.4.0,0.6.0,* 3 | pillar,NA,1.4.4,* 4 | rlang,NA,0.4.6,* 5 | -------------------------------------------------------------------------------- /revdep/data.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/data.sqlite -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: pillar 2 | Title: Coloured Formatting for Columns 3 | Version: 1.4.4 4 | Authors@R: 5 | c(person(given = "Kirill", 6 | family = "M\u00fcller", 7 | role = c("aut", "cre"), 8 | email = "krlmlr+r@mailbox.org"), 9 | person(given = "Hadley", 10 | family = "Wickham", 11 | role = "aut"), 12 | person(given = "RStudio", 13 | role = "cph")) 14 | Description: Provides 'pillar' and 'colonnade' generics designed 15 | for formatting columns of data using the full range of colours 16 | provided by modern terminals. 17 | License: GPL-3 18 | URL: https://github.com/r-lib/pillar 19 | BugReports: https://github.com/r-lib/pillar/issues 20 | Imports: cli, crayon (>= 1.3.4), fansi, rlang (>= 0.3.0), utf8 (>= 21 | 1.1.0), vctrs (>= 0.2.0) 22 | Suggests: knitr, lubridate, testthat (>= 2.0.0), withr 23 | Encoding: UTF-8 24 | LazyData: true 25 | RoxygenNote: 7.1.0 26 | Collate: 'capital.R' 'compat-lifecycle.R' 'compat-purrr.R' 27 | 'deprecated.R' 'dim.R' 'empty-data.R' 'extent.R' 'lengths.R' 28 | 'multi.R' 'ornament.R' 'pillar-package.R' 'pillar.R' 29 | 'rowid-capital.R' 'rowid-data.R' 'rowid-title.R' 'rowid-type.R' 30 | 'scientific.R' 'shaft.R' 'shaft-simple.R' 'sigfig.R' 31 | 'spark-bar.R' 'spark-line.R' 'strrep.R' 'styles.R' 'testthat.R' 32 | 'tick.R' 'title.R' 'type-sum.R' 'type.R' 'utils.R' 'vctrs.R' 33 | 'width.R' 'zzz.R' 34 | NeedsCompilation: no 35 | Packaged: 2020-05-05 03:49:44 UTC; kirill 36 | Author: Kirill Müller [aut, cre], 37 | Hadley Wickham [aut], 38 | RStudio [cph] 39 | Maintainer: Kirill Müller 40 | Repository: CRAN 41 | Date/Publication: 2020-05-05 05:30:03 UTC 42 | Built: R 3.6.3; ; 2020-05-11 12:09:49 UTC; unix 43 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/INDEX: -------------------------------------------------------------------------------- 1 | colonnade Format multiple vectors in a tabular display 2 | dim_desc Format dimensions 3 | expect_known_display Test helpers 4 | extra_cols Retrieve information about columns that didn't 5 | fit the available width 6 | format_type_sum Format a type summary 7 | get_extent Calculate display width 8 | new_ornament Helper to define the contents of a pillar 9 | new_pillar_shaft Constructor for column data 10 | new_pillar_title Prepare a column title for formatting 11 | new_pillar_type Prepare a column type for formatting 12 | pillar Format a vector suitable for tabular display 13 | pillar-package pillar: Coloured Formatting for Columns 14 | pillar_shaft Column data 15 | style_num Styling helpers 16 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/Rd.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/Rd.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/features.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/features.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/hsearch.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/hsearch.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/links.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/links.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/nsInfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/nsInfo.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/Meta/package.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/Meta/package.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(extra_cols,pillar_squeezed_colonnade) 4 | S3method(format,pillar) 5 | S3method(format,pillar_capital) 6 | S3method(format,pillar_colonnade) 7 | S3method(format,pillar_empty_shaft) 8 | S3method(format,pillar_rif_shaft) 9 | S3method(format,pillar_rif_title) 10 | S3method(format,pillar_rif_type) 11 | S3method(format,pillar_shaft) 12 | S3method(format,pillar_shaft_decimal) 13 | S3method(format,pillar_shaft_simple) 14 | S3method(format,pillar_squeezed_colonnade) 15 | S3method(format,pillar_title) 16 | S3method(format,pillar_type) 17 | S3method(format_type_sum,default) 18 | S3method(is_vector_s3,default) 19 | S3method(obj_sum,AsIs) 20 | S3method(obj_sum,POSIXlt) 21 | S3method(obj_sum,default) 22 | S3method(obj_sum,list) 23 | S3method(pillar_shaft,AsIs) 24 | S3method(pillar_shaft,Date) 25 | S3method(pillar_shaft,POSIXt) 26 | S3method(pillar_shaft,character) 27 | S3method(pillar_shaft,default) 28 | S3method(pillar_shaft,factor) 29 | S3method(pillar_shaft,list) 30 | S3method(pillar_shaft,logical) 31 | S3method(pillar_shaft,numeric) 32 | S3method(pillar_shaft,pillar_empty_col) 33 | S3method(pillar_shaft,pillar_vertical) 34 | S3method(pillar_shaft,vctrs_list_of) 35 | S3method(pillar_shaft,vctrs_vctr) 36 | S3method(print,pillar) 37 | S3method(print,pillar_colonnade) 38 | S3method(print,pillar_ornament) 39 | S3method(print,pillar_shaft) 40 | S3method(print,pillar_squeezed_colonnade) 41 | S3method(print,pillar_vertical) 42 | S3method(type_sum,default) 43 | S3method(type_sum,factor) 44 | S3method(type_sum,ordered) 45 | S3method(type_sum,vctrs_unspecified) 46 | S3method(type_sum,vctrs_vctr) 47 | export(colonnade) 48 | export(dim_desc) 49 | export(expect_known_display) 50 | export(extra_cols) 51 | export(format_type_sum) 52 | export(get_extent) 53 | export(get_max_extent) 54 | export(is_vector_s3) 55 | export(new_ornament) 56 | export(new_pillar_shaft) 57 | export(new_pillar_shaft_simple) 58 | export(new_pillar_title) 59 | export(new_pillar_type) 60 | export(obj_sum) 61 | export(pillar) 62 | export(pillar_shaft) 63 | export(squeeze) 64 | export(style_bold) 65 | export(style_na) 66 | export(style_neg) 67 | export(style_num) 68 | export(style_subtle) 69 | export(style_subtle_num) 70 | export(type_sum) 71 | import(rlang) 72 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/R/pillar: -------------------------------------------------------------------------------- 1 | # File share/R/nspackloader.R 2 | # Part of the R package, http://www.R-project.org 3 | # 4 | # Copyright (C) 1995-2012 The R Core Team 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # A copy of the GNU General Public License is available at 17 | # http://www.r-project.org/Licenses/ 18 | 19 | local({ 20 | info <- loadingNamespaceInfo() 21 | pkg <- info$pkgname 22 | ns <- .getNamespace(as.name(pkg)) 23 | if (is.null(ns)) 24 | stop("cannot find namespace environment for ", pkg, domain = NA); 25 | dbbase <- file.path(info$libname, pkg, "R", pkg) 26 | lazyLoad(dbbase, ns, filter = function(n) n != ".__NAMESPACE__.") 27 | }) 28 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/R/pillar.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/R/pillar.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/R/pillar.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/R/pillar.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/AnIndex: -------------------------------------------------------------------------------- 1 | pillar-package pillar-package 2 | colonnade colonnade 3 | deprecated deprecated 4 | dim_desc dim_desc 5 | expect_known_display expect_known_display 6 | extra_cols extra_cols 7 | extra_cols.pillar_squeezed_colonnade extra_cols 8 | format.pillar_shaft pillar_shaft 9 | format_type_sum format_type_sum 10 | format_type_sum.default format_type_sum 11 | get_extent get_extent 12 | get_max_extent get_extent 13 | is_vector_s3 deprecated 14 | new_ornament new_ornament 15 | new_pillar_shaft new_pillar_shaft 16 | new_pillar_shaft_simple new_pillar_shaft 17 | new_pillar_title new_pillar_title 18 | new_pillar_type new_pillar_type 19 | obj_sum type_sum 20 | pillar pillar 21 | pillar_shaft pillar_shaft 22 | pillar_shaft.AsIs pillar_shaft 23 | pillar_shaft.character pillar_shaft 24 | pillar_shaft.Date pillar_shaft 25 | pillar_shaft.default pillar_shaft 26 | pillar_shaft.factor pillar_shaft 27 | pillar_shaft.list pillar_shaft 28 | pillar_shaft.logical pillar_shaft 29 | pillar_shaft.numeric pillar_shaft 30 | pillar_shaft.pillar_vertical pillar_shaft 31 | pillar_shaft.POSIXt pillar_shaft 32 | print.pillar_shaft pillar_shaft 33 | squeeze colonnade 34 | style_bold style_subtle 35 | style_na style_subtle 36 | style_neg style_subtle 37 | style_num style_subtle 38 | style_subtle style_subtle 39 | style_subtle_num style_subtle 40 | type_sum type_sum 41 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/aliases.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/help/aliases.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/colours.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/help/figures/colours.png -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-archived.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclearchivedarchived -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-defunct.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledefunctdefunct -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-deprecated.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledeprecateddeprecated -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-experimental.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycleexperimentalexperimental -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-maturing.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclematuringmaturing -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-questioning.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclequestioningquestioning -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-retired.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycleretiredretired -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-soft-deprecated.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclesoft-deprecatedsoft-deprecated -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/figures/lifecycle-stable.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclestablestable -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/paths.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/help/paths.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/pillar.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/help/pillar.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/help/pillar.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/pillar/help/pillar.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/pillar/html/R.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white; 3 | color: black; 4 | } 5 | 6 | a:link { 7 | background: white; 8 | color: blue; 9 | } 10 | 11 | a:visited { 12 | background: white; 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | h1 { 17 | background: white; 18 | color: rgb(55%, 55%, 55%); 19 | font-family: monospace; 20 | font-size: x-large; 21 | text-align: center; 22 | } 23 | 24 | h2 { 25 | background: white; 26 | color: rgb(40%, 40%, 40%); 27 | font-family: monospace; 28 | font-size: large; 29 | text-align: center; 30 | } 31 | 32 | h3 { 33 | background: white; 34 | color: rgb(40%, 40%, 40%); 35 | font-family: monospace; 36 | font-size: large; 37 | } 38 | 39 | h4 { 40 | background: white; 41 | color: rgb(40%, 40%, 40%); 42 | font-family: monospace; 43 | font-style: italic; 44 | font-size: large; 45 | } 46 | 47 | h5 { 48 | background: white; 49 | color: rgb(40%, 40%, 40%); 50 | font-family: monospace; 51 | } 52 | 53 | h6 { 54 | background: white; 55 | color: rgb(40%, 40%, 40%); 56 | font-family: monospace; 57 | font-style: italic; 58 | } 59 | 60 | img.toplogo { 61 | width: 4em; 62 | vertical-align: middle; 63 | } 64 | 65 | img.arrow { 66 | width: 30px; 67 | height: 30px; 68 | border: 0; 69 | } 70 | 71 | span.acronym { 72 | font-size: small; 73 | } 74 | 75 | span.env { 76 | font-family: monospace; 77 | } 78 | 79 | span.file { 80 | font-family: monospace; 81 | } 82 | 83 | span.option{ 84 | font-family: monospace; 85 | } 86 | 87 | span.pkg { 88 | font-weight: bold; 89 | } 90 | 91 | span.samp{ 92 | font-family: monospace; 93 | } 94 | 95 | div.vignettes a:hover { 96 | background: rgb(85%, 85%, 85%); 97 | } 98 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rlang 2 | Version: 0.4.6 3 | Title: Functions for Base Types and Core R and 'Tidyverse' Features 4 | Description: A toolbox for working with base types, core R features 5 | like the condition system, and core 'Tidyverse' features like tidy 6 | evaluation. 7 | Authors@R: c( 8 | person("Lionel", "Henry", ,"lionel@rstudio.com", c("aut", "cre")), 9 | person("Hadley", "Wickham", ,"hadley@rstudio.com", "aut"), 10 | person("RStudio", role = "cph") 11 | ) 12 | License: GPL-3 13 | LazyData: true 14 | ByteCompile: true 15 | Biarch: true 16 | Depends: R (>= 3.2.0) 17 | Suggests: cli, covr, crayon, glue, magrittr, methods, pillar, 18 | rmarkdown, testthat (>= 2.3.0), vctrs (>= 0.2.3) 19 | Encoding: UTF-8 20 | RoxygenNote: 7.0.2 21 | URL: http://rlang.r-lib.org, https://github.com/r-lib/rlang 22 | BugReports: https://github.com/r-lib/rlang/issues 23 | NeedsCompilation: yes 24 | Packaged: 2020-05-02 13:00:52 UTC; lionel 25 | Author: Lionel Henry [aut, cre], 26 | Hadley Wickham [aut], 27 | RStudio [cph] 28 | Maintainer: Lionel Henry 29 | Repository: CRAN 30 | Date/Publication: 2020-05-02 16:20:02 UTC 31 | Built: R 3.6.3; x86_64-pc-linux-gnu; 2020-05-11 12:09:37 UTC; unix 32 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/Rd.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/Rd.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/features.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/features.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/hsearch.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/hsearch.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/links.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/links.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/nsInfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/nsInfo.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/Meta/package.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/Meta/package.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/R/rlang: -------------------------------------------------------------------------------- 1 | # File share/R/nspackloader.R 2 | # Part of the R package, http://www.R-project.org 3 | # 4 | # Copyright (C) 1995-2012 The R Core Team 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # A copy of the GNU General Public License is available at 17 | # http://www.r-project.org/Licenses/ 18 | 19 | local({ 20 | info <- loadingNamespaceInfo() 21 | pkg <- info$pkgname 22 | ns <- .getNamespace(as.name(pkg)) 23 | if (is.null(ns)) 24 | stop("cannot find namespace environment for ", pkg, domain = NA); 25 | dbbase <- file.path(info$libname, pkg, "R", pkg) 26 | lazyLoad(dbbase, ns, filter = function(n) n != ".__NAMESPACE__.") 27 | }) 28 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/R/rlang.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/R/rlang.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/R/rlang.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/R/rlang.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/backtrace-ver: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/aliases.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/help/aliases.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-archived.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclearchivedarchived -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-defunct.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledefunctdefunct -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-deprecated.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycledeprecateddeprecated -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-experimental.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycleexperimentalexperimental -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-maturing.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclematuringmaturing -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-questioning.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclequestioningquestioning -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-retired.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecycleretiredretired -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-soft-deprecated.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclesoft-deprecatedsoft-deprecated -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/lifecycle-stable.svg: -------------------------------------------------------------------------------- 1 | lifecyclelifecyclestablestable -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/figures/rlang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/help/figures/rlang.png -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/paths.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/help/paths.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/rlang.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/help/rlang.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/help/rlang.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/help/rlang.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/html/R.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white; 3 | color: black; 4 | } 5 | 6 | a:link { 7 | background: white; 8 | color: blue; 9 | } 10 | 11 | a:visited { 12 | background: white; 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | h1 { 17 | background: white; 18 | color: rgb(55%, 55%, 55%); 19 | font-family: monospace; 20 | font-size: x-large; 21 | text-align: center; 22 | } 23 | 24 | h2 { 25 | background: white; 26 | color: rgb(40%, 40%, 40%); 27 | font-family: monospace; 28 | font-size: large; 29 | text-align: center; 30 | } 31 | 32 | h3 { 33 | background: white; 34 | color: rgb(40%, 40%, 40%); 35 | font-family: monospace; 36 | font-size: large; 37 | } 38 | 39 | h4 { 40 | background: white; 41 | color: rgb(40%, 40%, 40%); 42 | font-family: monospace; 43 | font-style: italic; 44 | font-size: large; 45 | } 46 | 47 | h5 { 48 | background: white; 49 | color: rgb(40%, 40%, 40%); 50 | font-family: monospace; 51 | } 52 | 53 | h6 { 54 | background: white; 55 | color: rgb(40%, 40%, 40%); 56 | font-family: monospace; 57 | font-style: italic; 58 | } 59 | 60 | img.toplogo { 61 | width: 4em; 62 | vertical-align: middle; 63 | } 64 | 65 | img.arrow { 66 | width: 30px; 67 | height: 30px; 68 | border: 0; 69 | } 70 | 71 | span.acronym { 72 | font-size: small; 73 | } 74 | 75 | span.env { 76 | font-family: monospace; 77 | } 78 | 79 | span.file { 80 | font-family: monospace; 81 | } 82 | 83 | span.option{ 84 | font-family: monospace; 85 | } 86 | 87 | span.pkg { 88 | font-weight: bold; 89 | } 90 | 91 | span.samp{ 92 | font-family: monospace; 93 | } 94 | 95 | div.vignettes a:hover { 96 | background: rgb(85%, 85%, 85%); 97 | } 98 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/rlang/libs/rlang.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/rlang/libs/rlang.so -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: silicate 2 | Title: Common Forms for Complex Hierarchical and Relational Data 3 | Structures 4 | Version: 0.6.0 5 | Authors@R: c(person("Michael D.","Sumner", role = c("aut", "cre"), email = "mdsumner@gmail.com"), 6 | person("John", "Corbett", role = "ctb", comment = "the original inspiration"), 7 | person("Simon", "Wotherspoon", role = "ctb"), 8 | person("Kent", "Johnson", role = "dtc"), 9 | person("Mark", "Padgham", role = "aut") 10 | ) 11 | Description: Generate common data forms for complex data suitable for conversions and 12 | transmission by decomposition as paths or primitives. Paths are sequentially-linked records, 13 | primitives are basic atomic elements and both can model many forms and be grouped into hierarchical 14 | structures. The universal models 'SC0' (structural) and 'SC' (labelled, relational) are composed of 15 | edges and can represent any hierarchical form. Specialist models 'PATH', 'ARC' and 'TRI' provide the 16 | most common intermediate forms used for converting from one form to another. The methods are 17 | inspired by the simplicial complex and 18 | provide intermediate forms that relate spatial data structures to this mathematical construct. 19 | Depends: R (>= 3.4.0) 20 | License: GPL-3 21 | Encoding: UTF-8 22 | LazyData: true 23 | Suggests: covr, knitr, rmarkdown, sp, testthat (>= 2.1.0), trip, vdiffr 24 | RoxygenNote: 7.1.0 25 | Imports: dplyr, gibble (>= 0.4.0), methods, purrr, rlang, decido, 26 | tibble, unjoin (>= 0.1.0), grDevices, graphics, stats, 27 | magrittr, gridBase, crsmeta (>= 0.3.0) 28 | VignetteBuilder: knitr 29 | Roxygen: list(markdown = TRUE) 30 | URL: https://github.com/hypertidy/silicate 31 | BugReports: https://github.com/hypertidy/silicate/issues 32 | RemoteType: local 33 | RemoteUrl: /perm_storage/home/mdsumner/Git/silicate 34 | NeedsCompilation: no 35 | Packaged: 2020-05-11 12:09:55 UTC; mdsumner 36 | Author: Michael D. Sumner [aut, cre], 37 | John Corbett [ctb] (the original inspiration), 38 | Simon Wotherspoon [ctb], 39 | Kent Johnson [dtc], 40 | Mark Padgham [aut] 41 | Maintainer: Michael D. Sumner 42 | Built: R 3.6.3; ; 2020-05-11 12:09:57 UTC; unix 43 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/INDEX: -------------------------------------------------------------------------------- 1 | ARC ARC model 2 | PATH PATH model. 3 | PATH0 Path model in structural form 4 | SC The universal model 5 | SC0 Pure edge model, structural form 6 | TRI TRI model, triangulations 7 | TRI0 TRI0 model, structural triangulations 8 | dplyr-methods Dplyr methods for silicate objects 9 | ear_gc Geometry collection of triangles 10 | flight_tracks Flight tracks 11 | inlandwaters Inland waters, for parts of Australia, and New 12 | Caledonia. 13 | minimal_mesh Minimal mesh. 14 | mmesh Deprecated data set. 15 | plot.SC Plot silicate 16 | polymesh Polygonal mesh 17 | print.sc Methods for silicate 18 | routes Transport routes 19 | sc_arc Arc-node topology. 20 | sc_colours Silicate colours 21 | sc_coord Coordinate decomposition 22 | sc_edge Edges. 23 | sc_node Nodes for arc-node topology. 24 | sc_object Objects, features 25 | sc_path Path decomposition 26 | sc_segment Given a 'PATH" model decompose to 1-dimensional 27 | primitives (or 0-dimensional). 28 | sc_uid Unique labels 29 | sc_vertex Extract unique vertices 30 | sfzoo Simple features zoo. 31 | silicate silicate 32 | tri_area Area of triangles 33 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/Rd.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/Rd.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/data.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/data.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/features.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/features.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/hsearch.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/hsearch.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/links.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/links.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/nsInfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/nsInfo.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/Meta/package.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/Meta/package.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/R/silicate: -------------------------------------------------------------------------------- 1 | # File share/R/nspackloader.R 2 | # Part of the R package, http://www.R-project.org 3 | # 4 | # Copyright (C) 1995-2012 The R Core Team 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # A copy of the GNU General Public License is available at 17 | # http://www.r-project.org/Licenses/ 18 | 19 | local({ 20 | info <- loadingNamespaceInfo() 21 | pkg <- info$pkgname 22 | ns <- .getNamespace(as.name(pkg)) 23 | if (is.null(ns)) 24 | stop("cannot find namespace environment for ", pkg, domain = NA); 25 | dbbase <- file.path(info$libname, pkg, "R", pkg) 26 | lazyLoad(dbbase, ns, filter = function(n) n != ".__NAMESPACE__.") 27 | }) 28 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/R/silicate.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/R/silicate.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/R/silicate.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/R/silicate.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/R/sysdata.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/R/sysdata.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/R/sysdata.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/R/sysdata.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/arcs/tg.r: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(scsf) 3 | nc <- st_read(system.file("shape/nc.shp", package="sf")) 4 | prim <- PRIMITIVE(minimal_mesh)#[c(9, 15, 24, 5, 16, 31), ]) 5 | library(scgraph) 6 | library(igraph) 7 | library(ggraph) 8 | # ig <- scgraph::sc_as_igraph(prim) 9 | # ## this is unlikely to be the right order 10 | # E(ig)$segment <- prim$segment$segment_ 11 | # 12 | # ggraph(ig) + ggraph::geom_edge_link(aes(label = segment_)) 13 | 14 | ## find vertices that are nodes 15 | nodes <- sc_node(prim) 16 | 17 | split_at <- function(x, vertex) { 18 | x$order <- seq(nrow(x)) 19 | test <- x$vertex_ %in% vertex 20 | if (!any(test)) return(list(x)) 21 | segs <- c(1, cumsum(abs(diff(test)))) 22 | split(x, segs) 23 | } 24 | library(tidyverse) 25 | arcs <- bind_rows(unlist(lapply(prim$path_link_vertex %>% split(.$path_), function(x) split_at(x, nodes$vertex_)), recursive = FALSE), .id = "arc") 26 | #arcs <- arcs %>% distinct(path_, vertex_, .keep_all = TRUE) 27 | ggplot(arcs %>% left_join(prim$vertex) %>% arrange(arc, order), 28 | aes(x_, y_, group = arc, colour = arc)) + geom_path(lwd = 3) + guides(colour = FALSE) 29 | 30 | plot(igraph::induced_subgraph(ig, nodes$vertex_) ) 31 | # ## process all paths into arcs 32 | # 33 | # all_paths <- sc_path(prim) %>% select(path_, object_) #distinct(path_) 34 | # for (ipath in seq_len(nrow(all_paths))) { 35 | # all_paths %>% slice(ipath) %>% left_join(prim$path_link_vertex) %>% inner_join(nodes) 36 | # } -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/data/Rdata.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/data/Rdata.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/data/Rdata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/data/Rdata.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/data/Rdata.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/data/Rdata.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/file.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { "type": "Feature", "properties": { "a": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 0.75, 1.0 ], [ 1.0, 0.8 ], [ 0.5, 0.7 ], [ 0.8, 0.6 ], [ 0.69, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.2, 0.2 ], [ 0.5, 0.2 ], [ 0.5, 0.4 ], [ 0.3, 0.6 ], [ 0.2, 0.4 ], [ 0.2, 0.2 ] ] ] ] } }, 5 | { "type": "Feature", "properties": { "a": 2 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.69, 0.0 ], [ 0.8, 0.6 ], [ 1.1, 0.63 ], [ 1.23, 0.3 ], [ 0.69, 0.0 ] ] ] ] } } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/flight_tracks/flight_tracks.R: -------------------------------------------------------------------------------- 1 | #from https://github.com/r-spatial/mapview/issues/99#issuecomment-328711275 2 | 3 | #> Attached is a zipped shapefile containing 144 flight tracks of aircraft #departing runway 4 | #> 33L at Boston Logan airport on June 28, 2017. Data is from an ADS-B recorder so it is 5 | #> kind of rough. Each point includes lat, lon, altitude in feet and time in EDT. #Unzip and 6 | #> read > with 7 | #> st_read('tracks.shp') 8 | #> 9 | 10 | #saved as inst/exdata/flight_tracks/tracks.shp/prj/dbf/shx 11 | 12 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.dbf -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.shp -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/extdata/flight_tracks/tracks.shx -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/help/aliases.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/help/aliases.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/help/paths.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/help/paths.rds -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/help/silicate.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/help/silicate.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/help/silicate.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/help/silicate.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/html/R.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white; 3 | color: black; 4 | } 5 | 6 | a:link { 7 | background: white; 8 | color: blue; 9 | } 10 | 11 | a:visited { 12 | background: white; 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | h1 { 17 | background: white; 18 | color: rgb(55%, 55%, 55%); 19 | font-family: monospace; 20 | font-size: x-large; 21 | text-align: center; 22 | } 23 | 24 | h2 { 25 | background: white; 26 | color: rgb(40%, 40%, 40%); 27 | font-family: monospace; 28 | font-size: large; 29 | text-align: center; 30 | } 31 | 32 | h3 { 33 | background: white; 34 | color: rgb(40%, 40%, 40%); 35 | font-family: monospace; 36 | font-size: large; 37 | } 38 | 39 | h4 { 40 | background: white; 41 | color: rgb(40%, 40%, 40%); 42 | font-family: monospace; 43 | font-style: italic; 44 | font-size: large; 45 | } 46 | 47 | h5 { 48 | background: white; 49 | color: rgb(40%, 40%, 40%); 50 | font-family: monospace; 51 | } 52 | 53 | h6 { 54 | background: white; 55 | color: rgb(40%, 40%, 40%); 56 | font-family: monospace; 57 | font-style: italic; 58 | } 59 | 60 | img.toplogo { 61 | width: 4em; 62 | vertical-align: middle; 63 | } 64 | 65 | img.arrow { 66 | width: 30px; 67 | height: 30px; 68 | border: 0; 69 | } 70 | 71 | span.acronym { 72 | font-size: small; 73 | } 74 | 75 | span.env { 76 | font-family: monospace; 77 | } 78 | 79 | span.file { 80 | font-family: monospace; 81 | } 82 | 83 | span.option{ 84 | font-family: monospace; 85 | } 86 | 87 | span.pkg { 88 | font-weight: bold; 89 | } 90 | 91 | span.samp{ 92 | font-family: monospace; 93 | } 94 | 95 | div.vignettes a:hover { 96 | background: rgb(85%, 85%, 85%); 97 | } 98 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/misc/ARC-data.R: -------------------------------------------------------------------------------- 1 | v <- sf::read_sf(raadfiles::thelist_files(pattern = "transport_segments_hobart")$fullname[1]) 2 | 3 | library(silicate) 4 | n <- 2697 5 | sfx <- v[sort(unique(c(n, unlist(sf::st_touches(sf::st_geometry(v)[n], sf::st_geometry(v)))))), ] 6 | 7 | sfy <- spex::polygonize(raster::raster(matrix(1:2, ncol = 2))) 8 | 9 | library(sf) 10 | sc <- SC0(sfx) 11 | plot(sc, col = rgb(0, 0, 0, 0.5), lwd = 15, asp = 1) 12 | plot(sfx[1], lwd = 3, reset = FALSE) 13 | text(sc$vertex, lab = 1:nrow(sc$vertex), pos = 1:4, cex = 0.8, offset = 0.3) 14 | 15 | 16 | 17 | ## on creation, SC0 has all edge instances in the order they occur 18 | sc$object$object_ <- seq_len(nrow(sc$object)) 19 | edge <- tidyr::unnest(sc$object[c("object_", "topology_")]) 20 | 21 | 22 | v_0 <- pmin(edge$.vx0, edge$.vx1) 23 | v_1 <- pmax(edge$.vx0, edge$.vx1) 24 | edge$native_ <- v_0 == edge$.vx0 ## if TRUE the orientation is how it came in 25 | 26 | uedge <- edge 27 | ## we now have ordered edges 28 | uedge[[".uvx0"]] <- v_0 29 | uedge[[".uvx1"]] <- v_1 30 | 31 | uedge[["u_edge"]] <- dplyr::group_indices(dplyr::group_by(uedge, ".uvx0", ".uvx1")) 32 | 33 | 34 | uedge %>% group_by(.uvx0, .uvx1) %>% tally() %>% print(n = Inf) 35 | ## nodes that occur twice or more 36 | shared_verts <- uedge$.uvx0[which(!match(uedge$.uvx1, uedge$.uvx0) == (seq_len(nrow(uedge)) - 1))] 37 | 38 | 39 | ## nodes that occur only once (for lines) 40 | terminal_verts <- tibble::tibble(vertex_ = as.vector(t(as.matrix(edge[c(".vx0", ".vx1")])))) %>% 41 | dplyr::count("vertex_") %>% dplyr::filter(n == 1) %>% dplyr::pull("vertex_") 42 | 43 | plot(sfx[1], lwd = c(10, 2), reset = FALSE) 44 | if (length(shared_verts) > 0) points(sc$vertex[shared_verts, c("x_", "y_")], col = "red", cex = 1.5) 45 | if (length(terminal_verts) > 0) points(sc$vertex[terminal_verts, c("x_", "y_")], col = "green", cex = 1, pch = 19) 46 | 47 | points(sc$vertex[c("x_", "y_")], pch = sample(1:23), cex = c(1:3)) 48 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/misc/geospatialsci-2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/new/silicate/misc/geospatialsci-2018.pdf -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/misc/makefile: -------------------------------------------------------------------------------- 1 | FILE=geospatialsci-2018 2 | TEMPLATE=template 3 | PREFLAGS=--variable geometry="margin=2.54cm" \ 4 | --variable linestretch=1.6 \ 5 | --variable mainfont="Times New Roman" 6 | POSTFLAGS= 7 | 8 | all: pdf 9 | 10 | pdf: $(FILE).md 11 | pandoc -s $(PREFLAGS) $(FILE).md -o $(FILE).pdf $(POSTFAGS) 12 | 13 | open: $(FILE).pdf 14 | xdg-open $(FILE).pdf & 15 | -------------------------------------------------------------------------------- /revdep/library/silicate/new/silicate/misc/validity.R: -------------------------------------------------------------------------------- 1 | tri_fix <- function(x) { 2 | sf::st_cast(sfdct::ct_triangulate(x)) %>% sf::st_is_valid() 3 | } 4 | 5 | sil_fix <- function(x) { 6 | sc <- silicate::SC(x) 7 | seg <- silicate::sc_segment(x) 8 | 9 | } 10 | #A 'bowtie' polygon: 11 | 12 | bowtie <- "POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))" 13 | x <- sf::st_as_sfc(bowtie) 14 | sf::st_is_valid(x) 15 | tri_fix(x) 16 | 17 | #' Square with wrong orientation: 18 | 19 | sq_wo <- "POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))" 20 | x <- sf::st_as_sfc(sq_wo) 21 | sf::st_is_valid(x) 22 | tri_fix(x) 23 | 24 | #' Inner ring with one edge sharing part of an edge of the outer ring: 25 | ir_share <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 2,5 7,10 7, 10 2, 5 2))" 26 | x <- sf::st_as_sfc(ir_share) 27 | sf::st_is_valid(x) 28 | tri_fix(x) 29 | 30 | 31 | #' Dangling edge: 32 | 33 | de <- "POLYGON((0 0, 10 0, 15 5, 10 0, 10 10, 0 10, 0 0))" 34 | x <- sf::st_as_sfc(de) 35 | sf::st_is_valid(x) 36 | tri_fix(x) 37 | 38 | #' Outer ring not closed: 39 | 40 | ornc <- "POLYGON((0 0, 10 0, 10 10, 0 10))" 41 | x <- sf::st_as_sfc(ornc) 42 | sf::st_is_valid(x) 43 | tri_fix(x) 44 | 45 | ## sfdct currently can't fix this one, but 46 | sc <- silicate::SC(x) 47 | 48 | p <- RTriangle::pslg(S = matrix(match(as.matrix(sc$edge %>% dplyr::select(.vertex0, .vertex1)), sc$vertex$vertex_), ncol = 2), 49 | P = as.matrix(sc$vertex %>% dplyr::select(x_, y_))) 50 | tr <- RTriangle::triangulate(p, a = 1) 51 | purrr::transpose(sc$edge) %>% 52 | purrr::map(~tibble::tibble(vertex_ = unlist(.x[c(".vertex0", ".vertex1")])) %>% 53 | dplyr::inner_join(sc$vertex)) 54 | 55 | #Two adjacent inner rings: 56 | 57 | tr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 8, 3 8, 3 1, 1 1), (3 1, 3 8, 5 8, 5 1, 3 1))" 58 | x <- sf::st_as_sfc(tr) 59 | sf::st_is_valid(x) 60 | tri_fix(x) 61 | 62 | #Polygon with an inner ring inside another inner ring: 63 | 64 | pr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (2 8, 5 8, 5 2, 2 2, 2 8), (3 3, 4 3, 3 4, 3 3))" 65 | x <- sf::st_as_sfc(pr) 66 | sf::st_is_valid(x) 67 | tri_fix(x) 68 | 69 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: silicate 2 | Title: Common Forms for Complex Hierarchical and Relational Data 3 | Structures 4 | Version: 0.4.0 5 | Authors@R: c(person("Michael D.","Sumner", role = c("aut", "cre"), email = "mdsumner@gmail.com"), 6 | person("John", "Corbett", role = "ctb", comment = "the original inspiration"), 7 | person("Simon", "Wotherspoon", role = "ctb"), 8 | person("Kent", "Johnson", role = "dtc"), 9 | person("Mark", "Padgham", role = "aut") 10 | ) 11 | Description: Generate common data forms for complex data suitable for conversions and 12 | transmission by decomposition as paths or primitives. Paths are sequentially-linked records, 13 | primitives are basic atomic elements and both can model many forms and be grouped into hierarchical 14 | structures. The universal models 'SC0' (structural) and 'SC' (labelled, relational) are composed of 15 | edges and can represent any hierarchical form. Specialist models 'PATH', 'ARC' and 'TRI' provide the 16 | most common intermediate forms used for converting from one form to another. The methods are 17 | inspired by the simplicial complex and 18 | provide intermediate forms that relate spatial data structures to this mathematical construct. 19 | Depends: R (>= 3.4.0) 20 | License: GPL-3 21 | Encoding: UTF-8 22 | LazyData: true 23 | Suggests: covr, knitr, rmarkdown, sp, testthat (>= 2.1.0), trip, vdiffr 24 | RoxygenNote: 7.1.0 25 | Imports: dplyr, gibble (>= 0.2.0), methods, purrr, rlang, decido, 26 | tibble, unjoin (>= 0.0.3), grDevices, graphics, stats, 27 | magrittr, gridBase, crsmeta (>= 0.3.0) 28 | VignetteBuilder: knitr 29 | URL: https://github.com/hypertidy/silicate 30 | BugReports: https://github.com/hypertidy/silicate/issues 31 | NeedsCompilation: no 32 | Packaged: 2020-04-15 15:20:22 UTC; mdsumner 33 | Author: Michael D. Sumner [aut, cre], 34 | John Corbett [ctb] (the original inspiration), 35 | Simon Wotherspoon [ctb], 36 | Kent Johnson [dtc], 37 | Mark Padgham [aut] 38 | Maintainer: Michael D. Sumner 39 | Repository: CRAN 40 | Date/Publication: 2020-04-15 17:20:02 UTC 41 | Built: R 3.6.3; ; 2020-05-11 12:09:21 UTC; unix 42 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/INDEX: -------------------------------------------------------------------------------- 1 | ARC ARC model 2 | PATH PATH model. 3 | PATH0 Path model in structural form 4 | SC The universal model 5 | SC0 Pure edge model, structural form 6 | TRI TRI model, triangulations 7 | TRI0 TRI0 model, structural triangulations 8 | dplyr-methods Dplyr methods for silicate objects 9 | flight_tracks Flight tracks 10 | inlandwaters Inland waters, for parts of Australia, and New 11 | Caledonia. 12 | minimal_mesh Minimal mesh. 13 | mmesh Deprecated data set. 14 | plot.SC Plot silicate 15 | polymesh Polygonal mesh 16 | print.sc Methods for silicate 17 | routes Transport routes 18 | sc_arc Arc-node topology. 19 | sc_colours Silicate colours 20 | sc_coord Coordinate decomposition 21 | sc_edge Edges. 22 | sc_node Nodes for arc-node topology. 23 | sc_object Objects, features 24 | sc_path Path decomposition 25 | sc_segment Given a 'PATH" model decompose to 1-dimensional 26 | primitives (or 0-dimensional). 27 | sc_uid Unique labels 28 | sc_vertex Extract unique vertices 29 | sfzoo Simple features zoo. 30 | silicate silicate 31 | tri_area Area of triangles 32 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/Rd.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/Rd.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/data.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/data.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/features.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/features.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/hsearch.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/hsearch.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/links.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/links.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/nsInfo.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/nsInfo.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/package.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/package.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/Meta/vignette.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/Meta/vignette.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/R/silicate: -------------------------------------------------------------------------------- 1 | # File share/R/nspackloader.R 2 | # Part of the R package, http://www.R-project.org 3 | # 4 | # Copyright (C) 1995-2012 The R Core Team 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # A copy of the GNU General Public License is available at 17 | # http://www.r-project.org/Licenses/ 18 | 19 | local({ 20 | info <- loadingNamespaceInfo() 21 | pkg <- info$pkgname 22 | ns <- .getNamespace(as.name(pkg)) 23 | if (is.null(ns)) 24 | stop("cannot find namespace environment for ", pkg, domain = NA); 25 | dbbase <- file.path(info$libname, pkg, "R", pkg) 26 | lazyLoad(dbbase, ns, filter = function(n) n != ".__NAMESPACE__.") 27 | }) 28 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/R/silicate.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/R/silicate.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/R/silicate.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/R/silicate.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/R/sysdata.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/R/sysdata.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/R/sysdata.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/R/sysdata.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/arcs/tg.r: -------------------------------------------------------------------------------- 1 | library(sf) 2 | library(scsf) 3 | nc <- st_read(system.file("shape/nc.shp", package="sf")) 4 | prim <- PRIMITIVE(minimal_mesh)#[c(9, 15, 24, 5, 16, 31), ]) 5 | library(scgraph) 6 | library(igraph) 7 | library(ggraph) 8 | # ig <- scgraph::sc_as_igraph(prim) 9 | # ## this is unlikely to be the right order 10 | # E(ig)$segment <- prim$segment$segment_ 11 | # 12 | # ggraph(ig) + ggraph::geom_edge_link(aes(label = segment_)) 13 | 14 | ## find vertices that are nodes 15 | nodes <- sc_node(prim) 16 | 17 | split_at <- function(x, vertex) { 18 | x$order <- seq(nrow(x)) 19 | test <- x$vertex_ %in% vertex 20 | if (!any(test)) return(list(x)) 21 | segs <- c(1, cumsum(abs(diff(test)))) 22 | split(x, segs) 23 | } 24 | library(tidyverse) 25 | arcs <- bind_rows(unlist(lapply(prim$path_link_vertex %>% split(.$path_), function(x) split_at(x, nodes$vertex_)), recursive = FALSE), .id = "arc") 26 | #arcs <- arcs %>% distinct(path_, vertex_, .keep_all = TRUE) 27 | ggplot(arcs %>% left_join(prim$vertex) %>% arrange(arc, order), 28 | aes(x_, y_, group = arc, colour = arc)) + geom_path(lwd = 3) + guides(colour = FALSE) 29 | 30 | plot(igraph::induced_subgraph(ig, nodes$vertex_) ) 31 | # ## process all paths into arcs 32 | # 33 | # all_paths <- sc_path(prim) %>% select(path_, object_) #distinct(path_) 34 | # for (ipath in seq_len(nrow(all_paths))) { 35 | # all_paths %>% slice(ipath) %>% left_join(prim$path_link_vertex) %>% inner_join(nodes) 36 | # } -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/data/Rdata.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/data/Rdata.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/data/Rdata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/data/Rdata.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/data/Rdata.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/data/Rdata.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | R: Vignettes and other documentation 4 | 5 | 6 | 7 |

Vignettes and other documentation 8 | 9 |

10 |
11 |
12 | [Top] 13 |
14 |

Vignettes from package 'silicate'

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
silicate::silicate-data-modelsilicate-data-modelHTMLsourceR code
silicate::silicate_topology_01silicate topologyHTMLsourceR code
33 | 34 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/doc/silicate-data-model.R: -------------------------------------------------------------------------------- 1 | ## ---- include = FALSE--------------------------------------------------------- 2 | knitr::opts_chunk$set( 3 | collapse = TRUE, 4 | comment = "#>" 5 | ) 6 | 7 | ## ----setup-------------------------------------------------------------------- 8 | library(silicate) 9 | 10 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/doc/silicate_topology_01.R: -------------------------------------------------------------------------------- 1 | ## ----setup, include=FALSE----------------------------------------------------- 2 | knitr::opts_chunk$set(echo = TRUE) 3 | library(dplyr) 4 | 5 | ## ----minimal_mesh------------------------------------------------------------- 6 | library(silicate) 7 | 8 | plot(matrix(attr(minimal_mesh$geom, "bbox"), 2, byrow = TRUE), type = "n", xlab = "", ylab = "") 9 | rbind_na <- function(x) head(do.call(rbind, unlist(lapply(x, function(a) rbind(a, NA)), recursive = F)), -1) 10 | cols <- sc_colours(nrow(minimal_mesh)) 11 | junk <- lapply(seq_along(minimal_mesh$geom), function(y) polypath(rbind_na(minimal_mesh$geom[[y]]), col = cols[y] )) 12 | 13 | 14 | 15 | ## ----sc----------------------------------------------------------------------- 16 | x <- SC(minimal_mesh) 17 | names(x) 18 | x$edge 19 | print(x) 20 | plot(x) 21 | text(x$vertex[c("x_", "y_")], label = x$vertex$vertex_) 22 | 23 | ## ----PATH--------------------------------------------------------------------- 24 | x <- PATH(minimal_mesh) 25 | names(x) 26 | 27 | ## ----reduce-path-------------------------------------------------------------- 28 | 29 | purrr::reduce(x[c("object", "path", "path_link_vertex", "vertex")], dplyr::inner_join) 30 | 31 | ## ----arc-node----------------------------------------------------------------- 32 | library(dplyr) 33 | arc <- ARC(minimal_mesh) 34 | nodes <- sc_node(arc) 35 | 36 | plot(arc) 37 | inner_join(nodes, arc$vertex) %>% dplyr::select(x_, y_) %>% points(pch = "N") 38 | 39 | 40 | ## ----TRI---------------------------------------------------------------------- 41 | tri <- TRI(minimal_mesh) 42 | plot(tri) 43 | 44 | ## ----------------------------------------------------------------------------- 45 | #system.time(sf::st_triangulate(inlandwaters)) 46 | # user system elapsed 47 | # 4.699 0.125 4.823 48 | #system.time(sfdct::ct_triangulate(inlandwaters)) 49 | # user system elapsed 50 | # 15.476 0.225 15.460 51 | system.time(tri <- TRI(inlandwaters)) 52 | 53 | ## ----------------------------------------------------------------------------- 54 | plot(tri) 55 | 56 | plot(NA, xlim = c(625000, 1060000), ylim = c(-1350000, -550000)) 57 | plot(tri, add = TRUE) 58 | 59 | ## ----sfdct,eval=FALSE--------------------------------------------------------- 60 | # #plot(sfdct::ct_triangulate(minimal_mesh)) 61 | 62 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/file.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { "type": "Feature", "properties": { "a": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 0.75, 1.0 ], [ 1.0, 0.8 ], [ 0.5, 0.7 ], [ 0.8, 0.6 ], [ 0.69, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.2, 0.2 ], [ 0.5, 0.2 ], [ 0.5, 0.4 ], [ 0.3, 0.6 ], [ 0.2, 0.4 ], [ 0.2, 0.2 ] ] ] ] } }, 5 | { "type": "Feature", "properties": { "a": 2 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 0.69, 0.0 ], [ 0.8, 0.6 ], [ 1.1, 0.63 ], [ 1.23, 0.3 ], [ 0.69, 0.0 ] ] ] ] } } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/flight_tracks/flight_tracks.R: -------------------------------------------------------------------------------- 1 | #from https://github.com/r-spatial/mapview/issues/99#issuecomment-328711275 2 | 3 | #> Attached is a zipped shapefile containing 144 flight tracks of aircraft #departing runway 4 | #> 33L at Boston Logan airport on June 28, 2017. Data is from an ADS-B recorder so it is 5 | #> kind of rough. Each point includes lat, lon, altitude in feet and time in EDT. #Unzip and 6 | #> read > with 7 | #> st_read('tracks.shp') 8 | #> 9 | 10 | #saved as inst/exdata/flight_tracks/tracks.shp/prj/dbf/shx 11 | 12 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.dbf -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.shp -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/extdata/flight_tracks/tracks.shx -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/help/aliases.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/help/aliases.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/help/paths.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/help/paths.rds -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/help/silicate.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/help/silicate.rdb -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/help/silicate.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/help/silicate.rdx -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/html/R.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white; 3 | color: black; 4 | } 5 | 6 | a:link { 7 | background: white; 8 | color: blue; 9 | } 10 | 11 | a:visited { 12 | background: white; 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | h1 { 17 | background: white; 18 | color: rgb(55%, 55%, 55%); 19 | font-family: monospace; 20 | font-size: x-large; 21 | text-align: center; 22 | } 23 | 24 | h2 { 25 | background: white; 26 | color: rgb(40%, 40%, 40%); 27 | font-family: monospace; 28 | font-size: large; 29 | text-align: center; 30 | } 31 | 32 | h3 { 33 | background: white; 34 | color: rgb(40%, 40%, 40%); 35 | font-family: monospace; 36 | font-size: large; 37 | } 38 | 39 | h4 { 40 | background: white; 41 | color: rgb(40%, 40%, 40%); 42 | font-family: monospace; 43 | font-style: italic; 44 | font-size: large; 45 | } 46 | 47 | h5 { 48 | background: white; 49 | color: rgb(40%, 40%, 40%); 50 | font-family: monospace; 51 | } 52 | 53 | h6 { 54 | background: white; 55 | color: rgb(40%, 40%, 40%); 56 | font-family: monospace; 57 | font-style: italic; 58 | } 59 | 60 | img.toplogo { 61 | width: 4em; 62 | vertical-align: middle; 63 | } 64 | 65 | img.arrow { 66 | width: 30px; 67 | height: 30px; 68 | border: 0; 69 | } 70 | 71 | span.acronym { 72 | font-size: small; 73 | } 74 | 75 | span.env { 76 | font-family: monospace; 77 | } 78 | 79 | span.file { 80 | font-family: monospace; 81 | } 82 | 83 | span.option{ 84 | font-family: monospace; 85 | } 86 | 87 | span.pkg { 88 | font-weight: bold; 89 | } 90 | 91 | span.samp{ 92 | font-family: monospace; 93 | } 94 | 95 | div.vignettes a:hover { 96 | background: rgb(85%, 85%, 85%); 97 | } 98 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/misc/ARC-data.R: -------------------------------------------------------------------------------- 1 | v <- sf::read_sf(raadfiles::thelist_files(pattern = "transport_segments_hobart")$fullname[1]) 2 | 3 | library(silicate) 4 | n <- 2697 5 | sfx <- v[sort(unique(c(n, unlist(sf::st_touches(sf::st_geometry(v)[n], sf::st_geometry(v)))))), ] 6 | 7 | sfy <- spex::polygonize(raster::raster(matrix(1:2, ncol = 2))) 8 | 9 | library(sf) 10 | sc <- SC0(sfx) 11 | plot(sc, col = rgb(0, 0, 0, 0.5), lwd = 15, asp = 1) 12 | plot(sfx[1], lwd = 3, reset = FALSE) 13 | text(sc$vertex, lab = 1:nrow(sc$vertex), pos = 1:4, cex = 0.8, offset = 0.3) 14 | 15 | 16 | 17 | ## on creation, SC0 has all edge instances in the order they occur 18 | sc$object$object_ <- seq_len(nrow(sc$object)) 19 | edge <- tidyr::unnest(sc$object[c("object_", "topology_")]) 20 | 21 | 22 | v_0 <- pmin(edge$.vx0, edge$.vx1) 23 | v_1 <- pmax(edge$.vx0, edge$.vx1) 24 | edge$native_ <- v_0 == edge$.vx0 ## if TRUE the orientation is how it came in 25 | 26 | uedge <- edge 27 | ## we now have ordered edges 28 | uedge[[".uvx0"]] <- v_0 29 | uedge[[".uvx1"]] <- v_1 30 | 31 | uedge[["u_edge"]] <- dplyr::group_indices(uedge, ".uvx0", ".uvx1") 32 | 33 | 34 | uedge %>% group_by(.uvx0, .uvx1) %>% tally() %>% print(n = Inf) 35 | ## nodes that occur twice or more 36 | shared_verts <- uedge$.uvx0[which(!match(uedge$.uvx1, uedge$.uvx0) == (seq_len(nrow(uedge)) - 1))] 37 | 38 | 39 | ## nodes that occur only once (for lines) 40 | terminal_verts <- tibble::tibble(vertex_ = as.vector(t(as.matrix(edge[c(".vx0", ".vx1")])))) %>% 41 | dplyr::count("vertex_") %>% dplyr::filter(n == 1) %>% dplyr::pull("vertex_") 42 | 43 | plot(sfx[1], lwd = c(10, 2), reset = FALSE) 44 | if (length(shared_verts) > 0) points(sc$vertex[shared_verts, c("x_", "y_")], col = "red", cex = 1.5) 45 | if (length(terminal_verts) > 0) points(sc$vertex[terminal_verts, c("x_", "y_")], col = "green", cex = 1, pch = 19) 46 | 47 | points(sc$vertex[c("x_", "y_")], pch = sample(1:23), cex = c(1:3)) 48 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/misc/geospatialsci-2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypertidy/silicate/959394e222f938ce40ea5f1b4d86cde48c0f2f5c/revdep/library/silicate/old/silicate/misc/geospatialsci-2018.pdf -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/misc/makefile: -------------------------------------------------------------------------------- 1 | FILE=geospatialsci-2018 2 | TEMPLATE=template 3 | PREFLAGS=--variable geometry="margin=2.54cm" \ 4 | --variable linestretch=1.6 \ 5 | --variable mainfont="Times New Roman" 6 | POSTFLAGS= 7 | 8 | all: pdf 9 | 10 | pdf: $(FILE).md 11 | pandoc -s $(PREFLAGS) $(FILE).md -o $(FILE).pdf $(POSTFAGS) 12 | 13 | open: $(FILE).pdf 14 | xdg-open $(FILE).pdf & 15 | -------------------------------------------------------------------------------- /revdep/library/silicate/old/silicate/misc/validity.R: -------------------------------------------------------------------------------- 1 | tri_fix <- function(x) { 2 | sf::st_cast(sfdct::ct_triangulate(x)) %>% sf::st_is_valid() 3 | } 4 | 5 | sil_fix <- function(x) { 6 | sc <- silicate::SC(x) 7 | seg <- silicate::sc_segment(x) 8 | 9 | } 10 | #A 'bowtie' polygon: 11 | 12 | bowtie <- "POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))" 13 | x <- sf::st_as_sfc(bowtie) 14 | sf::st_is_valid(x) 15 | tri_fix(x) 16 | 17 | #' Square with wrong orientation: 18 | 19 | sq_wo <- "POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))" 20 | x <- sf::st_as_sfc(sq_wo) 21 | sf::st_is_valid(x) 22 | tri_fix(x) 23 | 24 | #' Inner ring with one edge sharing part of an edge of the outer ring: 25 | ir_share <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 2,5 7,10 7, 10 2, 5 2))" 26 | x <- sf::st_as_sfc(ir_share) 27 | sf::st_is_valid(x) 28 | tri_fix(x) 29 | 30 | 31 | #' Dangling edge: 32 | 33 | de <- "POLYGON((0 0, 10 0, 15 5, 10 0, 10 10, 0 10, 0 0))" 34 | x <- sf::st_as_sfc(de) 35 | sf::st_is_valid(x) 36 | tri_fix(x) 37 | 38 | #' Outer ring not closed: 39 | 40 | ornc <- "POLYGON((0 0, 10 0, 10 10, 0 10))" 41 | x <- sf::st_as_sfc(ornc) 42 | sf::st_is_valid(x) 43 | tri_fix(x) 44 | 45 | ## sfdct currently can't fix this one, but 46 | sc <- silicate::SC(x) 47 | 48 | p <- RTriangle::pslg(S = matrix(match(as.matrix(sc$edge %>% dplyr::select(.vertex0, .vertex1)), sc$vertex$vertex_), ncol = 2), 49 | P = as.matrix(sc$vertex %>% dplyr::select(x_, y_))) 50 | tr <- RTriangle::triangulate(p, a = 1) 51 | purrr::transpose(sc$edge) %>% 52 | purrr::map(~tibble::tibble(vertex_ = unlist(.x[c(".vertex0", ".vertex1")])) %>% 53 | dplyr::inner_join(sc$vertex)) 54 | 55 | #Two adjacent inner rings: 56 | 57 | tr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 8, 3 8, 3 1, 1 1), (3 1, 3 8, 5 8, 5 1, 3 1))" 58 | x <- sf::st_as_sfc(tr) 59 | sf::st_is_valid(x) 60 | tri_fix(x) 61 | 62 | #Polygon with an inner ring inside another inner ring: 63 | 64 | pr <- "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0), (2 8, 5 8, 5 2, 2 2, 2 8), (3 3, 4 3, 3 4, 3 3))" 65 | x <- sf::st_as_sfc(pr) 66 | sf::st_is_valid(x) 67 | tri_fix(x) 68 | 69 | -------------------------------------------------------------------------------- /revdep/problems.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(silicate) 3 | 4 | test_check("silicate") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-arc.R: -------------------------------------------------------------------------------- 1 | context("test-arc-tests.R") 2 | 3 | #attr(minimal_mesh$geom, "crs") 4 | test_that("ARC for non polygons is a warnable offence", { 5 | arc <- ARC(minimal_mesh) 6 | expect_equal(nrow(arc$object), 2L) 7 | expect_equal(length(unique(ARC(minimal_mesh)$object_link_arc %>% group_by(object_, arc_) %>% dplyr::group_indices())), 5L) 8 | 9 | expect_s3_class(arc, "sc") 10 | expect_warning(ARC(minimal_line), "ARC is not well-defined unless used on polygon layers") 11 | 12 | expect_named(sc_coord(arc), c("x_", "y_")) 13 | expect_named(sc_path(arc), c("ncol", "type", "subobject", "object_", "path_", "ncoords_" 14 | )) 15 | }) 16 | 17 | -------------------------------------------------------------------------------- /tests/testthat/test-as_tibble.R: -------------------------------------------------------------------------------- 1 | test_that("no new tibble messages", { 2 | skip_if_not_installed("sp") 3 | library(sp) 4 | xsp <- .nc_sp ## needed to flush sp messages (or something) 5 | expect_silent(x <- SC0(xsp)) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test-degenerate.R: -------------------------------------------------------------------------------- 1 | context("test-degenerate.R") 2 | gm <- tibble::tibble(nrow = 5L, ncol = 2L, type = "POLYGON", object_ = 1L) 3 | cd <- tibble::as_tibble(list(x_ = c(153.185183093, 153.185183093, 153.19443135, 4 | 153.19443135, 153.185183093), 5 | y_ = c(-27.705328446, -27.6967222119999, -27.6967222119999, -27.705328446, 6 | -27.705328446))) 7 | my_extent <- structure(list(geometry = raw_build_sfc(gm, cd)), 8 | class = c("sf", "data.frame"), row.names = "1", sf_column = "geometry", agr = factor(c("constant", "aggregate", "identity"))) 9 | 10 | test_that("sanity reigns", { 11 | expect_equal(nrow(my_extent), nrow(silicate::PATH(my_extent)$object)) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test-dplyr.R: -------------------------------------------------------------------------------- 1 | context("test-dplyr") 2 | 3 | test_that("filter works", { 4 | sc <- SC(minimal_mesh) 5 | sc0 <- SC0(minimal_mesh) 6 | expect_equal(filter(sc), sc) 7 | # expect_equal(filter(sc0), sc0) 8 | 9 | expect_equal(nrow(filter(sc, a== 1)$object), 1L) 10 | # expect_equal(filter(sc0), sc0) 11 | 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test-earcut.R: -------------------------------------------------------------------------------- 1 | context("test-earcut") 2 | 3 | test_that("earcut works", { 4 | idx<- c(9L, 8L, 7L, 5L, 4L, 3L, 2L, 1L, 12L, 10L, 9L, 7L, 7L, 12L, 5 | 1L, 5L, 3L, 2L, 2L, 12L, 11L, 5L, 2L, 11L, 6L, 5L, 11L, 6L, 11L, 6 | 10L, 1L, 6L, 10L, 6L, 7L, 14L, 14L, 13L, 6L) 7 | earcut_PATH(PATH(minimal_mesh), equals(idx)) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test-generic-data.R: -------------------------------------------------------------------------------- 1 | context("test-generic-data.R") 2 | x <- c(.1, .1, .9, .9, NA, .2, .2, .8, .8) 3 | y <- c(.1, .9, .9, .1, NA, .2, .8, .8, .2) 4 | 5 | poly <- list(x = x, y = y) 6 | 7 | napos <- c(5, 15, 23, 80) 8 | l <- setNames(lapply(1:5, function(ignore) {x <- rnorm(100); x[napos] <- NA; x}), c("x", "y", "z", "a", "b")) 9 | 10 | m <- cbind(x, y) 11 | d <- data.frame(a = x[1:4], y = y[1:4]) 12 | d1 <- data.frame(x = x, y = y) 13 | test_that("generic forms are understood", { 14 | expect_equal(sc_coord(poly), tibble::tibble(x = x, y = y)[!is.na(x), ]) 15 | expect_equal(sc_path(poly), tibble::tibble(nrow = c(4L, 4L))) 16 | 17 | sc_coord(l) %>% expect_s3_class("tbl_df") %>% expect_length(5L) 18 | sc_path(l) %>% expect_s3_class("tbl_df") %>% expect_length(1L) 19 | 20 | ## no separators 21 | sc_coord(d) %>% expect_s3_class("tbl_df") %>% expect_length(2L) 22 | expect_error(sc_path(d)) 23 | }) 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/testthat/test-geometry-dim.R: -------------------------------------------------------------------------------- 1 | ## .tr and .xyz are internal data 2 | skip_if_not_installed("trip") 3 | test_that("dimensionality works", { 4 | 5 | 6 | expect_named(TRI(.xyz)$vertex, c("x_", "y_", "z_", "vertex_")) 7 | expect_named(TRI0(.xyz)$vertex, c("x_", "y_", "z_")) 8 | 9 | expect_named(SC(.xyz)$vertex, c("x_", "y_", "z_", "vertex_")) 10 | expect_named(SC0(.xyz)$vertex, c("x_", "y_", "z_")) 11 | 12 | expect_named(PATH(.xyz)$vertex, c("x_", "y_", "z_", "vertex_")) 13 | expect_named(PATH0(.xyz)$vertex, c("x_", "y_", "z_")) 14 | 15 | expect_warning(expect_named(ARC(.xyz)$vertex, c("x_", "y_", "z_", "vertex_"))) 16 | #expect_named(ARC0(.xyz)$vertex, c("x_", "y_", "z_")) 17 | 18 | .trnames <- c("x_", "y_", "t_", "Wet", "Forage", "vertex_") 19 | .tr0names <- c("x_", "y_", "t_", "Wet", "Forage") 20 | expect_named(TRI(.tr)$vertex, .trnames) 21 | expect_named(TRI0(.tr)$vertex, .tr0names) 22 | 23 | #these are different (for now, not sure - native names or these? and 24 | # means we don't keep other attributes at all) 25 | expect_named(SC(.tr)$vertex, c("x_", "y_", "t_", "vertex_")) 26 | expect_named(SC0(.tr)$vertex, c("x_", "y_", "t_")) 27 | 28 | expect_named(PATH(.tr)$vertex, .trnames) 29 | expect_named(PATH0(.tr)$vertex, .tr0names) 30 | 31 | expect_warning(expect_named(ARC(.tr)$vertex, .trnames)) 32 | #expect_named(ARC0(.tr)$vertex, .tr0names) 33 | 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test-multi-custom.R: -------------------------------------------------------------------------------- 1 | #context("multi-custom") 2 | 3 | 4 | 5 | #multi level features as custom types 6 | 7 | # state and county sharing vertices, note rules on internal rings (discard them, leave one level for simple features) 8 | # pre-computed topologically sound resolutions (i.e. district precision for a state boundary vs. country precision) 9 | # a voyage track, intervals within it, fine-resolution underway measures, specific stations 10 | # a fused surface, a combination of contour lines with a constant Z fused with polygons without elevation 11 | 12 | -------------------------------------------------------------------------------- /tests/testthat/test-path0-sanity.R: -------------------------------------------------------------------------------- 1 | context("test-path0-sanity") 2 | x <- PATH0(minimal_mesh) 3 | 4 | 5 | test_that("PATH0 round trip suite works", { 6 | SC(x) 7 | SC0(x) 8 | plot(SC(x)) 9 | plot(SC0(x)) 10 | ## these test have to go in anglr 11 | #anglr::DEL(SC(x)) 12 | #plot(anglr::DEL(SC(x))) 13 | sc_vertex(x) 14 | sc_coord(x) 15 | sc_node(x) 16 | sc_edge(x) 17 | sc_segment(x) 18 | sc_object(x) 19 | sc_path(x) 20 | PATH(x) 21 | PATH0(x) 22 | sc_start(x) 23 | sc_end(x) 24 | 25 | expect_s3_class(TRI0(x), "TRI0") 26 | expect_s3_class( TRI(x), "TRI") 27 | }) 28 | 29 | 30 | test_that("errors when PATH0 round trip unsupported", { 31 | 32 | expect_error(ARC0(x)) 33 | 34 | ## expect_error(sc_start(x)) 35 | ## expect_error(sc_end(x)) 36 | ## test must go in anglr 37 | #expect_error(DEL(x)) 38 | }) 39 | 40 | -------------------------------------------------------------------------------- /tests/testthat/test-print.R: -------------------------------------------------------------------------------- 1 | context("test-trip") 2 | test_that("print works", { 3 | expect_output(print(PATH(minimal_mesh))) 4 | expect_output(print(SC(minimal_mesh))) 5 | expect_output(print(ARC(minimal_mesh))) 6 | expect_output(print(TRI(minimal_mesh))) 7 | 8 | expect_output(print(PATH0(minimal_mesh))) 9 | expect_output(print(SC0(minimal_mesh))) 10 | expect_error(print(ARC0(minimal_mesh))) 11 | expect_output(print(TRI0(minimal_mesh))) 12 | 13 | }) 14 | -------------------------------------------------------------------------------- /tests/testthat/test-projection.R: -------------------------------------------------------------------------------- 1 | #context("test-projection.R") 2 | # 3 | # obj <- sf::st_set_crs(minimal_mesh, "+proj=lcc") 4 | # test_that("projection meta works", { 5 | # x <- SC(obj) 6 | # expect_that(x$meta$proj, equals("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")) 7 | # 8 | # x <- ARC(obj) 9 | # expect_that(x$meta$proj, equals("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")) 10 | # 11 | # x <- silicate::TRI(obj) 12 | # expect_that(x$meta$proj, equals("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")) 13 | # 14 | # x <- silicate::PATH(obj) 15 | # expect_that(x$meta$proj, equals("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")) 16 | # 17 | # }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-round-trip.R: -------------------------------------------------------------------------------- 1 | #context("round trip") 2 | #skip("no round trip") ## there's nothing to round trip ATM 2017-01-06 3 | 4 | # test_that("round trip works", { 5 | # path <- PATH(mmesh) %>% 6 | # expect_s3_class("PATH") %>% 7 | # expect_s3_class("sc") %>% PRIMITIVE() %>% expect_s3_class("PRIMITIVE") %>% 8 | # PATH() 9 | # path %>% sc_coord() %>% expect_s3_class("tbl_df") 10 | # path %>% sc_path() %>% expect_s3_class("tbl_df") 11 | # path %>% sc_object() %>% expect_s3_class("tbl_df") 12 | # 13 | # prim <- PRIMITIVE(mmesh) 14 | # prim %>% sc_coord() %>% expect_s3_class("tbl_df") 15 | # prim %>% sc_path() %>% expect_s3_class("tbl_df") 16 | # prim %>% sc_object() %>% expect_s3_class("tbl_df") 17 | # 18 | # 19 | # }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-sc-sanity.R: -------------------------------------------------------------------------------- 1 | context("test-SC-sanity") 2 | x <- SC(minimal_mesh) 3 | 4 | test_that("SC round trip suite works", { 5 | skip_on_cran() ## we get warnings 6 | expect_silent({ 7 | SC(x) 8 | SC0(x) 9 | ## must go in anglr 10 | #anglr::DEL(x) 11 | #plot(anglr::DEL(x)) 12 | 13 | plot(SC(x)) 14 | plot(SC0(x)) 15 | sc_vertex(x) 16 | sc_coord(x) 17 | sc_node(x) 18 | sc_edge(x) 19 | sc_segment(x) 20 | sc_start(x) 21 | sc_end(x) 22 | sc_object(x) 23 | }) 24 | }) 25 | 26 | 27 | test_that("errors when SC0 round trip unsupported", { 28 | expect_error(sc_arc(x)) 29 | expect_error(sc_path(x)) 30 | expect_error(TRI(x)) 31 | expect_error(TRI0(x)) 32 | expect_error(ARC(x)) 33 | expect_error(ARC0(x)) 34 | expect_error(PATH(x)) 35 | expect_error(PATH0(x)) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test-sc.R: -------------------------------------------------------------------------------- 1 | context("test-sc-model") 2 | 3 | sc <- SC(minimal_mesh) 4 | test_that("SC works", { 5 | sc <- expect_s3_class(sc, "SC") %>% 6 | expect_named(c("object", "object_link_edge", "edge", "vertex", "meta")) 7 | }) 8 | 9 | test_that("SC verb methods work", { 10 | #expect_s3_class(sc_arc(sc), "tbl_df") 11 | expect_error(sc_arc(sc), "ARC not yet implemented for SC") 12 | expect_s3_class(sc_coord(sc), "tbl_df") 13 | expect_s3_class(sc_edge(sc), "tbl_df") 14 | 15 | expect_s3_class(sc_object(sc), "tbl_df") 16 | expect_s3_class(sc_edge(sc), "tbl_df") 17 | #expect_s3_class(sc_path(sc), "tbl_df") 18 | expect_error(sc_path(sc), "sc_path not yet supported for SC") 19 | 20 | expect_s3_class(sc_segment(sc), "tbl_df") 21 | expect_s3_class(sc_vertex(sc), "tbl_df") 22 | 23 | expect_s3_class(sc_end(sc), "tbl_df") 24 | expect_s3_class(sc_start(sc), "tbl_df") 25 | 26 | } 27 | ) 28 | -------------------------------------------------------------------------------- /tests/testthat/test-sc0-sanity.R: -------------------------------------------------------------------------------- 1 | context("test-sc0-sanity") 2 | x <- SC0(minimal_mesh) 3 | 4 | 5 | test_that("SC0 round trip suite works", { 6 | skip_on_cran() ## we get warnings 7 | expect_silent({ 8 | SC(x) 9 | SC0(x) 10 | plot(SC(x)) 11 | plot(SC0(x)) 12 | ## these test have to go in anglr 13 | #anglr::DEL(SC(x)) 14 | #plot(anglr::DEL(SC(x))) 15 | sc_vertex(x) 16 | sc_coord(x) 17 | sc_node(x) 18 | sc_edge(x) 19 | sc_segment(x) 20 | sc_start(x) 21 | sc_end(x) 22 | sc_object(x) 23 | }) 24 | }) 25 | 26 | 27 | test_that("errors when SC0 round trip unsupported", { 28 | expect_error(sc_arc(x)) 29 | expect_error(sc_path(x)) 30 | expect_error(TRI(x)) 31 | expect_error(TRI0(x)) 32 | expect_error(ARC(x)) 33 | expect_error(ARC0(x)) 34 | expect_error(PATH(x)) 35 | expect_error(PATH0(x)) 36 | ## test must go in anglr 37 | #expect_error(DEL(x)) 38 | }) 39 | 40 | 41 | test_that("concat SC0 works", { 42 | sc <- SC0(minimal_mesh) 43 | sc1 <- SC0(minimal_line) 44 | expect_s3_class(c(sc, sc1), "SC0") 45 | }) 46 | -------------------------------------------------------------------------------- /tests/testthat/test-sc_coord.R: -------------------------------------------------------------------------------- 1 | context("test-sc_coord") 2 | 3 | test_that("weird case works", { 4 | expect_equal(sc_coord(list(coord = tibble::tibble(xx = 2, yy = 1))), tibble::tibble(xx = 2, yy = 1)) 5 | 6 | expect_equal(sc_coord(cbind(xx = 1, yy = 2)), tibble::tibble(xx = 1, yy = 2)) 7 | 8 | x <- silicate::PATH0(minimal_mesh) 9 | expect_silent(sc_coord(x)) ##issue107 10 | 11 | }) 12 | 13 | test_that("drop sfc etc works", { 14 | mm <- minimal_mesh 15 | # class(mm) <- "data.frame" 16 | class(mm$geom) <- "list" 17 | expect_equivalent(sc_coord(mm), 18 | sc_coord(minimal_mesh)) 19 | 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-sc_object.R: -------------------------------------------------------------------------------- 1 | context("test-sc_object") 2 | 3 | test_that("sfc object works", { 4 | expect_equal(sc_coord(minimal_mesh$geom), 5 | sc_coord(minimal_mesh)) 6 | 7 | expect_equal(sc_coord(minimal_mesh$geom), 8 | sc_coord(PATH(minimal_mesh))) 9 | 10 | expect_equal(nrow(sc_object(minimal_mesh$geom)), 11 | nrow(sc_object(minimal_mesh))) 12 | 13 | expect_named(sc_object(minimal_mesh$geom), "object_") 14 | expect_named(sc_object(minimal_mesh), c("a")) 15 | expect_equal(nrow(sc_object(minimal_mesh$geom)), 16 | nrow(sc_object(PATH(minimal_mesh)))) 17 | 18 | expect_named(sc_object(PATH(minimal_mesh)), c("a", "object_")) 19 | 20 | 21 | # expect_equal(sc_object) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-segment-creation.R: -------------------------------------------------------------------------------- 1 | context("segment-creation") 2 | mm <- PATH(minimal_mesh) 3 | ps <- PATH(polymesh) 4 | segsmm <- sc_segment_base(mm$path_link_vertex) 5 | segsps <- sc_segment_base(ps$path_link_vertex) 6 | minsegs <- c(7L, 1L, 2L, 3L, 4L, 5L, 6L, 12L, 8L, 9L, 10L, 11L, 6L, 5L, 7 | 14L, 15L) 8 | polysegs <- c(2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 1L, 56L, 50L, 49L, 48L, 47L, 46L, 45L, 44L, 43L, 65L, 66L, 67L, 68L, 55L, 70L, 71L, 72L, 52L, 51L, 50L, 56L, 55L, 68L, 67L, 66L, 81L, 82L, 69L, 84L, 85L, 86L, 66L, 65L, 43L, 42L, 41L, 40L, 39L, 94L, 83L, 96L, 97L, 98L, 1L, 54L, 53L, 52L, 72L, 71L, 70L, 106L, 95L, 108L, 109L, 110L, 84L, 83L, 94L, 39L, 38L, 37L, 36L, 35L, 119L, 120L, 107L, 96L, 123L, 124L, 125L, 2L, 1L, 98L, 97L, 130L, 131L, 108L, 107L, 120L, 119L, 35L, 34L, 138L, 129L, 140L, 141L, 142L, 143L, 70L, 69L, 82L, 81L, 66L, 86L, 85L, 84L, 152L, 139L, 154L, 155L, 156L, 96L, 95L, 106L, 70L, 143L, 142L, 141L, 140L, 165L, 166L, 153L, 168L, 169L, 170L, 140L, 139L, 152L, 84L, 110L, 109L, 108L, 178L, 167L, 166L, 181L, 154L, 153L, 156L, 155L, 154L, 187L, 188L, 189L, 123L, 96L, 192L, 168L, 167L, 178L, 108L, 131L, 130L, 199L, 200L, 191L, 202L, 203L, 204L, 166L, 165L, 140L, 170L, 169L, 168L, 201L, 181L, 166L, 204L, 203L, 202L, 217L, 218L, 219L, 220L, 221L, 187L, 154L, 202L, 201L, 168L, 192L, 191L, 200L, 230L, 231L, 232L, 223L, 234L, 235L, 218L, 217L, 202L, 223L, 232L, 233L) 9 | 10 | test_that("segment creation works", { 11 | expect_identical(match(segsmm$.vx0, segsmm$.vx1) , minsegs) 12 | expect_identical(match(segsps$.vx1, segsps$.vx0), polysegs) 13 | }) 14 | -------------------------------------------------------------------------------- /tests/testthat/test-sf-PRIMITIVE.R: -------------------------------------------------------------------------------- 1 | # context("primitives") 2 | # 3 | # # 4 | # # test_that("primitives 0D", { 5 | # # error("no tests!") 6 | # # }) 7 | # test_that("primitives 1D", { 8 | # # inlandwaters[5, ] 9 | # minimal_mesh %>% PRIMITIVE() %>% expect_s3_class("PRIMITIVE") %>% 10 | # ## test round-trip back to sf 11 | # sf() %>% expect_s3_class("sf") %>% PRIMITIVE() %>% sf() %>% expect_s3_class("sf") 12 | # 13 | # 14 | # }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-sf-decomposition.R: -------------------------------------------------------------------------------- 1 | context("path-decomposition") 2 | data("sfzoo") 3 | data("sfgc") 4 | test_that("raw geometry decomposition works", { 5 | dplyr::bind_rows(lapply(sfzoo, sc_path)) %>% 6 | expect_s3_class("tbl_df") %>% 7 | expect_named(c("nrow", "ncol", "type", "path_", "subobject")) 8 | }) 9 | inner_cascade <- function(x) { 10 | tabnames <- join_ramp(x) 11 | tab <- x[[tabnames[1]]] 12 | for (ni in tabnames[-1L]) tab <- dplyr::inner_join(tab, x[[ni]]) 13 | tab 14 | } 15 | test_that("geometrycollection decomposition works", { 16 | dplyr::bind_rows(lapply(sfgc, sc_path)) %>% 17 | expect_s3_class("tbl_df") %>% 18 | expect_named(c("nrow", "ncol", "type", "path_", "subobject")) 19 | 20 | expect_silent( sc_path(silicate::sfgc)) 21 | }) 22 | 23 | test_that("sf decomposition works", { 24 | path <- PATH(minimal_mesh) 25 | path %>% expect_s3_class("PATH") 26 | expect_true(all(c("object", "path", "path_link_vertex", "vertex") %in% names(path))) 27 | }) 28 | test_that("joins are valid", { 29 | PATH(minimal_mesh) %>% inner_cascade() %>% 30 | expect_s3_class("tbl_df") 31 | }) 32 | obj <- polymesh 33 | test_that("object and path names as expected", { 34 | gibble::gibble(obj) %>% expect_named(c("nrow", "ncol", "type", "subobject", "object")) 35 | expect_true("layer" %in% names(sc_object(obj))) 36 | expect_true(all(c("arc_", "ncoords_") %in% names(sc_arc(obj)))) 37 | expect_true(all(c("x_", "y_") %in% names(sc_coord(obj)))) 38 | expect_true(all(c(".vx0", ".vx1") %in% names(sc_edge(obj)))) 39 | expect_equal("vertex_", names(sc_node(obj))) 40 | expect_true(all(c("object_", "path_", "ncoords_") %in% names(sc_path(obj)))) 41 | expect_true(all(c(".vx0", ".vx1", 42 | "segment_", "edge_") %in% names(sc_segment(obj)))) 43 | 44 | 45 | 46 | } ) 47 | 48 | 49 | test_that("topology basis is sane", { 50 | expect_identical(PATH0(minimal_mesh)$vertex, SC0(minimal_mesh)$vertex) 51 | 52 | #identical(TRI0(minimal_mesh)$vertex, SC0(minimal_mesh)$vertex) 53 | }) 54 | 55 | -------------------------------------------------------------------------------- /tests/testthat/test-spatial-build.R: -------------------------------------------------------------------------------- 1 | context("test-spatial-build") 2 | 3 | test_that("building sf works", { 4 | gib <- gibble(minimal_mesh) 5 | cds <- sc_coord(minimal_mesh) 6 | expect_s3_class(build_sf(PATH(minimal_mesh)), "sf") 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test-tri-sanity.R: -------------------------------------------------------------------------------- 1 | context("test-TRI-sanity") 2 | x <- TRI(minimal_mesh) 3 | skip_on_cran() 4 | test_that("TRI round trip suite works", { 5 | expect_silent({ 6 | SC(x) 7 | SC0(x) 8 | # must go in anglr 9 | #anglr::DEL(SC(x)) ## have to SC it first 10 | #plot(anglr::DEL(SC(x))) 11 | 12 | plot(SC(x)) 13 | plot(SC0(x)) 14 | sc_vertex(x) 15 | sc_coord(x) 16 | sc_node(x) 17 | sc_edge(x) 18 | sc_segment(x) 19 | sc_start(x) 20 | sc_end(x) 21 | sc_object(x) 22 | 23 | TRI(x) 24 | TRI0(x) 25 | 26 | }) 27 | 28 | ## FIXED 2020-05-15 expect_warning( TRI(TRI0(x))) 29 | expect_silent({ 30 | 31 | sc_triangle(x) 32 | 33 | 34 | }) 35 | }) 36 | 37 | 38 | test_that("errors when SC0 round trip unsupported", { 39 | expect_error(sc_arc(x)) 40 | expect_error(sc_path(x)) 41 | ## put in anglr 42 | # expect_error(anglr::DEL(x)) 43 | 44 | expect_error(ARC(x)) 45 | expect_error(ARC0(x)) 46 | expect_error(PATH(x)) 47 | expect_error(PATH0(x)) 48 | }) 49 | -------------------------------------------------------------------------------- /tests/testthat/test-triangles.R: -------------------------------------------------------------------------------- 1 | context("test-triangles") 2 | pts <- structure(c(5L, 3L, 1L, 4L, 4L, 8L, 6L, 9L), .Dim = c(4L, 2L)) 3 | tri <- c(2, 1, 3, 2, 4, 1) 4 | a <- tri_area(pts[tri, ]) 5 | 6 | test_that("triangle tools works", { 7 | expect_equal(a, c(6, 3)) 8 | expect_equal(tri_ix(pts[tri, ]), c(3, 1, 2, 6, 4, 5)) 9 | expect_equal(tri_jx(pts[tri, ]), c(1, 2, 3, 4, 5, 6)) 10 | 11 | }) 12 | 13 | 14 | test_that("triangle cull/visibility works", { 15 | ## first object has a hole in it 16 | mintri <- silicate::TRI(silicate::minimal_mesh) 17 | 18 | ## TRI model *does not* have triangles that exist within a hole 19 | expect_true(sum(mintri$triangle$visible) == dim(mintri$triangle)[1L]) 20 | }) 21 | 22 | test_that("primitives extraction works", { 23 | tri <- TRI(minimal_mesh) 24 | tri0 <- TRI0(minimal_mesh) 25 | expect_named(sc_triangle(tri), c(".vx0", ".vx1", ".vx2", "object_", "visible")) 26 | expect_named(sc_triangle(tri0), c(".vx0", ".vx1", ".vx2", "path_", "object_")) 27 | 28 | expect_silent(plot(tri)) 29 | expect_silent(plot(tri, col = viridis_cols)) 30 | expect_silent(plot(tri0)) 31 | expect_silent(plot(tri0, col = viridis_cols)) 32 | 33 | 34 | }) 35 | -------------------------------------------------------------------------------- /tests/testthat/test-valid-inputs.R: -------------------------------------------------------------------------------- 1 | context("test-valid-inputs.R") 2 | 3 | pbroke <- p <- PATH(minimal_mesh) 4 | test_that("we stop on bad inputs", { 5 | pbroke$vertex$x_[10] <- NA 6 | expect_error(TRI(pbroke), "missing values in x_") 7 | 8 | pbroke$vertex <- pbroke$vertex[1:2, ] 9 | expect_error(TRI(pbroke), "need at least 3 coordinates") 10 | #expect_output(earcut(minimal_mesh$geom[1]), "Column 1 must be named") 11 | # expect_error(earcut(minimal_mesh$geom[[1]]), "Evaluation error: invalid 'times' argument.") 12 | 13 | }) 14 | 15 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/silicate_topology_01.R: -------------------------------------------------------------------------------- 1 | ## ----setup, include=FALSE------------------------------------------------ 2 | knitr::opts_chunk$set(echo = TRUE) 3 | library(dplyr) 4 | 5 | ## ----minimal_mesh-------------------------------------------------------- 6 | library(silicate) 7 | 8 | plot(matrix(attr(minimal_mesh$geom, "bbox"), 2, byrow = TRUE), type = "n", xlab = "", ylab = "") 9 | rbind_na <- function(x) head(do.call(rbind, unlist(lapply(x, function(a) rbind(a, NA)), recursive = F)), -1) 10 | cols <- sc_colours(nrow(minimal_mesh)) 11 | junk <- lapply(seq_along(minimal_mesh$geom), function(y) polypath(rbind_na(minimal_mesh$geom[[y]]), col = cols[y] )) 12 | 13 | 14 | 15 | ## ----sc------------------------------------------------------------------ 16 | x <- SC(minimal_mesh) 17 | names(x) 18 | x$edge 19 | print(x) 20 | plot(x) 21 | text(x$vertex[c("x_", "y_")], label = x$vertex$vertex_) 22 | 23 | ## ----PATH---------------------------------------------------------------- 24 | x <- PATH(minimal_mesh) 25 | names(x) 26 | 27 | ## ----reduce-path--------------------------------------------------------- 28 | 29 | purrr::reduce(x[c("object", "path", "path_link_vertex", "vertex")], dplyr::inner_join) 30 | 31 | ## ----arc-node------------------------------------------------------------ 32 | library(dplyr) 33 | arc <- ARC(minimal_mesh) 34 | nodes <- sc_node(arc) 35 | 36 | plot(arc) 37 | inner_join(nodes, arc$vertex) %>% dplyr::select(x_, y_) %>% points(pch = "N") 38 | 39 | 40 | ## ----TRI----------------------------------------------------------------- 41 | tri <- TRI(minimal_mesh) 42 | plot(tri) 43 | 44 | ## ------------------------------------------------------------------------ 45 | #system.time(sf::st_triangulate(inlandwaters)) 46 | # user system elapsed 47 | # 4.699 0.125 4.823 48 | #system.time(sfdct::ct_triangulate(inlandwaters)) 49 | # user system elapsed 50 | # 15.476 0.225 15.460 51 | system.time(tri <- TRI(inlandwaters)) 52 | 53 | ## ------------------------------------------------------------------------ 54 | plot(tri) 55 | 56 | plot(NA, xlim = c(625000, 1060000), ylim = c(-1350000, -550000)) 57 | plot(tri, add = TRUE) 58 | 59 | ## ----sfdct,eval=FALSE---------------------------------------------------- 60 | # #plot(sfdct::ct_triangulate(minimal_mesh)) 61 | 62 | --------------------------------------------------------------------------------