Determine geometry field at build time
big picture
https://gyazo.com/32f082df6cd28a2401fe34cdb055aed0
table: decisions
o Data format selects whether to process properties or geometry first
o Nested / child structs are allowed
? Struct fields can be in a different order from actual format
? Compatible with all serde_derive attributes
code:plan0(rs)
struct MyFeature {
title: String,
location: Point,
}
pros
no additional code needed
easy to learn
cons
dynamic geometry detection is slow
hard to implement various geometry types
code:plan1(rs)
use geoserde::geometry;
struct MyFeature {
title: String,
location: Point,
}
cons
missing geometry => runtime error
hard to implement
how to tell "this is the geometry" to Serializer?
code: plan1-a(rs)
struct MyFeature {
title: String,
location: Point,
}
pros
minimum aditional code
cons
can't contain "geometry" field as an property
missing geometry => runtime error
code:plan2(rs)
use geoserde::Feature;
struct MyFeature {
title: String,
location: Point,
}
pros
missing geometry => build error
cons
hard to implement
geometry in child struct
code:plan2a(rs)
use geoserde::Feature;
struct MyFeature {
title: String,
location: Point,
}
code:api2(rs)
pub trait Feature {
fn serialize_geometry(ser);
fn serialize_properties(ser);
}
code:api2(rs)
pub trait Feature {
fn geometry(&self) -> impl Serialize + '_;
fn properties(&self) -> impl Serialize + '_;
}
code:plan3.rs
struct MyFeature {
title: String,
location: Point,
}