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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Serialize, Deserialize, Debug)]
struct Style {
version: u32,
name: String,
sprite: String,
glyphs: String,
sources: HashMap<String, Source>,
layers: Vec<Layer>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "kebab-case")]
struct Layer {
id: String,
r#type: String,
filter: Option<Value>,
layout: Option<Value>,
maxzoom: Option<u32>,
mainzoom: Option<u32>,
metadata: Option<Value>,
paint: Option<Value>,
source: Option<String>,
source_layer: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Source {
r#type: SourceType,
attribution: Option<String>,
bounds: Option<Vec<f64>>,
buffer: Option<u32>,
#[serde(flatten)]
cluster: Option<Cluster>,
data: Option<String>,
encoding: Option<String>,
filter: Option<String>,
line_metric: Option<bool>,
maxzoom: Option<u32>,
minzoom: Option<u32>,
promote_id: Option<Value>,
scheme: Option<String>,
tile_size: Option<u32>,
tiles: Option<Vec<String>>,
tolerance: Option<f64>,
url: Option<String>,
volatile: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "kebab-case")]
enum SourceType {
Vector,
Raster,
RasterDem,
Geojson,
Image,
Video,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Cluster {
cluster: Option<bool>,
cluster_max_zoom: Option<u32>,
cluster_min_points: Option<u32>,
cluster_properties: Option<Value>,
cluster_radius: Option<u32>,
}