R-ArcGIS / arcpbf

Rust crate and R package for processing Esri Protocol Buffers
https://r.esri.com/arcpbf/
Apache License 2.0
8 stars 0 forks source link

`resps_data_pbf()` errors when `resps` is an empty list #8

Closed elipousson closed 1 month ago

elipousson commented 1 month ago

resps_data_pbf() errors when resps is an empty list:

arcpbf::resps_data_pbf(list())
#> Error in x[[1]]: subscript out of bounds

Created on 2024-10-28 with reprex v2.1.1

This is an issue for arcgislayers when the query defined by where returns 0 features. Here is a reprex showing how the error pops up for arcgislayers:

library(arcgislayers)

layer <- arc_open(
  "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized_Boundaries/FeatureServer/0"
)

arc_select(
  layer,
  where = "STATE_NAME LIKE 'Marylnd'"
)
#> Error in x[[1]]: subscript out of bounds

arc_select(
  layer,
  where = "STATE_NAME LIKE 'Maryland'"
)
#> Simple feature collection with 24 features and 12 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -79.48986 ymin: 37.97025 xmax: -75.04562 ymax: 39.72546
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    OBJECTID                NAME STATE_NAME STATE_FIPS  FIPS   SQMI POPULATION
#> 1      1191     Allegany County   Maryland         24 24001 427.90      68106
#> 2      1192 Anne Arundel County   Maryland         24 24003 416.69     588261
#> 3      1193    Baltimore County   Maryland         24 24005 608.10     854535
#> 4      1194      Calvert County   Maryland         24 24009 216.65      92783
#> 5      1195     Caroline County   Maryland         24 24011 324.09      33293
#> 6      1196      Carroll County   Maryland         24 24013 452.69     172891
#> 7      1197        Cecil County   Maryland         24 24015 352.70     103725
#> 8      1198      Charles County   Maryland         24 24017 459.85     166617
#> 9      1199   Dorchester County   Maryland         24 24019 567.83      32531
#> 10     1200    Frederick County   Maryland         24 24021 667.42     271717
#>    POP_SQMI STATE_ABBR COUNTY_FIPS Shape__Area Shape__Length
#> 1     159.2         MD         001  0.11682303      2.200322
#> 2    1411.7         MD         003  0.11857783      1.733350
#> 3    1405.3         MD         005  0.16468989      2.241737
#> 4     428.3         MD         009  0.06361530      1.248014
#> 5     102.7         MD         011  0.08919855      1.478438
#> 6     381.9         MD         013  0.12497357      1.744244
#> 7     294.1         MD         015  0.09582565      1.502649
#> 8     362.3         MD         017  0.12214606      1.735967
#> 9      57.3         MD         019  0.14287233      1.886759
#> 10    407.1         MD         021  0.18039944      1.890163
#>                          geometry
#> 1  POLYGON ((-78.48128 39.5199...
#> 2  POLYGON ((-76.84341 39.0982...
#> 3  POLYGON ((-76.7017 39.20803...
#> 4  POLYGON ((-76.64694 38.4505...
#> 5  POLYGON ((-75.72459 38.8302...
#> 6  POLYGON ((-76.87876 39.3318...
#> 7  POLYGON ((-75.79109 39.7238...
#> 8  POLYGON ((-76.67888 38.4953...
#> 9  POLYGON ((-75.87209 38.3573...
#> 10 POLYGON ((-77.6793 39.31878...

Created on 2024-10-28 with reprex v2.1.1

JosiahParry commented 1 month ago

i swear we have fixed this before...

thank you for the repro ill give it a looksie