Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/feature_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
2 changes: 1 addition & 1 deletion examples/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.87.0"
channel = "1.88.0"
components = ["clippy", "rustfmt"]
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 10 additions & 9 deletions src/supercluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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(),
]));
Expand Down Expand Up @@ -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]),
])),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use geojson::{Feature, FeatureCollection, Value};
use geojson::{Feature, FeatureCollection, GeometryValue};
use std::{fs, path::Path};
use supercluster::range::DataRange;

Expand All @@ -10,9 +10,9 @@ pub fn get_data_range(data: &Vec<Feature>) -> Option<DataRange> {

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);
Expand Down
10 changes: 5 additions & 5 deletions tests/supercluster_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()),
},
])
Expand Down