pub fn create_nodes(elements: &[RailwayElement]) -> Vec<RailwayNode>
Expand description

Create a vector of RailwayNodes from the provided RailwayElements.

This function combines the nodes created from RailwayElements of type Node and the nodes created from RailwayElements of type Way which don’t have a corresponding node in the elements of type Node.

Arguments

  • elements - A slice of RailwayElements from which the nodes will be created.

Returns

A vector of RailwayNodes created from the input RailwayElements.

Example

use openrailwaymap_exporter::importer::overpass_importer::create_nodes;
use openrailwaymap_exporter::importer::overpass_importer::{ElementType, RailwayElement};
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 nodes = create_nodes(&elements);
println!("Created {} nodes", nodes.len());
assert_eq!(nodes.len(), 1);