Skip to content

Commit 32b10ac

Browse files
authored
Added support for cubic interpolation (galileo-map#301)
* feat: Added cubic interpolation * feat: replaced nr method with bisection * add: tests for cubic_interpolation
1 parent 327d03d commit 32b10ac

2 files changed

Lines changed: 390 additions & 2 deletions

File tree

galileo/examples/vector_tiles_expressions.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ impl eframe::App for App {
4141
if ui.button("Exponential Interpolation").clicked() {
4242
self.set_style(with_overlay_rule(exponential_interpolation_style()));
4343
}
44+
if ui.button("Cubic Interpolation").clicked() {
45+
self.set_style(with_overlay_rule(cubic_interpolation_style()));
46+
}
4447
if ui.button("Stepped Interpolation").clicked() {
4548
self.set_style(with_overlay_rule(stepped_interpolation_style()));
4649
}
@@ -183,6 +186,30 @@ fn exponential_interpolation_style() -> StyleRule {
183186
.expect("invalid style json")
184187
}
185188

189+
fn cubic_interpolation_style() -> StyleRule {
190+
serde_json::from_str(
191+
r##"{
192+
"symbol": {
193+
"polygon": {
194+
"fill_color": {
195+
"interpolate": {
196+
"cubic":{
197+
"control_points": [0.25, 0.0, 0.75, 1.0],
198+
"step_values": [
199+
{"resolution": 9783.939620501465, "step_value": "#81C4EC"},
200+
{"resolution": 611.4962262813416, "step_value": "#29546dff"},
201+
{"resolution": 2.3886571339114906, "step_value": "#3d835cff"}
202+
]
203+
}
204+
}
205+
}
206+
}
207+
}
208+
}"##,
209+
)
210+
.expect("invalid style json")
211+
}
212+
186213
fn tile_schema() -> TileSchema {
187214
TileSchemaBuilder::web_mercator(2..16)
188215
.rect_tile_size(1024)

0 commit comments

Comments
 (0)