diff --git a/examples/feature_builder.rs b/examples/feature_builder.rs index 99d6b4d..78fd016 100644 --- a/examples/feature_builder.rs +++ b/examples/feature_builder.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), SuperclusterError> { // Get a tile from the Supercluster instance let tile = index.get_tile(0, 0.0, 0.0)?; - println!("Tile: {:?}", tile); + println!("Tile: {tile:?}"); Ok(()) } diff --git a/examples/tile.rs b/examples/tile.rs index 99d6b4d..78fd016 100644 --- a/examples/tile.rs +++ b/examples/tile.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), SuperclusterError> { // Get a tile from the Supercluster instance let tile = index.get_tile(0, 0.0, 0.0)?; - println!("Tile: {:?}", tile); + println!("Tile: {tile:?}"); Ok(()) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e0b3bc8..c6f8dfa 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.87.0" +channel = "1.88.0" components = ["clippy", "rustfmt"] diff --git a/src/builder.rs b/src/builder.rs index 4c3b430..d366cb0 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -4,7 +4,7 @@ use std::{collections::HashMap, hash::BuildHasherDefault}; -use geojson::{feature::Id, Feature, Geometry, Value}; +use geojson::{feature::Id, Feature, Geometry, GeometryValue}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use twox_hash::XxHash64; @@ -104,7 +104,7 @@ impl FeatureBuilder { .into_iter() .map(|(id, point)| Feature { id: Some(Id::String(id)), - geometry: Some(Geometry::new(Value::Point(point))), + geometry: Some(Geometry::new(GeometryValue::new_point(point))), bbox: None, properties: None, foreign_members: None, diff --git a/src/supercluster.rs b/src/supercluster.rs index 94c2f11..379879c 100644 --- a/src/supercluster.rs +++ b/src/supercluster.rs @@ -16,7 +16,7 @@ use std::{collections::HashMap, f64::consts::PI, hash::BuildHasherDefault}; #[cfg(feature = "cluster_metadata")] use geojson::JsonObject; -use geojson::{feature::Id, Feature, FeatureCollection, Geometry, Value::Point}; +use geojson::{feature::Id, Feature, FeatureCollection, Geometry, GeometryValue}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; #[cfg(feature = "cluster_metadata")] @@ -154,7 +154,7 @@ impl Supercluster { // Store internal point/cluster data in flat numeric arrays for performance let coordinates = match &feature.geometry { Some(geometry) => match &geometry.value { - Point(coords) => coords, + GeometryValue::Point { coordinates } => coordinates, _ => continue, }, None => continue, @@ -634,7 +634,7 @@ impl Supercluster { let (px, py) = match p.geometry.as_ref() { Some(geometry) => { - if let Point(coordinates) = &geometry.value { + if let GeometryValue::Point { coordinates } = &geometry.value { match &self.options.coordinate_system { CoordinateSystem::Cartesian { range } => ( range.normalize(coordinates[0]), @@ -666,7 +666,7 @@ impl Supercluster { self.points[data[k + OFFSET_ID] as usize].id.to_owned() }; - let geometry = Geometry::new(Point(vec![ + let geometry = Geometry::new(GeometryValue::new_point(vec![ (self.options.extent * (cluster.0 * z2 - x)).round(), (self.options.extent * (cluster.1 * z2 - y)).round(), ])); @@ -859,11 +859,11 @@ fn get_cluster( #[cfg(feature = "cluster_metadata")] metadata: &[JsonObject], ) -> Feature { let geometry = match coordinate_system { - CoordinateSystem::Cartesian { range } => Geometry::new(Point(vec![ + CoordinateSystem::Cartesian { range } => Geometry::new(GeometryValue::new_point(vec![ range.denormalize(data[i]), range.denormalize(data[i + 1]), ])), - CoordinateSystem::LatLng => Geometry::new(Point(vec![ + CoordinateSystem::LatLng => Geometry::new(GeometryValue::new_point(vec![ convert_spherical_mercator_to_longitude(data[i]), convert_spherical_mercator_to_latitude(data[i + 1]), ])), @@ -980,8 +980,6 @@ fn convert_spherical_mercator_to_latitude(y: f64) -> f64 { mod tests { use super::*; - use geojson::JsonObject; - fn setup() -> Supercluster { let options = Supercluster::builder().build(); Supercluster::new(options) @@ -1012,7 +1010,10 @@ mod tests { let feature = features.first().unwrap(); assert_eq!(feature.id, Some(Id::String("0".to_string()))); - assert_eq!(feature.geometry, Some(Geometry::new(Point(vec![0.0, 0.0])))); + assert_eq!( + feature.geometry, + Some(Geometry::new(GeometryValue::new_point(vec![0.0, 0.0]))) + ); } #[test] diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 3e92361..2675e8e 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,4 +1,4 @@ -use geojson::{Feature, FeatureCollection, Value}; +use geojson::{Feature, FeatureCollection, GeometryValue}; use std::{fs, path::Path}; use supercluster::range::DataRange; @@ -10,9 +10,9 @@ pub fn get_data_range(data: &Vec) -> Option { for feature in data { if let Some(geometry) = &feature.geometry { - if let Value::Point(ref coords) = geometry.value { - let x = coords[0]; - let y = coords[1]; + if let GeometryValue::Point { ref coordinates } = geometry.value { + let x = coordinates[0]; + let y = coordinates[1]; min_x = min_x.min(x); min_y = min_y.min(y); max_x = max_x.max(x); diff --git a/tests/supercluster_integration_test.rs b/tests/supercluster_integration_test.rs index cf64d2d..24aa8ec 100644 --- a/tests/supercluster_integration_test.rs +++ b/tests/supercluster_integration_test.rs @@ -3,7 +3,7 @@ mod common; use common::{ get_data_range, load_cartesian, load_places, load_tile_places, load_tile_places_with_min_5, }; -use geojson::{Feature, Geometry, JsonObject, Value::Point}; +use geojson::{Feature, Geometry, GeometryValue, JsonObject}; use supercluster::{CoordinateSystem, Supercluster, SuperclusterError}; #[test] @@ -195,28 +195,28 @@ fn test_clusters_when_query_crosses_international_dateline() { id: None, bbox: None, foreign_members: None, - geometry: Some(Geometry::new(Point(vec![-178.989, 0.0]))), + geometry: Some(Geometry::new(GeometryValue::new_point(vec![-178.989, 0.0]))), properties: Some(JsonObject::new()), }, Feature { id: None, bbox: None, foreign_members: None, - geometry: Some(Geometry::new(Point(vec![-178.99, 0.0]))), + geometry: Some(Geometry::new(GeometryValue::new_point(vec![-178.99, 0.0]))), properties: Some(JsonObject::new()), }, Feature { id: None, bbox: None, foreign_members: None, - geometry: Some(Geometry::new(Point(vec![-178.991, 0.0]))), + geometry: Some(Geometry::new(GeometryValue::new_point(vec![-178.991, 0.0]))), properties: Some(JsonObject::new()), }, Feature { id: None, bbox: None, foreign_members: None, - geometry: Some(Geometry::new(Point(vec![-178.992, 0.0]))), + geometry: Some(Geometry::new(GeometryValue::new_point(vec![-178.992, 0.0]))), properties: Some(JsonObject::new()), }, ])