Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make serde optional for 'geo'. #209

Merged
merged 1 commit into from
May 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ travis-ci = { repository = "georust/rust-geo" }

[dependencies]
num-traits = "0.2"
serde = "1.0"
serde_derive = "1.0"
serde = { version = "1.0", optional = true, features = ["derive"] }
spade = "1.3.0"
failure = "0.1.1"
postgis = { version = "0.5", optional = true }
proj-sys = { version = "0.6.1", optional = true }
libc = { version = "0.2.39", optional = true }
geo-types = { version = "0.1.0", features = ["serde", "spade"] }
geo-types = { version = "0.1.0", features = ["spade"] }

[features]
default = []
postgis-integration = ["postgis"]
proj = ["proj-sys", "libc"]
use-serde = ["serde", "geo-types/serde"]

[dev-dependencies]
approx = "0.1.1"
Expand Down
3 changes: 2 additions & 1 deletion geo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
extern crate geo_types;
extern crate num_traits;
#[cfg(feature = "use-serde")]
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate spade;
#[cfg(feature = "postgis-integration")]
extern crate postgis;
Expand Down
12 changes: 8 additions & 4 deletions geo/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use ::{CoordinateType, Point};
pub static COORD_PRECISION: f32 = 1e-1; // 0.1m

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

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

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

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