Skip to content

Commit

Permalink
address new warnings from clippy 1.83 (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk authored Dec 14, 2024
1 parent bdb8e97 commit 7716094
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ license = "MIT OR Apache-2.0"
# Used in geozero-cli and geozero-bench
# geozero version must be in sync with flatgeobuf version!
geozero = { version = "0.14.0", default-features = false }
flatgeobuf = "4.4.0"
# flatgeobuf had a breaking (!) change released in 4.5.0, so we'll pin until we adapt to the new version.
flatgeobuf = ">=4.4.0,<4.5.0"

async-trait = "0.1"
byteorder = { version = "1.4.3", default-features = false }
Expand Down
17 changes: 7 additions & 10 deletions geozero/src/geos/geos_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod test {
#[test]
fn point_geom() {
let geojson = r#"{"type": "Point", "coordinates": [1, 1]}"#;
let wkt = "POINT (1.0000000000000000 1.0000000000000000)";
let wkt = "POINT (1 1)";
let mut geos = GeosWriter::new();
assert!(read_geojson(geojson.as_bytes(), &mut geos).is_ok());
assert_eq!(geos.geometry().to_wkt().unwrap(), wkt);
Expand All @@ -192,15 +192,15 @@ mod test {
#[test]
fn multipoint_geom() {
let geojson = GeoJson(r#"{"type": "MultiPoint", "coordinates": [[1, 1], [2, 2]]}"#);
let wkt = "MULTIPOINT (1.0000000000000000 1.0000000000000000, 2.0000000000000000 2.0000000000000000)";
let wkt = "MULTIPOINT ((1 1), (2 2))";
let geos = geojson.to_geos().unwrap();
assert_eq!(geos.to_wkt().unwrap(), wkt);
}

#[test]
fn line_geom() {
let geojson = GeoJson(r#"{"type": "LineString", "coordinates": [[1,1], [2,2]]}"#);
let wkt = "LINESTRING (1.0000000000000000 1.0000000000000000, 2.0000000000000000 2.0000000000000000)";
let wkt = "LINESTRING (1 1, 2 2)";
let geos = geojson.to_geos().unwrap();
assert_eq!(geos.to_wkt().unwrap(), wkt);
}
Expand All @@ -217,7 +217,7 @@ mod test {
fn multiline_geom() {
let geojson =
GeoJson(r#"{"type": "MultiLineString", "coordinates": [[[1,1],[2,2]],[[3,3],[4,4]]]}"#);
let wkt = "MULTILINESTRING ((1.0000000000000000 1.0000000000000000, 2.0000000000000000 2.0000000000000000), (3.0000000000000000 3.0000000000000000, 4.0000000000000000 4.0000000000000000))";
let wkt = "MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))";
let geos = geojson.to_geos().unwrap();
assert_eq!(geos.to_wkt().unwrap(), wkt);
}
Expand All @@ -233,7 +233,7 @@ mod test {
]]
}"#;
let geojson = GeoJson(geojson);
let wkt = "POLYGON ((0.0000000000000000 0.0000000000000000, 0.0000000000000000 3.0000000000000000, 3.0000000000000000 3.0000000000000000, 3.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000), (0.2000000000000000 0.2000000000000000, 0.2000000000000000 2.0000000000000000, 2.0000000000000000 2.0000000000000000, 2.0000000000000000 0.2000000000000000, 0.2000000000000000 0.2000000000000000))";
let wkt = "POLYGON ((0 0, 0 3, 3 3, 3 0, 0 0), (0.2 0.2, 0.2 2, 2 2, 2 0.2, 0.2 0.2))";
let geos = geojson.to_geos().unwrap();
assert_eq!(geos.to_wkt().unwrap(), wkt);
}
Expand All @@ -247,7 +247,7 @@ mod test {
]]]
}"#;
let geojson = GeoJson(geojson);
let wkt = "MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000 1.0000000000000000, 1.0000000000000000 1.0000000000000000, 1.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000)))";
let wkt = "MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)))";
let geos = geojson.to_geos().unwrap();
assert_eq!(geos.to_wkt().unwrap(), wkt);
}
Expand All @@ -267,10 +267,7 @@ mod test {
let geo =
geo_types::Geometry::try_from(wkt::Wkt::from_str("POINT (10 20)").unwrap()).unwrap();
let geos = geo.to_geos()?;
assert_eq!(
&geos.to_wkt().unwrap(),
"POINT (10.0000000000000000 20.0000000000000000)"
);
assert_eq!(&geos.to_wkt().unwrap(), "POINT (10 20)");
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion geozero/src/gpx/gpx_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io;
/// GPX geometry collection
pub struct Gpx<'a>(pub &'a str);

impl<'a> crate::GeozeroGeometry for Gpx<'a> {
impl crate::GeozeroGeometry for Gpx<'_> {
fn process_geom<P: crate::GeomProcessor>(&self, processor: &mut P) -> crate::error::Result<()> {
read_gpx(&mut self.0.as_bytes(), processor)
}
Expand Down
2 changes: 1 addition & 1 deletion geozero/src/shp/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub enum ShapeType {
impl ShapeType {
pub(crate) fn read_from<T: Read>(source: &mut T) -> Result<ShapeType, Error> {
let code = source.read_i32::<LittleEndian>()?;
Self::from(code).ok_or_else(|| Error::InvalidShapeType(code))
Self::from(code).ok_or(Error::InvalidShapeType(code))
}

/// Returns the ShapeType corresponding to the input code
Expand Down
6 changes: 3 additions & 3 deletions geozero/src/tessellator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> Tessellator<'a> {
}
}

impl<'a> GeomProcessor for Tessellator<'a> {
impl GeomProcessor for Tessellator<'_> {
fn xy(&mut self, x: f64, y: f64, idx: usize) -> Result<()> {
if idx == 0 {
self.has_started = true;
Expand Down Expand Up @@ -124,8 +124,8 @@ fn tessellate_poly(path: &Path, out: &dyn VertexOutput) {
}
}

impl<'a> PropertyProcessor for Tessellator<'a> {}
impl<'a> FeatureProcessor for Tessellator<'a> {}
impl PropertyProcessor for Tessellator<'_> {}
impl FeatureProcessor for Tessellator<'_> {}

/// OBJ writer
pub struct ObjWriter;
Expand Down
5 changes: 1 addition & 4 deletions geozero/tests/geopackage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ async fn geos_query() -> Result<(), sqlx::Error> {
.fetch_one(&pool)
.await?;
let geom = row.0.geometry.unwrap();
assert_eq!(
geom.to_wkt().unwrap(),
"POINT (1.1000000000000001 1.1000000000000001)"
);
assert_eq!(geom.to_wkt().unwrap(), "POINT (1.1 1.1)");

let row: (wkb::Decode<geos::Geometry>,) =
sqlx::query_as("SELECT geom FROM pt2d WHERE geom IS NULL")
Expand Down
2 changes: 1 addition & 1 deletion geozero/tests/postgis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ mod postgis_sqlx {
}
}

impl<'de> Decode<'de, Postgres> for Text {
impl Decode<'_, Postgres> for Text {
fn decode(value: PgValueRef) -> Result<Self, BoxDynError> {
if value.is_null() {
return Ok(Text("EMPTY".to_string()));
Expand Down

0 comments on commit 7716094

Please sign in to comment.