Skip to content

need ID builder for pairs of tables #136

@mdsumner

Description

@mdsumner

SC0() is pretty fast, but SC() is very slow - unpack

  • building the object_link_edge table from SC0

WIP

f <- raadfiles::thelist_files(pattern = "parcels_hobart")$fullname

sfx <- sf::read_sf(f)
idx <- sort(unique(unlist(sf::st_touches(sfx[1:10, ], sfx))))
library(dplyr)

sc0 <- silicate::SC0(sfx[idx, ])
#system.time(sc <- silicate::SC(sc0))
system.time(
## flesh out the edge pairs, and unique id them
edge <- bind_rows(sc0$object$topology_, .id = "object") %>% 
  mutate(min = pmin(.vx0, .vx1), max = pmax(.vx0, .vx1), native_ = min == .vx0) %>% 
  dplyr::group_by(min, max) %>% 
  dplyr::mutate(edge = dplyr::cur_group_id()) %>% 
  dplyr::ungroup() %>% 
  dplyr::select(.vx0, .vx1, path_, edge, object, native_)
)

sc2 <- silicate::SC(sc0)
ams <- function(x, y) as.character(match(x, y))
sc2$object_link_edge$object_ <- ams(sc2$object_link_edge$object_, sc2$object$object_)
sc2$object$object_ <- as.character(1:nrow(sc2$object))

sc2$object_link_edge$edge_ <- ams(sc2$object_link_edge$edge_, sc2$edge$edge_)
sc2$edge$edge_ <- as.character(1:nrow(sc2$edge))

sc2$edge$.vx0 <- ams(sc2$edge$.vx0, sc2$vertex$vertex_)
sc2$edge$.vx1 <- ams(sc2$edge$.vx1, sc2$vertex$vertex_)
sc2$vertex$vertex_ <- as.character(1:nrow(sc2$vertex))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions