|
1 | | -use contour::ContourBuilder; |
| 1 | +use contour::{ContourBuilder, Float}; |
2 | 2 | use geojson::{FeatureCollection, GeoJson}; |
3 | 3 | use std::fs::File; |
4 | 4 | use std::io::{BufWriter, Write}; |
5 | 5 |
|
6 | 6 | fn main() { |
7 | 7 | let pot_pop_fr = include_str!("../tests/fixtures/pot_pop_fr.json"); |
8 | 8 | let raw_data: serde_json::Value = serde_json::from_str(pot_pop_fr).unwrap(); |
9 | | - let matrix: Vec<f64> = raw_data["data"] |
| 9 | + let matrix: Vec<Float> = raw_data["data"] |
10 | 10 | .as_array() |
11 | 11 | .unwrap() |
12 | 12 | .iter() |
13 | | - .map(|x| x.as_f64().unwrap()) |
| 13 | + .map(|x| { |
| 14 | + #[cfg(not(feature = "f32"))] |
| 15 | + { |
| 16 | + x.as_f64().unwrap() |
| 17 | + } |
| 18 | + #[cfg(feature = "f32")] |
| 19 | + { |
| 20 | + x.as_f64().unwrap() as f32 |
| 21 | + } |
| 22 | + }) |
14 | 23 | .collect(); |
15 | 24 | let h = raw_data["height"].as_u64().unwrap() as u32; |
16 | 25 | let w = raw_data["width"].as_u64().unwrap() as u32; |
@@ -51,11 +60,20 @@ fn main() { |
51 | 60 |
|
52 | 61 | let volcano = include_str!("../tests/fixtures/volcano.json"); |
53 | 62 | let raw_data: serde_json::Value = serde_json::from_str(volcano).unwrap(); |
54 | | - let matrix: Vec<f64> = raw_data["data"] |
| 63 | + let matrix: Vec<Float> = raw_data["data"] |
55 | 64 | .as_array() |
56 | 65 | .unwrap() |
57 | 66 | .iter() |
58 | | - .map(|x| x.as_f64().unwrap()) |
| 67 | + .map(|x| { |
| 68 | + #[cfg(not(feature = "f32"))] |
| 69 | + { |
| 70 | + x.as_f64().unwrap() |
| 71 | + } |
| 72 | + #[cfg(feature = "f32")] |
| 73 | + { |
| 74 | + x.as_f64().unwrap() as f32 |
| 75 | + } |
| 76 | + }) |
59 | 77 | .collect(); |
60 | 78 | let h = raw_data["height"].as_u64().unwrap() as u32; |
61 | 79 | let w = raw_data["width"].as_u64().unwrap() as u32; |
|
0 commit comments