use crate::osm::PrimitiveBlock;
use crate::{osm, osm::relation::MemberType};
use super::common::{OsmEntryId, ReferenceKey, References, Referential, Tagable, Tags};
#[derive(Clone, Debug)]
pub struct Way {
id: OsmEntryId,
refs: References,
tags: Tags,
}
impl Way {
pub fn id(&self) -> OsmEntryId {
self.id
}
#[inline]
pub fn tags(&self) -> &Tags {
&self.tags
}
#[inline]
pub fn refs(&self) -> &References {
&self.refs
}
#[inline]
pub fn from_raw(value: &osm::Way, block: &PrimitiveBlock) -> Self {
Way {
id: OsmEntryId::way(value.id),
refs: value.references(block),
tags: value.tags(block),
}
}
}
impl Tagable for osm::Way {
fn indices(&self) -> impl Iterator<Item = (&u32, &u32)> {
self.keys.iter().zip(self.vals.iter())
}
}
impl Referential for osm::Way {
fn indices(&self) -> impl Iterator<Item = ReferenceKey> {
self.refs
.iter()
.map(|id| (&-1i32, id, &(MemberType::Node as i32)))
}
}