maplibre/legacy/geometry_tile_data.rs
1//! Translated from https://github.com/maplibre/maplibre-native/blob/4add9ea/src/mbgl/tile/geometry_tile_data.cpp
2//! In maplibre-native GeometryTileFeature are traits/classes and there are impls for symbol, fill, line features etc.
3//! The same is true for the data objects which might be backed by geojson
4
5use std::ops::Index;
6
7use crate::{
8 euclid::Point2D,
9 legacy::{layout::symbol_feature::SymbolGeometryTileFeature, TileSpace},
10};
11
12/// maplibre/maplibre-native#4add9ea original name: GeometryCoordinate
13pub type GeometryCoordinate = Point2D<i16, TileSpace>;
14
15/// maplibre/maplibre-native#4add9ea original name: GeometryCoordinates(pub
16#[derive(Default, Clone, Debug)]
17pub struct GeometryCoordinates(pub Vec<GeometryCoordinate>);
18impl GeometryCoordinates {
19 /// maplibre/maplibre-native#4add9ea original name: len
20 pub fn len(&self) -> usize {
21 self.0.len()
22 }
23}
24impl Index<usize> for GeometryCoordinates {
25 /// maplibre/maplibre-native#4add9ea original name: Output
26 type Output = GeometryCoordinate;
27
28 /// maplibre/maplibre-native#4add9ea original name: index
29 fn index(&self, index: usize) -> &Self::Output {
30 &self.0[index]
31 }
32}
33
34/// maplibre/maplibre-native#4add9ea original name: GeometryCollection
35pub type GeometryCollection = Vec<GeometryCoordinates>;
36
37// TODO: The following types are not final
38/// maplibre/maplibre-native#4add9ea original name: Value
39pub type Value = geo_types::Geometry;
40/// maplibre/maplibre-native#4add9ea original name: Identifier
41pub type Identifier = String;
42/// maplibre/maplibre-native#4add9ea original name: PropertyMap
43pub type PropertyMap = serde_json::Value;
44
45/// maplibre/maplibre-native#4add9ea original name: FeatureType
46#[derive(PartialEq)]
47pub enum FeatureType {
48 Unknown = 0,
49 Point = 1,
50 LineString = 2,
51 Polygon = 3,
52}
53
54/// maplibre/maplibre-native#4add9ea original name: SymbolGeometryTileLayer
55#[derive(Clone)]
56pub struct SymbolGeometryTileLayer {
57 pub name: String,
58 pub features: Vec<SymbolGeometryTileFeature>,
59}
60impl SymbolGeometryTileLayer {
61 /// maplibre/maplibre-native#4add9ea original name: featureCount
62 pub fn feature_count(&self) -> usize {
63 self.features.len()
64 }
65
66 // Returns the feature object at the given position within the layer. The
67 // returned feature object may *not* outlive the layer object.
68 /// maplibre/maplibre-native#4add9ea original name: getFeature
69 pub fn get_feature(&self, index: usize) -> Box<SymbolGeometryTileFeature> {
70 Box::new(self.features[index].clone())
71 }
72
73 /// maplibre/maplibre-native#4add9ea original name: getName
74 pub fn get_name(&self) -> &str {
75 &self.name
76 }
77}
78
79/// maplibre/maplibre-native#4add9ea original name: SymbolGeometryTileData
80#[derive(Clone)]
81struct SymbolGeometryTileData;
82
83impl SymbolGeometryTileData {
84 /// maplibre/maplibre-native#4add9ea original name: clone
85 pub fn clone(&self) -> Box<SymbolGeometryTileData> {
86 todo!()
87 }
88
89 // Returns the layer with the given name. The returned layer object *may*
90 // outlive the data object.
91 /// maplibre/maplibre-native#4add9ea original name: getLayer
92 pub fn get_layer(&self, name: &str) -> Box<SymbolGeometryTileLayer> {
93 todo!()
94 }
95}