diff --git a/.travis.yml b/.travis.yml index e183cbe1..6e3f5b85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: rust -rust: - - nightly - - beta - - stable -after_success: | - cargo doc && \ - echo '' > target/doc/index.html && \ - sudo pip install ghp-import && \ - ghp-import -n target/doc && \ - git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages + +cache: cargo + +matrix: + include: + - env: FEATURES="" + - env: FEATURES="--features geo-types" + +script: + - cargo build --release $FEATURES && cargo test --release $FEATURES diff --git a/Cargo.toml b/Cargo.toml index c6ab2067..27d2b0f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" [dependencies] serde = "~1.0" serde_json = "~1.0" -geo-types = "0.4" +geo-types = { version = "0.4", optional = true } num-traits = "0.2" [dev-dependencies] @@ -24,3 +24,6 @@ criterion = "0.2" [[bench]] name = "parse" harness = false + +[package.metadata.docs.rs] +features = [ "geo-types" ] \ No newline at end of file diff --git a/README.md b/README.md index 87592ed0..cf089e77 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ geojson ======= -[![Build Status](https://travis-ci.org/georust/geojson.svg)](https://travis-ci.org/georust/geojson) -[![geojson on Crates.io](https://meritbadge.herokuapp.com/geojson)](https://crates.io/crates/geojson) - [Documentation](https://docs.rs/geojson/) Library for serializing the [GeoJSON](http://geojson.org) vector GIS file format diff --git a/src/geometry.rs b/src/geometry.rs index 2add35d6..fc9d373a 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -24,14 +24,17 @@ use crate::{util, Bbox, Error, LineStringType, PointType, PolygonType}; /// types: /// /// ```rust -/// extern crate geo_types; -/// extern crate geojson; -/// +/// # #[cfg(feature = "geo-types")] +/// # fn test() { /// let point = geo_types::Point::new(2., 9.); /// assert_eq!( /// geojson::Value::from(&point), /// geojson::Value::Point(vec![2., 9.]), /// ); +/// # } +/// # #[cfg(not(feature = "geo-types"))] +/// # fn test() {} +/// # test() /// ``` #[derive(Clone, Debug, PartialEq)] pub enum Value { @@ -258,12 +261,10 @@ mod tests { use crate::json::JsonObject; use crate::{GeoJson, Geometry, Value}; - use geo_types::LineString; fn encode(geometry: &Geometry) -> String { serde_json::to_string(&geometry).unwrap() } - fn decode(json_string: String) -> GeoJson { json_string.parse().unwrap() } @@ -291,8 +292,7 @@ mod tests { #[test] fn test_geometry_display() { - let route: LineString<_> = vec![(0.0, 0.1), (0.1, 0.2), (0.2, 0.3)].into(); - let v = Value::from(&route); + let v = Value::LineString(vec![vec![0.0, 0.1], vec![0.1, 0.2], vec![0.2, 0.3]]); let geometry = Geometry::new(v); assert_eq!( "{\"coordinates\":[[0.0,0.1],[0.1,0.2],[0.2,0.3]],\"type\":\"LineString\"}", diff --git a/src/lib.rs b/src/lib.rs index 24e39b8c..2f92103b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,7 +184,10 @@ //! //! The [`geojson_example`](https://github.com/urschrei/geojson_example) and [`polylabel_cmd`](https://github.com/urschrei/polylabel_cmd/blob/master/src/main.rs) crates contain example //! implementations which may be useful if you wish to perform these conversions. +//! +//! To use the conversion functionality, ensure the `geo-types` feature is enabled. +#[cfg(feature = "geo-types")] use geo_types; use serde; use serde_json; @@ -216,8 +219,8 @@ pub mod feature; mod feature_collection; pub use crate::feature_collection::FeatureCollection; -/// Convert Geometries into [Geo](https://docs.rs/geo) types -pub mod conversion; +#[cfg(feature = "geo-types")] +mod conversion; /// Feature Objects ///