Skip to content

Commit

Permalink
parse blob field into a list
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Feb 11, 2025
1 parent 7e82ada commit 44fd48f
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/rust/arcpbf/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,23 @@ pub fn parse_spatial_ref(x: SpatialReference) -> List {
}

pub fn parse_blob(x: Vec<Value>) -> Robj {
let mut n_some = 0usize;
let res = x.into_iter()
.map(|xi| {
match xi.value_type {
Some(v) => {
n_some += 1;
Raw::new(0)
},
None => Raw::new(0),
}
x.into_iter()
.map(|xi| match xi.value_type {
Some(v) => match v {
ValueType::StringValue(v) => v.into_robj(),
ValueType::FloatValue(v) => v.into_robj(),
ValueType::DoubleValue(v) => v.into_robj(),
ValueType::SintValue(v) => v.into_robj(),
ValueType::UintValue(v) => v.into_robj(),
ValueType::Int64Value(v) => v.into_robj(),
ValueType::Uint64Value(v) => v.into_robj(),
ValueType::Sint64Value(v) => v.into_robj(),
ValueType::BoolValue(v) => v.into_robj(),
},
None => ().into_robj(),
})
.collect::<List>()
.into();

if n_some > 0 {
eprintln!("Blob types not supported.\nPlease report an issue at https://github.com/R-ArcGIS/arcpbf/issues\nProvide the FeatureService URL if possible");
}

res
.into()
}

// map field type to parser
Expand All @@ -163,11 +161,11 @@ pub fn field_type_robj_mapper(fi: &FieldType) -> fn(Vec<Value>) -> Robj {
FieldType::EsriFieldTypeGuid => |x| parse_strings(x).into_robj(),
FieldType::EsriFieldTypeOid => |x| parse_big_ints(x).into_robj(),
FieldType::EsriFieldTypeDate => |x| parse_date(x),
// FieldType::EsriFieldTypeXml => todo!(),
FieldType::EsriFieldTypeGlobalId => |x| parse_strings(x).into_robj(),
// FieldType::EsriFieldTypeRaster => todo!(),
FieldType::EsriFieldTypeBlob => |x| parse_blob(x),
// FieldType::EsriFieldTypeGeometry => todo!(),
_ => todo!(),
_ => |x| {
eprintln!("This field type is not supported.\nPlease report an issue at https://github.com/R-ArcGIS/arcpbf/issues\nProvide the FeatureService URL if possible");
List::new(x.len()).into_robj()
},
}
}

0 comments on commit 44fd48f

Please sign in to comment.