pub fn count_way_elements(elements: &[RailwayElement]) -> usize
Expand description

Counts the number of Way elements in a vector of RailwayElements.

This function takes a slice of RailwayElements as input and returns the count of Way elements as a usize.

Arguments

  • elements - A slice of RailwayElements to count the Way elements in.

Example

use openrailwaymap_exporter::importer::overpass_importer::count_way_elements;
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 way_count = count_way_elements(&elements);
assert_eq!(way_count, 1);