@@ -23,7 +23,7 @@ pub struct VectorTileStyle {
2323
2424impl VectorTileStyle {
2525 /// Get a rule for the given feature.
26- pub fn get_style_rule ( & self , layer_name : & str , feature : & MvtFeature ) -> Option < & StyleRule > {
26+ pub fn get_style_rule ( & self , layer_name : & str , resolution_level : f64 , feature : & MvtFeature ) -> Option < & StyleRule > {
2727 self . rules . iter ( ) . find ( |& rule| {
2828 let correct_geometry_type = match feature. geometry {
2929 MvtGeometry :: Point ( _)
@@ -50,6 +50,12 @@ impl VectorTileStyle {
5050 if rule. layer_name . as_ref ( ) . is_some_and ( |v| v != layer_name) {
5151 return false ;
5252 }
53+ if rule. max_resolution . is_some_and ( |v| v < resolution_level) {
54+ return false ;
55+ }
56+ if rule. min_resolution . is_some_and ( |v| v > resolution_level) {
57+ return false ;
58+ }
5359
5460 let filter_check_passed = rule. properties . iter ( ) . all ( |filter| {
5561 let value = feature. properties . get ( & filter. property_name ) ;
@@ -102,6 +108,10 @@ fn compare_numeric(a: &galileo_mvt::MvtValue, b: &str, cmp: impl Fn(f64, f64) ->
102108pub struct StyleRule {
103109 /// If set, a feature must belong to the set layer. If not set, layer is not checked.
104110 pub layer_name : Option < String > ,
111+ /// Determins the maximum resolution
112+ pub max_resolution : Option < f64 > ,
113+ /// Determins the minimum resolution
114+ pub min_resolution : Option < f64 > ,
105115 /// Specifies a set of attributes of a feature that must have the given values for this rule to be applied.
106116 #[ serde( default ) ]
107117 pub properties : Vec < PropertyFilter > ,
@@ -331,6 +341,8 @@ mod tests {
331341 fn serialize_with_bincode ( ) {
332342 let rule = StyleRule {
333343 layer_name : None ,
344+ min_resolution : None ,
345+ max_resolution : None ,
334346 properties : vec ! [ ] ,
335347 symbol : VectorTileSymbol :: None ,
336348 } ;
0 commit comments