seems alright
This commit is contained in:
parent
ebe7bbb51d
commit
eac1bd0d13
58 changed files with 23125 additions and 153505 deletions
|
|
@ -331,7 +331,10 @@ impl PlaceData {
|
|||
let lon = extract_f32_col(&df, "lon")?;
|
||||
let population: Vec<u32> = if df.column("population").is_ok() {
|
||||
let pop_f32 = extract_f32_col(&df, "population")?;
|
||||
pop_f32.iter().map(|&val| val.max(0.0) as u32).collect()
|
||||
pop_f32
|
||||
.iter()
|
||||
.map(|&val| val.max(0.0).min(u32::MAX as f32) as u32)
|
||||
.collect()
|
||||
} else {
|
||||
vec![0; row_count]
|
||||
};
|
||||
|
|
@ -419,11 +422,11 @@ mod tests {
|
|||
|
||||
fn test_city_rows() -> [(&'static str, f32, f32, u32); 5] {
|
||||
[
|
||||
("London", 51.5074456, -0.1277653, 8_908_083),
|
||||
("Westminster", 51.4973206, -0.137149, 211_365),
|
||||
("City of London", 51.5156177, -0.0919983, 10_847),
|
||||
("Cambridge", 52.2055314, 0.1186637, 145_818),
|
||||
("Oxford", 51.7520131, -1.2578499, 165_000),
|
||||
("London", 51.507_446, -0.1277653, 8_908_083),
|
||||
("Westminster", 51.497_322, -0.137149, 211_365),
|
||||
("City of London", 51.515_617, -0.0919983, 10_847),
|
||||
("Cambridge", 52.205_532, 0.1186637, 145_818),
|
||||
("Oxford", 51.752_014, -1.2578499, 165_000),
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -503,7 +506,7 @@ mod tests {
|
|||
let cities = test_city_candidates();
|
||||
|
||||
assert_eq!(
|
||||
nearest_display_city(51.3713049, -0.101957, &cities),
|
||||
nearest_display_city(51.371_304, -0.101957, &cities),
|
||||
Some("London")
|
||||
);
|
||||
}
|
||||
|
|
@ -513,7 +516,7 @@ mod tests {
|
|||
let cities = test_city_candidates();
|
||||
|
||||
assert_eq!(
|
||||
nearest_display_city(52.1277704, -0.0813098, &cities),
|
||||
nearest_display_city(52.127_77, -0.0813098, &cities),
|
||||
Some("Cambridge")
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue