hypertidy/anglr

reproj isn't doing XYZ properly for geocent

Closed this issue · 3 comments

Use the globe() function instead, or assume XYZ if it's a mesh3d? If we reproj a TRI it doesn't get a z, so another option is detect the case of geocent and make sure it's added.

Ah, because reproj already has a reproj.sc() you dumbo:

reproj.sc <- function(x, target = NULL, ..., source = NULL) {
  # if (is.null(target)) {
  #   target <- make_local(x, family = family)
  # }
  if (is.null(source)) source <- get_proj(x)

  verts <- get_vertex(x)
  verts$z_ <- if (is.null(x$vertex$z_)) 0 else x$vertex$z_
  if (inherits(x, "QUAD") && is.null(x$vertex)) {
    x$vertex <- verts
    x$quad <- NULL
  }
  x$vertex[c("x_", "y_", "z_")] <- tibble::as_tibble(reproj::reproj(as.matrix(verts[c("x_", "y_", "z_")]), 
                                               source = source, 
                                               target = target))
  meta <- get_meta(x)
  meta["ctime"] <- Sys.time()
  meta["proj"] <- target
  x$meta <- rbind(meta, x$meta)
  x
                                                  
}

FIXED

reproj(TRI0(minimal_mesh), "+proj=geocent")
class       : TRI0
type        : Primitive
vertices    : 14 (3-space)
primitives  : 14 (2-space)
crs         : +proj=geocent
Warning message:
In reproj.matrix(mat, source = source, target = target) :
  'source' projection not included, but looks like longitude/latitude values:
   using '+proj=longlat +datum=WGS84 +no_defs'