Skip to content

Commit a33edae

Browse files
committed
Upgrade to geo-0.10
1 parent 5ad7850 commit a33edae

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

postgres-shared/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/sfackler/rust-postgres"
1010
"with-bit-vec-0.5" = ["bit-vec"]
1111
"with-chrono-0.4" = ["chrono"]
1212
"with-eui48-0.3" = ["eui48"]
13-
"with-geo-0.8" = ["geo"]
13+
"with-geo-0.10" = ["geo"]
1414
with-serde_json-1 = ["serde_json"]
1515
"with-uuid-0.6" = ["uuid"]
1616

@@ -23,6 +23,6 @@ postgres-protocol = { version = "0.3", path = "../postgres-protocol" }
2323
bit-vec = { version = "0.5", optional = true }
2424
chrono = { version = "0.4", optional = true }
2525
eui48 = { version = "0.3", optional = true }
26-
geo = { version = "0.8", optional = true }
26+
geo = { version = "0.10", optional = true }
2727
serde_json = { version = "1.0", optional = true }
2828
uuid = { version = "0.6", optional = true }

postgres-shared/src/types/geo.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate geo;
22

3-
use self::geo::{Bbox, LineString, Point};
3+
use self::geo::{Coordinate, LineString, Point, Rect};
44
use fallible_iterator::FallibleIterator;
55
use postgres_protocol::types;
66
use std::error::Error;
@@ -26,23 +26,21 @@ impl ToSql for Point<f64> {
2626
to_sql_checked!();
2727
}
2828

