mvt_reader/
feature.rs

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