|
|
@@ -85,18 +85,36 @@ impl Config {
|
|
85
|
85
|
let mut sources_vec: Vec<(String, TileSource)> = Vec::with_capacity(sources_table.len());
|
|
86
|
86
|
|
|
87
|
87
|
for (id, (name, source)) in sources_table.iter().enumerate() {
|
|
|
88
|
+ let min_zoom = source.get("min_zoom")
|
|
|
89
|
+ .unwrap_or_else(|| &Value::Integer(0))
|
|
|
90
|
+ .as_integer()
|
|
|
91
|
+ .ok_or_else(|| "min_zoom has to be an integer".to_string())
|
|
|
92
|
+ .and_then(|m| {
|
|
|
93
|
+ if m < 0 || m > 30 {
|
|
|
94
|
+ Err(format!("min_zoom = {} is out of bounds, has to be in interval [0, 30]", m))
|
|
|
95
|
+ } else {
|
|
|
96
|
+ Ok(m)
|
|
|
97
|
+ }
|
|
|
98
|
+ })?;
|
|
|
99
|
+
|
|
88
|
100
|
let max_zoom = source.get("max_zoom")
|
|
89
|
101
|
.ok_or_else(|| format!("source {:?} is missing \"max_zoom\" entry", name))?
|
|
90
|
102
|
.as_integer()
|
|
91
|
103
|
.ok_or_else(|| "max_zoom has to be an integer".to_string())
|
|
92
|
104
|
.and_then(|m| {
|
|
93
|
|
- if m <= 0 || m > 30 {
|
|
94
|
|
- Err(format!("max_zoom = {} is out of bounds, has to be in interval [1, 30]", m))
|
|
|
105
|
+ if m < 0 || m > 30 {
|
|
|
106
|
+ Err(format!("max_zoom = {} is out of bounds, has to be in interval [0, 30]", m))
|
|
95
|
107
|
} else {
|
|
96
|
108
|
Ok(m)
|
|
97
|
109
|
}
|
|
98
|
110
|
})?;
|
|
99
|
111
|
|
|
|
112
|
+ if min_zoom > max_zoom {
|
|
|
113
|
+ warn!("min_zoom ({}) and max_zoom ({}) allow no valid tiles", min_zoom, max_zoom);
|
|
|
114
|
+ } else if min_zoom == max_zoom {
|
|
|
115
|
+ warn!("min_zoom ({}) and max_zoom ({}) allow only one zoom level", min_zoom, max_zoom);
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
100
|
118
|
let url_template = source.get("url_template")
|
|
101
|
119
|
.ok_or_else(|| format!("source {:?} is missing \"url_template\" entry", name))?
|
|
102
|
120
|
.as_str()
|
|
|
@@ -121,6 +139,7 @@ impl Config {
|
|
121
|
139
|
url_template.to_string(),
|
|
122
|
140
|
path,
|
|
123
|
141
|
extension.to_string(),
|
|
|
142
|
+ min_zoom as u32,
|
|
124
|
143
|
max_zoom as u32,
|
|
125
|
144
|
),
|
|
126
|
145
|
));
|