diff --git a/postgres-shared/Cargo.toml b/postgres-shared/Cargo.toml index 31014e663..853a9f46e 100644 --- a/postgres-shared/Cargo.toml +++ b/postgres-shared/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/sfackler/rust-postgres" "with-bit-vec-0.5" = ["bit-vec"] "with-chrono-0.4" = ["chrono"] "with-eui48-0.3" = ["eui48"] -"with-geo-0.8" = ["geo"] +"with-geo-0.10" = ["geo"] with-serde_json-1 = ["serde_json"] "with-uuid-0.6" = ["uuid"] @@ -23,6 +23,6 @@ postgres-protocol = { version = "0.3", path = "../postgres-protocol" } bit-vec = { version = "0.5", optional = true } chrono = { version = "0.4", optional = true } eui48 = { version = "0.3", optional = true } -geo = { version = "0.8", optional = true } +geo = { version = "0.10", optional = true } serde_json = { version = "1.0", optional = true } uuid = { version = "0.6", optional = true } diff --git a/postgres-shared/src/types/geo.rs b/postgres-shared/src/types/geo.rs index d2cee6949..c09b0c566 100644 --- a/postgres-shared/src/types/geo.rs +++ b/postgres-shared/src/types/geo.rs @@ -1,6 +1,6 @@ extern crate geo; -use self::geo::{Bbox, LineString, Point}; +use self::geo::{Coordinate, LineString, Point, Rect}; use fallible_iterator::FallibleIterator; use postgres_protocol::types; use std::error::Error; @@ -26,23 +26,21 @@ impl ToSql for Point { to_sql_checked!(); } -impl<'a> FromSql<'a> for Bbox { +impl<'a> FromSql<'a> for Rect { fn from_sql(_: &Type, raw: &[u8]) -> Result> { - let bbox = types::box_from_sql(raw)?; - Ok(Bbox { - xmin: bbox.lower_left().x(), - xmax: bbox.upper_right().x(), - ymin: bbox.lower_left().y(), - ymax: bbox.upper_right().y(), + let rect = types::box_from_sql(raw)?; + Ok(Rect { + min: Coordinate { x: rect.lower_left().x(), y: rect.lower_left().y(), }, + max: Coordinate { x: rect.upper_right().x(), y: rect.upper_right().y(), }, }) } accepts!(BOX); } -impl ToSql for Bbox { +impl ToSql for Rect { fn to_sql(&self, _: &Type, out: &mut Vec) -> Result> { - types::box_to_sql(self.xmin, self.ymin, self.xmax, self.ymax, out); + types::box_to_sql(self.min.x, self.min.y, self.max.x, self.max.y, out); Ok(IsNull::No) } @@ -53,7 +51,7 @@ impl ToSql for Bbox { impl<'a> FromSql<'a> for LineString { fn from_sql(_: &Type, raw: &[u8]) -> Result> { let path = types::path_from_sql(raw)?; - let points = path.points().map(|p| Point::new(p.x(), p.y())).collect()?; + let points = path.points().map(|p| Coordinate { x: p.x(), y: p.y() }).collect()?; Ok(LineString(points)) } @@ -63,7 +61,7 @@ impl<'a> FromSql<'a> for LineString { impl ToSql for LineString { fn to_sql(&self, _: &Type, out: &mut Vec) -> Result> { let closed = false; // always encode an open path from LineString - types::path_to_sql(closed, self.0.iter().map(|p| (p.x(), p.y())), out)?; + types::path_to_sql(closed, self.0.iter().map(|p| (p.x, p.y)), out)?; Ok(IsNull::No) } diff --git a/postgres-shared/src/types/mod.rs b/postgres-shared/src/types/mod.rs index cc23162b3..457248164 100644 --- a/postgres-shared/src/types/mod.rs +++ b/postgres-shared/src/types/mod.rs @@ -77,7 +77,7 @@ mod bit_vec; mod chrono; #[cfg(feature = "with-eui48-0.3")] mod eui48; -#[cfg(feature = "with-geo-0.8")] +#[cfg(feature = "with-geo-0.10")] mod geo; #[cfg(feature = "with-serde_json-1")] mod serde_json; diff --git a/postgres/Cargo.toml b/postgres/Cargo.toml index 0a6a31b56..2a21d33a1 100644 --- a/postgres/Cargo.toml +++ b/postgres/Cargo.toml @@ -15,7 +15,7 @@ features = [ "with-bit-vec-0.5", "with-chrono-0.4", "with-eui48-0.3", - "with-geo-0.8", + "with-geo-0.10", "with-serde_json-1", "with-uuid-0.6", "with-openssl", @@ -39,7 +39,7 @@ path = "tests/test.rs" "with-bit-vec-0.5" = ["postgres-shared/with-bit-vec-0.5"] "with-chrono-0.4" = ["postgres-shared/with-chrono-0.4"] "with-eui48-0.3" = ["postgres-shared/with-eui48-0.3"] -"with-geo-0.8" = ["postgres-shared/with-geo-0.8"] +"with-geo-0.10" = ["postgres-shared/with-geo-0.10"] "with-serde_json-1" = ["postgres-shared/with-serde_json-1"] "with-uuid-0.6" = ["postgres-shared/with-uuid-0.6"] @@ -61,6 +61,6 @@ url = "1.0" bit-vec = "0.5" chrono = "0.4" eui48 = "0.3" -geo = "0.8" +geo = "0.10" serde_json = "1.0" uuid = "0.6" diff --git a/postgres/tests/types/geo.rs b/postgres/tests/types/geo.rs index 92571fec0..bcde561fc 100644 --- a/postgres/tests/types/geo.rs +++ b/postgres/tests/types/geo.rs @@ -1,6 +1,6 @@ extern crate geo; -use self::geo::{Bbox, LineString, Point}; +use self::geo::{Coordinate, LineString, Point, Rect}; use types::test_type; #[test] @@ -21,11 +21,9 @@ fn test_box_params() { "BOX", &[ ( - Some(Bbox { - xmax: 160.0, - ymax: 69701.5615, - xmin: -3.14, - ymin: 1.618, + Some(Rect { + min: Coordinate { x: -3.14, y: 1.618, }, + max: Coordinate { x: 160.0, y: 69701.5615, }, }), "BOX(POINT(160.0, 69701.5615), POINT(-3.14, 1.618))", ), diff --git a/postgres/tests/types/mod.rs b/postgres/tests/types/mod.rs index e376f8823..e95945b36 100644 --- a/postgres/tests/types/mod.rs +++ b/postgres/tests/types/mod.rs @@ -15,7 +15,7 @@ mod bit_vec; mod chrono; #[cfg(feature = "with-eui48-0.3")] mod eui48; -#[cfg(feature = "with-geo-0.8")] +#[cfg(feature = "with-geo-0.10")] mod geo; #[cfg(feature = "with-serde_json-1")] mod serde_json; diff --git a/tokio-postgres/Cargo.toml b/tokio-postgres/Cargo.toml index fd3e68645..14fb12cde 100644 --- a/tokio-postgres/Cargo.toml +++ b/tokio-postgres/Cargo.toml @@ -14,7 +14,7 @@ features = [ "with-bit-vec-0.5", "with-chrono-0.4", "with-eui48-0.3", - "with-geo-0.8", + "with-geo-0.10", "with-serde_json-1", "with-uuid-0.6", "with-openssl", @@ -27,7 +27,7 @@ circle-ci = { repository = "sfackler/rust-postgres" } "with-bit-vec-0.5" = ["postgres-shared/with-bit-vec-0.5"] "with-chrono-0.4" = ["postgres-shared/with-chrono-0.4"] "with-eui48-0.3" = ["postgres-shared/with-eui48-0.3"] -"with-geo-0.8" = ["postgres-shared/with-geo-0.8"] +"with-geo-0.10" = ["postgres-shared/with-geo-0.10"] "with-serde_json-1" = ["postgres-shared/with-serde_json-1"] "with-uuid-0.6" = ["postgres-shared/with-uuid-0.6"]