Skip to content

Instantly share code, notes, and snippets.

@Tristramg
Last active January 29, 2024 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tristramg/e7b1422476e987721bb7165a078c6dc5 to your computer and use it in GitHub Desktop.
Save Tristramg/e7b1422476e987721bb7165a078c6dc5 to your computer and use it in GitHub Desktop.
pub struct Id<T> {
id: String,
_phantom: std::marker::PhantomData<T>,
}
use std::collections::HashMap;
pub struct Topology {
pub metadata: Metadata,
pub networks: Vec<Network>,
}
pub struct LRS {
pub metadata: Metadata,
pub anchors: Vec<Anchor>,
pub linear_referencing_methods: Vec<LrsMethod>,
}
struct Anchor {
id: Id<Anchor>,
name: Option<String>,
node: Option<Node>,
}
struct LrsNode {
network: String,
id: Id<Traversal>,
}
enum DistanceUnit {
Meters,
}
struct LrsMethod {
id: Id<LrsMethod>,
traversal: Node,
used_on: Vec<LrsNode>,
anchors: Vec<Id<Anchor>>,
distances: Vec<f64>,
distance_unit: DistanceUnit,
}
pub struct Geometry {
pub metadata: GeometryMetadata,
// Est-ce qu’on ne voudrait pas plutôt un tableau associatif id_anchor => geometry
// Idem pour les segments
pub anchors: Vec<AnchorGeometry>,
pub networks: Vec<NetworkGeometry>,
}
pub struct Metadata {
pub source: String,
}
pub enum GeometryType {
Geographic,
Schematic,
}
pub struct GeometryMetadata {
pub source: String,
// #[serde(rename = "type")]
pub geometry_type: GeometryType,
}
pub struct Network {
pub id: Id<Network>,
pub segments: Vec<Segment>,
pub nodes: Vec<Node>,
pub traversals: Vec<Traversal>,
}
pub struct Segment {
pub id: Id<Segment>,
}
pub struct Node {
pub id: Id<Node>,
pub connection: Vec<Connection>,
pub metadata: HashMap<String, String>,
}
enum Endpoint {
Begin,
End,
}
pub struct Connection {
pub segment: String,
pub endpoint: Endpoint,
pub metadata: HashMap<String, String>,
}
enum Direction {
Increasing,
Decreasing,
}
pub struct Traversal {
pub id: Id<Traversal>,
pub segments: Vec<String>,
pub directions: Vec<Direction>,
}
pub struct AnchorGeometry {
pub id: Id<Anchor>,
pub geom: geo_types::Point<f64>,
// Que fait-on du SRID ?
}
pub struct NetworkGeometry {
pub id: Id<Network>,
pub segments: Vec<SegmentGeometry>,
}
pub struct SegmentGeometry {
pub id: Id<Segment>,
pub geom: geo_types::LineString<f64>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment