44use std:: sync:: Arc ;
55
66use egui:: FontDefinitions ;
7- use galileo:: expr:: {
8- ControlPoint , CubicBezierInterpolation , ExponentialInterpolation , Expr , LinearInterpolation ,
9- } ;
7+ use galileo:: MapBuilder ;
108use galileo:: layer:: VectorTileLayer ;
119use galileo:: layer:: data_provider:: remove_parameters_modifier;
1210use galileo:: layer:: vector_tile_layer:: VectorTileLayerBuilder ;
@@ -16,9 +14,9 @@ use galileo::layer::vector_tile_layer::style::{
1614use galileo:: render:: text:: RustybuzzRasterizer ;
1715use galileo:: render:: text:: text_service:: TextService ;
1816use galileo:: tile_schema:: { TileIndex , TileSchema , TileSchemaBuilder } ;
19- use galileo:: { Color , MapBuilder } ;
2017use galileo_egui:: { EguiMap , EguiMapState } ;
2118use parking_lot:: RwLock ;
19+ use serde_json:: json;
2220
2321#[ cfg( not( target_arch = "wasm32" ) ) ]
2422fn main ( ) {
@@ -128,24 +126,17 @@ fn linear_interpolation_style() -> StyleRule {
128126 min_resolution : None ,
129127 filter : None ,
130128 symbol : VectorTileSymbol :: Polygon ( VectorTilePolygonSymbol {
131- fill_color : Expr :: InterpolateLinear ( Box :: new ( LinearInterpolation {
132- input : Expr :: Zoom ,
133- control_points : vec ! [
134- ControlPoint {
135- input: 2.0 . into( ) ,
136- output: Color :: try_from_hex( "#81C4ec" ) . unwrap( ) . into( ) ,
137- } ,
138- ControlPoint {
139- input: 5.0 . into( ) ,
140- output: Color :: try_from_hex( "#29546d" ) . unwrap( ) . into( ) ,
141- } ,
142- ControlPoint {
143- input: 8.0 . into( ) ,
144- output: Color :: try_from_hex( "#3d835c" ) . unwrap( ) . into( ) ,
145- } ,
146- ] ,
129+ fill_color : serde_json:: from_value ( json ! ( {
130+ "Linear" : {
131+ "input" : "Zoom" ,
132+ "control_points" : [
133+ { "input" : 2 , "output" : "#81c4ecff" } ,
134+ { "input" : 5 , "output" : "#29546dff" } ,
135+ { "input" : 8 , "output" : "#3d835cff" }
136+ ]
137+ }
147138 } ) )
148- . into ( ) ,
139+ . unwrap ( ) ,
149140 } ) ,
150141 }
151142}
@@ -158,25 +149,18 @@ fn exponential_interpolation_style() -> StyleRule {
158149 min_resolution : None ,
159150 filter : None ,
160151 symbol : VectorTileSymbol :: Polygon ( VectorTilePolygonSymbol {
161- fill_color : Expr :: InterpolateExp ( Box :: new ( ExponentialInterpolation {
162- base : 2.0 ,
163- input : Expr :: Zoom ,
164- control_points : vec ! [
165- ControlPoint {
166- input: 2.0 . into( ) ,
167- output: Color :: try_from_hex( "#81C4ec" ) . unwrap( ) . into( ) ,
168- } ,
169- ControlPoint {
170- input: 5.0 . into( ) ,
171- output: Color :: try_from_hex( "#29546d" ) . unwrap( ) . into( ) ,
172- } ,
173- ControlPoint {
174- input: 8.0 . into( ) ,
175- output: Color :: try_from_hex( "#3d835c" ) . unwrap( ) . into( ) ,
176- } ,
177- ] ,
152+ fill_color : serde_json:: from_value ( json ! ( {
153+ "Exponential" : {
154+ "base" : 2 ,
155+ "input" : "Zoom" ,
156+ "control_points" : [
157+ { "input" : 2 , "output" : "#81c4ecff" } ,
158+ { "input" : 5 , "output" : "#29546dff" } ,
159+ { "input" : 8 , "output" : "#3d835cff" }
160+ ]
161+ }
178162 } ) )
179- . into ( ) ,
163+ . unwrap ( ) ,
180164 } ) ,
181165 }
182166}
@@ -189,25 +173,18 @@ fn cubic_interpolation_style() -> StyleRule {
189173 min_resolution : None ,
190174 filter : None ,
191175 symbol : VectorTileSymbol :: Polygon ( VectorTilePolygonSymbol {
192- fill_color : Expr :: InterpolateCubicBezier ( Box :: new ( CubicBezierInterpolation {
193- curve_params : [ 0.25 , 0.0 , 0.75 , 1.0 ] ,
194- input : Expr :: Zoom ,
195- control_points : vec ! [
196- ControlPoint {
197- input: 2.0 . into( ) ,
198- output: Color :: try_from_hex( "#81C4ec" ) . unwrap( ) . into( ) ,
199- } ,
200- ControlPoint {
201- input: 5.0 . into( ) ,
202- output: Color :: try_from_hex( "#29546d" ) . unwrap( ) . into( ) ,
203- } ,
204- ControlPoint {
205- input: 8.0 . into( ) ,
206- output: Color :: try_from_hex( "#3d835c" ) . unwrap( ) . into( ) ,
207- } ,
208- ] ,
176+ fill_color : serde_json:: from_value ( json ! ( {
177+ "CubicBezier" : {
178+ "curve_params" : [ 0.25 , 0.0 , 0.75 , 1.0 ] ,
179+ "input" : "Zoom" ,
180+ "control_points" : [
181+ { "input" : 2 , "output" : "#81c4ecff" } ,
182+ { "input" : 5 , "output" : "#29546dff" } ,
183+ { "input" : 8 , "output" : "#3d835cff" }
184+ ]
185+ }
209186 } ) )
210- . into ( ) ,
187+ . unwrap ( ) ,
211188 } ) ,
212189 }
213190}
0 commit comments