pub fn from_railway_elements(elements: &[RailwayElement]) -> RailwayGraph
Expand description

Create a RailwayGraph from a vector of RailwayElements.

The function processes the input elements to create a graph with nodes and edges.

Arguments

  • elements - A vector of RailwayElements from which the graph will be created.

Returns

A RailwayGraph created from the input RailwayElements.

Example

use openrailwaymap_exporter::importer::overpass_importer::{ElementType, RailwayElement, Coordinate};
use openrailwaymap_exporter::importer::overpass_importer::from_railway_elements;
use std::collections::HashMap;

let elements = vec![
    RailwayElement {
        id: 1,
        element_type: ElementType::Node,
        lat: Some(50.1109),
        lon: Some(8.6821),
        tags: Some(HashMap::new()),
        nodes: None,
        geometry: None,
    },
    RailwayElement {
        id: 2,
        element_type: ElementType::Way,
        lat: None,
        lon: None,
        tags: Some(HashMap::new()),
        nodes: Some(vec![1, 3]),
        geometry: None,
    },
];

let railway_graph = from_railway_elements(&elements);
println!("Created railway graph with {} nodes", railway_graph.physical_graph.graph.node_count());