diff --git a/CHANGES.md b/CHANGES.md index 4ee8b67..dacffce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,9 @@ ## Unreleased * Changed license field to [SPDX 2.1 license expression](https://spdx.dev/spdx-specification-21-web-version/#h.jxpfx0ykyb60) +* Bump min version of geo-types, and update geo_types::Coordinate to non-deprecated geo_types::Coord +* BREAKING: WktNum must implement PartialEq +* Implement PartialEq for Wkt ## 0.10.3 - 2022-06-22 diff --git a/Cargo.toml b/Cargo.toml index 844f0c5..e197645 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,14 +10,14 @@ keywords = ["geo", "geospatial", "wkt"] edition = "2021" [dependencies] -geo-types = { version = "0.7.4", optional = true } +geo-types = { version = "0.7.8", optional = true } num-traits = "0.2" serde = { version = "1.0", default-features = false, optional = true } thiserror = "1.0.23" log = "0.4.17" [dev-dependencies] -criterion = { version = "0.2" } +criterion = "0.5.1" serde = { version = "1.0", default-features = false, features = ["derive"] } serde_json = "1.0" diff --git a/src/deserialize/mod.rs b/src/deserialize/mod.rs index 625ebd4..0aad8d4 100644 --- a/src/deserialize/mod.rs +++ b/src/deserialize/mod.rs @@ -80,8 +80,8 @@ struct TryFromWktVisitor> { impl> Default for TryFromWktVisitor { fn default() -> Self { Self { - _marker_t: PhantomData::default(), - _marker_g: PhantomData::default(), + _marker_t: PhantomData, + _marker_g: PhantomData, } } } @@ -111,7 +111,7 @@ struct WktVisitor { impl Default for WktVisitor { fn default() -> Self { WktVisitor { - _marker: PhantomData::default(), + _marker: PhantomData, } } } @@ -151,7 +151,7 @@ struct GeometryVisitor { impl Default for GeometryVisitor { fn default() -> Self { GeometryVisitor { - _marker: PhantomData::default(), + _marker: PhantomData, } } } diff --git a/src/geo_types_from_wkt.rs b/src/geo_types_from_wkt.rs index 01dbe44..eb3af4b 100644 --- a/src/geo_types_from_wkt.rs +++ b/src/geo_types_from_wkt.rs @@ -137,12 +137,12 @@ impl TryFrom> for geo_types::GeometryCollection { } } -impl From> for geo_types::Coordinate +impl From> for geo_types::Coord where T: CoordNum, { /// Convert from a WKT Coordinate to a [`geo_types::Coordinate`] - fn from(coord: Coord) -> geo_types::Coordinate { + fn from(coord: Coord) -> geo_types::Coord { coord! { x: coord.x, y: coord.y } } } @@ -188,7 +188,7 @@ where let coords = line_string .0 .into_iter() - .map(geo_types::Coordinate::from) + .map(geo_types::Coord::from) .collect(); geo_types::LineString(coords) diff --git a/src/geo_types_to_wkt.rs b/src/geo_types_to_wkt.rs index a97f6f4..76f94a0 100644 --- a/src/geo_types_to_wkt.rs +++ b/src/geo_types_to_wkt.rs @@ -243,7 +243,7 @@ where } } -fn g_point_to_w_coord(g_point: &geo_types::Coordinate) -> Coord +fn g_point_to_w_coord(g_point: &geo_types::Coord) -> Coord where T: CoordNum, { @@ -263,7 +263,7 @@ where Point(Some(coord)) } -fn g_points_to_w_coords(g_points: &[geo_types::Coordinate]) -> Vec> +fn g_points_to_w_coords(g_points: &[geo_types::Coord]) -> Vec> where T: CoordNum, { @@ -293,11 +293,11 @@ fn g_linestring_to_w_linestring(g_linestring: &geo_types::LineString) -> L where T: CoordNum, { - let &geo_types::LineString(ref g_points) = g_linestring; + let geo_types::LineString(g_points) = g_linestring; g_points_to_w_linestring(g_points) } -fn g_points_to_w_linestring(g_coords: &[geo_types::Coordinate]) -> LineString +fn g_points_to_w_linestring(g_coords: &[geo_types::Coord]) -> LineString where T: CoordNum, { @@ -311,7 +311,7 @@ where { let mut w_lines = vec![]; for g_line in g_lines { - let &geo_types::LineString(ref g_points) = g_line; + let geo_types::LineString(g_points) = g_line; w_lines.push(g_points_to_w_linestring(g_points)); } w_lines @@ -342,14 +342,14 @@ where let mut poly_lines = vec![]; // Outer - let &geo_types::LineString(ref outer_points) = outer_line; + let geo_types::LineString(outer_points) = outer_line; if !outer_points.is_empty() { poly_lines.push(g_points_to_w_linestring(outer_points)); } // Inner let inner = g_lines_to_w_lines(inner_lines); - poly_lines.extend(inner.into_iter()); + poly_lines.extend(inner); Polygon(poly_lines) } @@ -358,7 +358,7 @@ fn g_mpoint_to_w_mpoint(g_mpoint: &geo_types::MultiPoint) -> MultiPoint where T: CoordNum, { - let &geo_types::MultiPoint(ref g_points) = g_mpoint; + let geo_types::MultiPoint(g_points) = g_mpoint; let w_points = g_points_to_w_points(g_points); MultiPoint(w_points) } @@ -367,7 +367,7 @@ fn g_mline_to_w_mline(g_mline: &geo_types::MultiLineString) -> MultiLineSt where T: CoordNum, { - let &geo_types::MultiLineString(ref g_lines) = g_mline; + let geo_types::MultiLineString(g_lines) = g_mline; let w_lines = g_lines_to_w_lines(g_lines); MultiLineString(w_lines) } @@ -387,7 +387,7 @@ fn g_mpolygon_to_w_mpolygon(g_mpolygon: &geo_types::MultiPolygon) -> Multi where T: CoordNum, { - let &geo_types::MultiPolygon(ref g_polygons) = g_mpolygon; + let geo_types::MultiPolygon(g_polygons) = g_mpolygon; let w_polygons = g_polygons_to_w_polygons(g_polygons); MultiPolygon(w_polygons) } @@ -396,7 +396,7 @@ fn g_geocol_to_w_geocol(g_geocol: &geo_types::GeometryCollection) -> Geome where T: CoordNum, { - let &geo_types::GeometryCollection(ref g_geoms) = g_geocol; + let geo_types::GeometryCollection(g_geoms) = g_geocol; let mut w_geoms = vec![]; for g_geom in g_geoms { let w_geom = g_geom_to_w_geom(g_geom); diff --git a/src/lib.rs b/src/lib.rs index 85b93af..5a5132d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,13 +134,13 @@ pub use deserialize::geo_types::deserialize_geometry; )] pub use deserialize::geo_types::deserialize_point; -pub trait WktNum: Num + NumCast + PartialOrd + Copy + fmt::Debug {} -impl WktNum for T where T: Num + NumCast + PartialOrd + Copy + fmt::Debug {} +pub trait WktNum: Num + NumCast + PartialOrd + PartialEq + Copy + fmt::Debug {} +impl WktNum for T where T: Num + NumCast + PartialOrd + PartialEq + Copy + fmt::Debug {} pub trait WktFloat: WktNum + Float {} impl WktFloat for T where T: WktNum + Float {} -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] /// All supported WKT geometry [`types`] pub enum Geometry where diff --git a/src/types/coord.rs b/src/types/coord.rs index 4c4f308..e740ed9 100644 --- a/src/types/coord.rs +++ b/src/types/coord.rs @@ -17,7 +17,7 @@ use crate::{FromTokens, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct Coord where T: WktNum, diff --git a/src/types/geometrycollection.rs b/src/types/geometrycollection.rs index 511c7c2..b1e73a5 100644 --- a/src/types/geometrycollection.rs +++ b/src/types/geometrycollection.rs @@ -17,7 +17,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct GeometryCollection(pub Vec>); impl GeometryCollection diff --git a/src/types/linestring.rs b/src/types/linestring.rs index ea9c89d..dfe6813 100644 --- a/src/types/linestring.rs +++ b/src/types/linestring.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct LineString(pub Vec>); impl LineString diff --git a/src/types/multilinestring.rs b/src/types/multilinestring.rs index b0108af..7a65a55 100644 --- a/src/types/multilinestring.rs +++ b/src/types/multilinestring.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct MultiLineString(pub Vec>); impl MultiLineString diff --git a/src/types/multipoint.rs b/src/types/multipoint.rs index 5c0d80d..051d206 100644 --- a/src/types/multipoint.rs +++ b/src/types/multipoint.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct MultiPoint(pub Vec>); impl MultiPoint diff --git a/src/types/multipolygon.rs b/src/types/multipolygon.rs index 3b40cb5..b76956b 100644 --- a/src/types/multipolygon.rs +++ b/src/types/multipolygon.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct MultiPolygon(pub Vec>); impl MultiPolygon diff --git a/src/types/point.rs b/src/types/point.rs index 27fda20..3239637 100644 --- a/src/types/point.rs +++ b/src/types/point.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct Point(pub Option>); impl Point diff --git a/src/types/polygon.rs b/src/types/polygon.rs index ab94fbf..1c778c2 100644 --- a/src/types/polygon.rs +++ b/src/types/polygon.rs @@ -18,7 +18,7 @@ use crate::{FromTokens, Geometry, WktNum}; use std::fmt; use std::str::FromStr; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq)] pub struct Polygon(pub Vec>); impl Polygon