Skip to content

Commit 7ef9361

Browse files
committed
Make serde optional for 'geo'.
Fixes #207.
1 parent f629f1b commit 7ef9361

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

geo/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ travis-ci = { repository = "georust/rust-geo" }
1414

1515
[dependencies]
1616
num-traits = "0.2"
17-
serde = "1.0"
18-
serde_derive = "1.0"
17+
serde = { version = "1.0", optional = true, features = ["derive"] }
1918
spade = "1.3.0"
2019
failure = "0.1.1"
2120
postgis = { version = "0.5", optional = true }
2221
proj-sys = { version = "0.6.1", optional = true }
2322
libc = { version = "0.2.39", optional = true }
24-
geo-types = { version = "0.1.0", features = ["serde", "spade"] }
23+
geo-types = { version = "0.1.0", features = ["spade"] }
2524

2625
[features]
2726
default = []
2827
postgis-integration = ["postgis"]
2928
proj = ["proj-sys", "libc"]
29+
use-serde = ["serde", "geo-types/serde"]
3030

3131
[dev-dependencies]
3232
approx = "0.1.1"

geo/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
extern crate geo_types;
22
extern crate num_traits;
3+
#[cfg(feature = "use-serde")]
34
#[macro_use]
4-
extern crate serde_derive;
5+
extern crate serde;
56
extern crate spade;
67
#[cfg(feature = "postgis-integration")]
78
extern crate postgis;

geo/src/types.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use ::{CoordinateType, Point};
77
pub static COORD_PRECISION: f32 = 1e-1; // 0.1m
88

99
/// A container for the bounding box of a [`Geometry`](enum.Geometry.html)
10-
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
10+
#[cfg_attr(feature = "use-serde", derive(Serialize, Deserialize))]
11+
#[derive(PartialEq, Clone, Copy, Debug)]
1112
pub struct Bbox<T>
1213
where
1314
T: CoordinateType,
@@ -19,7 +20,8 @@ where
1920
}
2021

2122
/// A container for indices of the minimum and maximum points of a [`Geometry`](enum.Geometry.html)
22-
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
23+
#[cfg_attr(feature = "use-serde", derive(Serialize, Deserialize))]
24+
#[derive(PartialEq, Clone, Copy, Debug)]
2325
pub struct Extremes {
2426
pub ymin: usize,
2527
pub xmax: usize,
@@ -39,7 +41,8 @@ impl From<Vec<usize>> for Extremes {
3941
}
4042

4143
/// A container for the coordinates of the minimum and maximum points of a [`Geometry`](enum.Geometry.html)
42-
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
44+
#[cfg_attr(feature = "use-serde", derive(Serialize, Deserialize))]
45+
#[derive(PartialEq, Clone, Copy, Debug)]
4346
pub struct ExtremePoint<T>
4447
where
4548
T: CoordinateType,
@@ -139,7 +142,8 @@ where
139142
}
140143

141144
/// The result of trying to find the closest spot on an object to a point.
142-
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
145+
#[cfg_attr(feature = "use-serde", derive(Serialize, Deserialize))]
146+
#[derive(Debug, Clone, Copy, PartialEq)]
143147
pub enum Closest<F: Float> {
144148
/// The point actually intersects with the object.
145149
Intersection(Point<F>),

0 commit comments

Comments
 (0)