Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

124 changes: 124 additions & 0 deletions r/sedonadb/R/000-wrappers.R

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

29 changes: 29 additions & 0 deletions r/sedonadb/R/crs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

#' Parse CRS from GeoArrow metadata
#'
#' @param crs_json A JSON string representing the CRS (PROJJSON or authority code)
#' @returns A list with components: authority_code (e.g., "EPSG:5070"), srid (integer),
#' name (character string with a human-readable CRS name), and proj_string (character
#' string with the PROJ representation of the CRS), or \code{NULL} when no CRS
#' information is available, when the \code{"crs"} field is not present in the
#' metadata, or when parsing the CRS information fails.
#' @keywords internal
sd_parse_crs <- function(crs_json) {
parse_crs_metadata(crs_json)
}
35 changes: 35 additions & 0 deletions r/sedonadb/R/dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,41 @@ as_nanoarrow_array_stream.sedonadb_dataframe <- function(x, ..., schema = NULL)

#' @export
print.sedonadb_dataframe <- function(x, ..., width = NULL, n = NULL) {
# Print class header
schema <- nanoarrow::infer_nanoarrow_schema(x)
ncols <- length(schema$children)

cat(sprintf("# A sedonadb_dataframe: ? x %d\n", ncols))

# Print geometry column info using SedonaTypeR wrapper
geo_col_info <- character()
for (col_name in names(schema$children)) {
child <- schema$children[[col_name]]
sd_type <- tryCatch(
SedonaTypeR$new(child),
error = function(e) NULL
)
if (!is.null(sd_type)) {
logical_type <- sd_type$logical_type_name()
if (logical_type == "geometry" || logical_type == "geography") {
crs_display <- sd_type$crs_display()
geo_col_info <- c(geo_col_info, sprintf("%s%s", col_name, crs_display))
}
}
}

if (length(geo_col_info) > 0) {
if (is.null(width)) {
width <- getOption("width")
}

geo_line <- sprintf("# Geometry: %s", paste(geo_col_info, collapse = ", "))
if (nchar(geo_line) > width) {
geo_line <- paste0(substr(geo_line, 1, width - 3), "...")
}
cat(paste0(geo_line, "\n"))
}

if (isTRUE(getOption("sedonadb.interactive", TRUE))) {
sd_preview(x, n = n, width = width)
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/sedonadb/R/pkg-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ as_sedonadb_dataframe.sf <- function(x, ..., schema = NULL) {
as_sedonadb_dataframe(new_sedonadb_dataframe(ctx, df), schema = schema)
}

# dynamically registered in zzz.R
#' @exportS3Method sf::st_as_sf
# nolint start: object_name_linter
st_as_sf.sedonadb_dataframe <- function(x, ...) {
stream <- nanoarrow::nanoarrow_allocate_array_stream()
Expand Down
22 changes: 22 additions & 0 deletions r/sedonadb/man/sd_parse_crs.Rd

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

73 changes: 73 additions & 0 deletions r/sedonadb/src/init.c

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

1 change: 1 addition & 0 deletions r/sedonadb/src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ sedona-expr = { workspace = true }
sedona-geoparquet = { workspace = true }
sedona-proj = { workspace = true }
sedona-schema = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
Loading
Loading