29-
impl<'a> FromSql<'a> for Bbox<f64> {
29+
impl<'a> FromSql<'a> for Rect<f64> {
3030
fn from_sql(_: &Type, raw: &[u8]) -> Result<Self, Box<Error + Sync + Send>> {
31-
let bbox = types::box_from_sql(raw)?;
32-
Ok(Bbox {
33-
xmin: bbox.lower_left().x(),
34-
xmax: bbox.upper_right().x(),
35-
ymin: bbox.lower_left().y(),
36-
ymax: bbox.upper_right().y(),
31+
let rect = types::box_from_sql(raw)?;
32+
Ok(Rect {
33+
min: Coordinate { x: rect.lower_left().x(), y: rect.lower_left().y(), },
34+
max: Coordinate { x: rect.upper_right().x(), y: rect.upper_right().y(), },
3735
})
3836
}
3937

4038
accepts!(BOX);
4139
}
4240

43-
impl ToSql for Bbox<f64> {
41+
impl ToSql for Rect<f64> {
4442
fn to_sql(&self, _: &Type, out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
45-
types::box_to_sql(self.xmin, self.ymin, self.xmax, self.ymax, out);
43+
types::box_to_sql(self.min.x, self.min.y, self.max.x, self.max.y, out);
4644
Ok(IsNull::No)
4745
}
4846

@@ -53,7 +51,7 @@ impl ToSql for Bbox<f64> {
5351
impl<'a> FromSql<'a> for LineString<f64> {
5452
fn from_sql(_: &Type, raw: &[u8]) -> Result<Self, Box<Error + Sync + Send>> {
5553
let path = types::path_from_sql(raw)?;
56-
let points = path.points().map(|p| Point::new(p.x(), p.y())).collect()?;
54+
let points = path.points().map(|p| Coordinate { x: p.x(), y: p.y() }).collect()?;
5755
Ok(LineString(points))
5856
}
5957

@@ -63,7 +61,7 @@ impl<'a> FromSql<'a> for LineString<f64> {
6361
impl ToSql for LineString<f64> {
6462
fn to_sql(&self, _: &Type, out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {
6563
let closed = false; // always encode an open path from LineString
66-
types::path_to_sql(closed, self.0.iter().map(|p| (p.x(), p.y())), out)?;
64+
types::path_to_sql(closed, self.0.iter().map(|p| (p.x, p.y)), out)?;
6765
Ok(IsNull::No)
6866
}
6967

postgres-shared/src/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mod bit_vec;
7777
mod chrono;
7878
#[cfg(feature = "with-eui48-0.3")]
7979
mod eui48;
80-
#[cfg(feature = "with-geo-0.8")]
80+
#[cfg(feature = "with-geo-0.10")]
8181
mod geo;
8282
#[cfg(feature = "with-serde_json-1")]
8383
mod serde_json;

postgres/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ features = [
1515
"with-bit-vec-0.5",
1616
"with-chrono-0.4",
1717
"with-eui48-0.3",
18-
"with-geo-0.8",
18+
"with-geo-0.10",
1919
"with-serde_json-1",
2020
"with-uuid-0.6",
2121
"with-openssl",
@@ -39,7 +39,7 @@ path = "tests/test.rs"
3939
"with-bit-vec-0.5" = ["postgres-shared/with-bit-vec-0.5"]
4040
"with-chrono-0.4" = ["postgres-shared/with-chrono-0.4"]
4141
"with-eui48-0.3" = ["postgres-shared/with-eui48-0.3"]
42-
"with-geo-0.8" = ["postgres-shared/with-geo-0.8"]
42+
"with-geo-0.10" = ["postgres-shared/with-geo-0.10"]
4343
"with-serde_json-1" = ["postgres-shared/with-serde_json-1"]
4444
"with-uuid-0.6" = ["postgres-shared/with-uuid-0.6"]
4545

@@ -61,6 +61,6 @@ url = "1.0"
6161
bit-vec = "0.5"
6262
chrono = "0.4"
6363
eui48 = "0.3"
64-
geo = "0.8"
64+
geo = "0.10"
6565
serde_json = "1.0"
6666
uuid = "0.6"

postgres/tests/types/geo.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern crate geo;
22

3-
use self::geo::{Bbox, LineString, Point};
3+
use self::geo::{Coordinate, LineString, Point, Rect};
44
use types::test_type;
55

66
#[test]
@@ -21,11 +21,9 @@ fn test_box_params() {
2121
"BOX",
2222
&[
2323
(
24-
Some(Bbox {
25-
xmax: 160.0,
26-
ymax: 69701.5615,
27-
xmin: -3.14,
28-
ymin: 1.618,
24+
Some(Rect {
25+
min: Coordinate { x: -3.14, y: 1.618, },
26+
max: Coordinate { x: 160.0, y: 69701.5615, },
2927
}),
3028
"BOX(POINT(160.0, 69701.5615), POINT(-3.14, 1.618))",
3129
),

postgres/tests/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod bit_vec;
1515
mod chrono;
1616
#[cfg(feature = "with-eui48-0.3")]
1717
mod eui48;
18-
#[cfg(feature = "with-geo-0.8")]
18+
#[cfg(feature = "with-geo-0.10")]
1919
mod geo;
2020
#[cfg(feature = "with-serde_json-1")]
2121
mod serde_json;

tokio-postgres/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ features = [
1414
"with-bit-vec-0.5",
1515
"with-chrono-0.4",
1616
"with-eui48-0.3",
17-
"with-geo-0.8",
17+
"with-geo-0.10",
1818
"with-serde_json-1",
1919
"with-uuid-0.6",
2020
"with-openssl",
@@ -27,7 +27,7 @@ circle-ci = { repository = "sfackler/rust-postgres" }
2727
"with-bit-vec-0.5" = ["postgres-shared/with-bit-vec-0.5"]
2828
"with-chrono-0.4" = ["postgres-shared/with-chrono-0.4"]
2929
"with-eui48-0.3" = ["postgres-shared/with-eui48-0.3"]
30-
"with-geo-0.8" = ["postgres-shared/with-geo-0.8"]
30+
"with-geo-0.10" = ["postgres-shared/with-geo-0.10"]
3131
"with-serde_json-1" = ["postgres-shared/with-serde_json-1"]
3232
"with-uuid-0.6" = ["postgres-shared/with-uuid-0.6"]
3333

0 commit comments

Comments
 (0)