mvt_reader/feature.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//! This module provides types and utilities for working with features in the `mvt-reader` crate.
//!
//! A feature represents a geographic entity with geometry and associated properties. Features are typically found within layers of a vector tile.
//!
//! # Types
//!
//! The `feature` module defines the following types:
//!
//! - `Feature`: Represents a feature with geometry and properties.
use std::collections::HashMap;
use geo_types::Geometry;
/// A structure representing a feature in a vector tile.
pub struct Feature {
/// The geometry of the feature.
pub geometry: Geometry<f32>,
/// Optional properties associated with the feature.
pub properties: Option<HashMap<String, String>>,
}
impl Feature {
/// Retrieves the geometry of the feature.
///
/// # Returns
///
/// A reference to the geometry of the feature.
///
/// # Examples
///
/// ```
/// use mvt_reader::feature::Feature;
/// use geo_types::{Geometry, Point};
///
/// let feature = Feature {
/// geometry: Geometry::Point(Point::new(0.0, 0.0)),
/// properties: None,
/// };
///
/// let geometry = feature.get_geometry();
/// println!("{:?}", geometry);
/// ```
pub fn get_geometry(&self) -> &Geometry<f32> {
&self.geometry
}
}