Skip to content

Commit

Permalink
Make the geo-types conversion functionality opt-in. (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv authored May 5, 2019
1 parent 5579fe4 commit c76d9be
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: rust
rust:
- nightly
- beta
- stable
after_success: |
cargo doc && \
echo '<meta http-equiv=refresh content=0;url=geojson/index.html>' > 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
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -24,3 +24,6 @@ criterion = "0.2"
[[bench]]
name = "parse"
harness = false

[package.metadata.docs.rs]
features = [ "geo-types" ]
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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\"}",
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
///
Expand Down

0 comments on commit c76d9be

Please sign in to comment.