R-ArcGIS/arcgislayers

publish_layer() fails with mapply error

Closed this issue · 5 comments

Describe the bug
Publishing a hosted feature layer using publish_layer() is failing currently.

To Reproduce

library(arcgis)
#> Attaching core arcgis packages:
#> → arcgisutils v0.2.0.9000
#> → arcgislayers v0.2.0
set_arc_token(auth_user())
nc <- sf::read_sf(system.file("shape/nc.shp", package = "sf"))
res <- publish_layer(nc, "NorthCarolinaSIDS_test1")
#> Warning in mapply(function(.x, .y) c(list(attributes = c(.y)), geometry =
#> list(.x)), : longer argument not a multiple of length of shorter

Created on 2024-04-19 with reprex v2.1.0

Expected behavior
Publishing should succeed with the valid input data (nc.shp).

Additional context
N/A

This work is being done in https://github.com/JosiahParry/serde_esri/tree/geom

It's almostttt done. I'll need to figure out how to get this into arcgisutils though. I'm torn between two options:

  • put Rust code inside of arcgisutils and remove C code
  • create another small utility package for json much like arcpbf but here it could be esrijson or something and importing it into arcgisutils

@elipousson this will affect you. Do you have a stance?

The work being done in serde_esri can also be used to create arrays of features, individual geometries, as well as parse esri json more cleanly.

I think it might be worth the effort to migrate it all to using serde_esri. Most of the scaffolding is there.

What is not:

  • creating feature sets with M or ZM
  • parsing json similarly to arcpbf::resps_body_pbf()

This also means that all functions will create the json string directly and not create a list object. So this means all as_geometry(), as_features() and as_featureset() will have to be deprecated.

But the benefit is that we know the geometries will be correct. If you need the list types we can -> create the string -> parse the string

This is probably also the same time to fix validate_crs() I think. Hm.

I haven't built anything on top of the lower-level functions directly so, unless there are some possible consequences that I'm not thinking of, I'm somewhat agnostic on the solution.

It all sounds promising though! Happy to help test when it is ready.

This is drafted in R-ArcGIS/arcgisutils#48.
There's still a bit of documentation and testing to get written. But I've been able to publish a MULTIPOLYGON and mapviewer recognizes the geometries which is a huge win.