@@ -10,15 +10,16 @@ pub fn apply(layer: &mut Layer, record: &Value, report: &mut Report) {
1010 let st = & record[ "style" ] ;
1111 layer. visible = boolean ( record, "visible" , true ) ;
1212 layer. transparency = ( 100.0 * ( 1.0 - number ( record, "opacity" , 1.0 ) . clamp ( 0.0 , 1.0 ) ) ) as f32 ;
13- layer. min_scale = scale ( st, "maxZoom " , 24 .0) ;
14- layer. max_scale = scale ( st, "minZoom " , 0 .0) ;
13+ layer. min_scale = scale ( st, "minZoom " , 0 .0) ;
14+ layer. max_scale = scale ( st, "maxZoom " , 24 .0) ;
1515 if layer. is_raster ( ) {
1616 report. approximated ( & name, "raster colouring uses RustGIS defaults" ) ;
1717 return ;
1818 }
1919 let mut symbol = Symbol :: default_for ( layer. geometry_type ( ) , 0 ) ;
2020 symbol. fill = color ( st, "fillColor" , Rgba :: rgb ( 0x3b , 0x82 , 0xf6 ) , report, & name) ;
2121 symbol. stroke = color ( st, "strokeColor" , Rgba :: rgb ( 0x1e , 0x40 , 0xaf ) , report, & name) ;
22+ let fill = symbol. fill ;
2223 symbol. fill = symbol. fill . with_alpha ( ( symbol. fill . a ( ) as f64 * number ( st, "fillOpacity" , 0.6 ) . clamp ( 0.0 , 1.0 ) ) . round ( ) as u8 ) ;
2324 symbol. stroke_width = number ( st, "strokeWidth" , 2.0 ) . clamp ( 0.0 , 100.0 ) as f32 ;
2425 symbol. size = ( 2.0 * number ( st, "circleRadius" , 6.0 ) . clamp ( 0.0 , 128.0 ) ) as f32 ;
@@ -41,7 +42,7 @@ pub fn apply(layer: &mut Layer, record: &Value, report: &mut Report) {
4142 Some ( v) => v. to_string ( ) ,
4243 None => String :: new ( ) ,
4344 } ;
44- ( value, painted ( symbol, color ( stop, "color" , symbol . fill , report, & name) , layer. geometry_type ( ) ) )
45+ ( value, painted ( symbol, color ( stop, "color" , fill, report, & name) , layer. geometry_type ( ) , number ( st , "fillOpacity" , 0.6 ) ) )
4546 } )
4647 . collect ( ) ;
4748 layer. renderer = Renderer :: Unique {
@@ -63,11 +64,8 @@ pub fn apply(layer: &mut Layer, record: &Value, report: &mut Report) {
6364 other_strokes : Vec :: new ( ) ,
6465 } ;
6566 } else if mode == "graduated" {
66- let mut pairs: Vec < _ > = stops
67- . iter ( )
68- . take ( 256 )
69- . filter_map ( |s| Some ( ( s. get ( "value" ) ?. as_f64 ( ) ?, color ( s, "color" , symbol. fill , report, & name) ) ) )
70- . collect ( ) ;
67+ let mut pairs: Vec < _ > =
68+ stops. iter ( ) . take ( 256 ) . filter_map ( |s| Some ( ( s. get ( "value" ) ?. as_f64 ( ) ?, color ( s, "color" , fill, report, & name) ) ) ) . collect ( ) ;
7169 pairs. sort_by ( |a, b| a. 0 . total_cmp ( & b. 0 ) ) ;
7270 pairs. dedup_by ( |a, b| a. 0 == b. 0 ) ;
7371 if let Some ( first) = pairs. first ( ) . filter ( |_| pairs. len ( ) >= 2 ) {
@@ -78,7 +76,7 @@ pub fn apply(layer: &mut Layer, record: &Value, report: &mut Report) {
7876 // GeoLibre stores class lower bounds and switches at equality. RustGIS
7977 // stores inclusive upper bounds: the previous float preserves that boundary.
8078 breaks : pairs. iter ( ) . skip ( 1 ) . map ( |p| p. 0 . next_down ( ) ) . chain ( std:: iter:: once ( f64:: MAX ) ) . collect ( ) ,
81- symbols : pairs. iter ( ) . map ( |p| painted ( symbol, p. 1 , layer. geometry_type ( ) ) ) . collect ( ) ,
79+ symbols : pairs. iter ( ) . map ( |p| painted ( symbol, p. 1 , layer. geometry_type ( ) , number ( st , "fillOpacity" , 0.6 ) ) ) . collect ( ) ,
8280 ramp : Default :: default ( ) ,
8381 method : ClassMethod :: Manual ,
8482 class_labels : pairs
@@ -132,8 +130,8 @@ pub fn apply(layer: &mut Layer, record: &Value, report: &mut Report) {
132130 c. size = number ( labels, "size" , 13.0 ) . clamp ( 1.0 , 128.0 ) as f32 ;
133131 c. color = color ( labels, "color" , Rgba :: rgb ( 0x11 , 0x18 , 0x27 ) , report, & name) ;
134132 c. halo = number ( labels, "haloWidth" , 1.5 ) > 0.0 ;
135- c. min_scale = scale ( labels, "maxZoom " , 24 .0) ;
136- c. max_scale = scale ( labels, "minZoom " , 0 .0) ;
133+ c. min_scale = scale ( labels, "minZoom " , 0 .0) ;
134+ c. max_scale = scale ( labels, "maxZoom " , 24 .0) ;
137135 c. placement = if string ( labels, "placement" ) == "line" { LabelPlacement :: Curved } else { LabelPlacement :: Auto } ;
138136 if layer. labels . enabled && layer. dataset . field_index ( & c. field ) . is_none ( ) {
139137 layer. labels . enabled = false ;
@@ -180,8 +178,8 @@ fn color(v: &Value, key: &str, default: Rgba, report: &mut Report, name: &str) -
180178 default
181179}
182180/// Changes the class colour without changing the saved outline or fill opacity.
183- fn painted ( mut s : Symbol , c : Rgba , g : rustgis_data:: GeometryType ) -> Symbol {
184- s. fill = c. with_alpha ( ( u16 :: from ( c. a ( ) ) * u16 :: from ( s . fill . a ( ) ) / 255 ) as u8 ) ;
181+ fn painted ( mut s : Symbol , c : Rgba , g : rustgis_data:: GeometryType , opacity : f64 ) -> Symbol {
182+ s. fill = c. with_alpha ( ( f64 :: from ( c. a ( ) ) * opacity . clamp ( 0.0 , 1.0 ) ) . round ( ) as u8 ) ;
185183 if g == rustgis_data:: GeometryType :: Polyline {
186184 s. stroke = c;
187185 }
0 commit comments