Skip to content

Commit

Permalink
Merge georust#345
Browse files Browse the repository at this point in the history
345: Migrate to Rust 2018 Edition. r=frewsxcv a=frewsxcv



Co-authored-by: Corey Farwell <coreyf@rwell.org>
  • Loading branch information
bors[bot] and frewsxcv committed Feb 17, 2019
2 parents 0c4ecf8 + ef85605 commit b8a9514
Show file tree
Hide file tree
Showing 46 changed files with 146 additions and 144 deletions.
1 change: 1 addition & 0 deletions geo-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ documentation = "https://docs.rs/geo-types/"
readme = "../README.md"
keywords = ["gis", "geo", "geography", "geospatial"]
description = "Geospatial primitive data types"
edition = "2018"

[dependencies]
num-traits = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/coordinate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {CoordinateType, Point};
use crate::{CoordinateType, Point};

/// A lightweight struct used to store coordinates on the 2-dimensional
/// Cartesian plane.
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {
use crate::{
CoordinateType, GeometryCollection, Line, LineString, MultiLineString, MultiPoint,
MultiPolygon, Point, Polygon,
};
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/geometry_collection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::iter::FromIterator;
use {CoordinateType, Geometry};
use crate::{CoordinateType, Geometry};

/// A collection of [`Geometry`](enum.Geometry.html) types.
///
Expand Down
24 changes: 12 additions & 12 deletions geo-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,40 @@ pub trait CoordinateType: Num + Copy + NumCast + PartialOrd {}
impl<T: Num + Copy + NumCast + PartialOrd> CoordinateType for T {}

mod coordinate;
pub use coordinate::Coordinate;
pub use crate::coordinate::Coordinate;

mod point;
pub use point::Point;
pub use crate::point::Point;

mod multi_point;
pub use multi_point::MultiPoint;
pub use crate::multi_point::MultiPoint;

mod line;
pub use line::Line;
pub use crate::line::Line;

pub mod line_string;
pub use line_string::LineString;
pub use crate::line_string::LineString;

mod multi_line_string;
pub use multi_line_string::MultiLineString;
pub use crate::multi_line_string::MultiLineString;

mod polygon;
pub use polygon::Polygon;
pub use crate::polygon::Polygon;

mod multi_polygon;
pub use multi_polygon::MultiPolygon;
pub use crate::multi_polygon::MultiPolygon;

mod geometry;
pub use geometry::Geometry;
pub use crate::geometry::Geometry;

mod geometry_collection;
pub use geometry_collection::GeometryCollection;
pub use crate::geometry_collection::GeometryCollection;

mod triangle;
pub use triangle::Triangle;
pub use crate::triangle::Triangle;

mod rect;
pub use rect::Rect;
pub use crate::rect::Rect;

#[doc(hidden)]
pub mod private_utils;
Expand Down
6 changes: 3 additions & 3 deletions geo-types/src/line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {Coordinate, CoordinateType, Point};
use crate::{Coordinate, CoordinateType, Point};

/// A line segment made up of exactly two [`Point`s](struct.Point.html).
#[derive(PartialEq, Clone, Copy, Debug)]
Expand Down Expand Up @@ -168,7 +168,7 @@ where
type Envelope = ::rstar::AABB<Point<T>>;

fn envelope(&self) -> Self::Envelope {
let bounding_rect = ::private_utils::line_bounding_rect(*self);
let bounding_rect = crate::private_utils::line_bounding_rect(*self);
::rstar::AABB::from_corners(bounding_rect.min.into(), bounding_rect.max.into())
}
}
Expand All @@ -179,7 +179,7 @@ where
T: ::num_traits::Float + ::rstar::RTreeNum,
{
fn distance_2(&self, point: &Point<T>) -> T {
let d = ::private_utils::point_line_euclidean_distance(*point, *self);
let d = crate::private_utils::point_line_euclidean_distance(*point, *self);
d.powi(2)
}
}
6 changes: 3 additions & 3 deletions geo-types/src/line_string.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::iter::FromIterator;
use std::ops::{Index, IndexMut};
use {Coordinate, CoordinateType, Line, Point, Triangle};
use crate::{Coordinate, CoordinateType, Line, Point, Triangle};

/// An ordered collection of two or more [`Coordinate`s](struct.Coordinate.html), representing a
/// path between locations.
Expand Down Expand Up @@ -199,7 +199,7 @@ where

fn envelope(&self) -> Self::Envelope {
use num_traits::Bounded;
let bounding_rect = ::private_utils::line_string_bounding_rect(self);
let bounding_rect = crate::private_utils::line_string_bounding_rect(self);
match bounding_rect {
None => ::rstar::AABB::from_corners(
Point::new(Bounded::min_value(), Bounded::min_value()),
Expand All @@ -219,7 +219,7 @@ where
T: ::num_traits::Float + ::rstar::RTreeNum,
{
fn distance_2(&self, point: &Point<T>) -> T {
let d = ::private_utils::point_line_string_euclidean_distance(*point, self);
let d = crate::private_utils::point_line_string_euclidean_distance(*point, self);
if d == T::zero() {
d
} else {
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/multi_line_string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::iter::FromIterator;
use {CoordinateType, LineString};
use crate::{CoordinateType, LineString};

/// A collection of [`LineString`s](struct.LineString.html).
///
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/multi_point.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::iter::FromIterator;
use {CoordinateType, Point};
use crate::{CoordinateType, Point};

/// A collection of [`Point`s](struct.Point.html).
///
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/multi_polygon.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::iter::FromIterator;
use {CoordinateType, Polygon};
use crate::{CoordinateType, Polygon};

/// A collection of [`Polygon`s](struct.Polygon.html).
///
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use num_traits::Float;
use std::ops::Add;
use std::ops::Neg;
use std::ops::Sub;
use {Coordinate, CoordinateType};
use crate::{Coordinate, CoordinateType};

/// A single point in 2D space.
///
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/polygon.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use num_traits::{Float, Signed};
use {CoordinateType, LineString, Point, Rect};
use crate::{CoordinateType, LineString, Point, Rect};

/// A bounded two-dimensional area.
///
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/private_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// prevent duplication. These functions are _not_ meant for public consumption.

use num_traits::Float;
use {Coordinate, CoordinateType, Line, LineString, Point, Rect};
use crate::{Coordinate, CoordinateType, Line, LineString, Point, Rect};

pub static COORD_PRECISION: f32 = 1e-1; // 0.1m

Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/rect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {Coordinate, CoordinateType};
use crate::{Coordinate, CoordinateType};

/// A bounded 2D quadrilateral whose area is defined by minimum and maximum `Coordinates`.
#[derive(PartialEq, Clone, Copy, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/triangle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {Coordinate, CoordinateType, Line};
use crate::{Coordinate, CoordinateType, Line};

/// A bounded 2D area whose three vertices are defined by `Coordinate`s.
#[derive(Copy, Clone, Debug)]
Expand Down
1 change: 1 addition & 0 deletions geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ documentation = "https://docs.rs/geo/"
readme = "../README.md"
keywords = ["gis", "geo", "geography", "geospatial"]
autobenches = true
edition = "2018"

[badges]
travis-ci = { repository = "georust/geo" }
Expand Down
8 changes: 4 additions & 4 deletions geo/src/algorithm/area.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use num_traits::Float;
use {CoordinateType, Line, LineString, MultiPolygon, Polygon, Rect, Triangle};
use crate::{CoordinateType, Line, LineString, MultiPolygon, Polygon, Rect, Triangle};

use algorithm::winding_order::twice_signed_ring_area;
use crate::algorithm::winding_order::twice_signed_ring_area;

/// Calculation of the area.
Expand Down Expand Up @@ -100,8 +100,8 @@ where

#[cfg(test)]
mod test {
use algorithm::area::Area;
use {Coordinate, Line, LineString, MultiPolygon, Polygon, Rect, Triangle};
use crate::algorithm::area::Area;
use crate::{Coordinate, Line, LineString, MultiPolygon, Polygon, Rect, Triangle};

// Area of the polygon
#[test]
Expand Down
6 changes: 3 additions & 3 deletions geo/src/algorithm/bearing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use num_traits::Float;
use Point;
use crate::Point;

/// Returns the bearing to another Point in degrees.
///
Expand Down Expand Up @@ -46,8 +46,8 @@ where
#[cfg(test)]
mod test {
use super::*;
use algorithm::bearing::Bearing;
use algorithm::haversine_destination::HaversineDestination;
use crate::algorithm::bearing::Bearing;
use crate::algorithm::haversine_destination::HaversineDestination;

#[test]
fn returns_the_proper_bearing_to_another_point() {
Expand Down
6 changes: 3 additions & 3 deletions geo/src/algorithm/bounding_rect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use geo_types::private_utils::{get_bounding_rect, line_string_bounding_rect};
use {
use crate::{
Coordinate, CoordinateType, Line, LineString, MultiLineString, MultiPoint, MultiPolygon,
Polygon, Rect, Triangle,
};
Expand Down Expand Up @@ -138,8 +138,8 @@ where

#[cfg(test)]
mod test {
use algorithm::bounding_rect::BoundingRect;
use {Coordinate, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Polygon, Rect};
use crate::algorithm::bounding_rect::BoundingRect;
use crate::{Coordinate, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Polygon, Rect};

#[test]
fn empty_linestring_test() {
Expand Down
12 changes: 6 additions & 6 deletions geo/src/algorithm/centroid.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use num_traits::{Float, FromPrimitive};
use std::iter::Sum;

use algorithm::area::{get_linestring_area, Area};
use algorithm::euclidean_length::EuclideanLength;
use {Line, LineString, MultiPoint, MultiPolygon, Point, Polygon, Rect};
use crate::algorithm::area::{get_linestring_area, Area};
use crate::algorithm::euclidean_length::EuclideanLength;
use crate::{Line, LineString, MultiPoint, MultiPolygon, Point, Polygon, Rect};

/// Calculation of the centroid.
/// The centroid is the arithmetic mean position of all points in the shape.
Expand Down Expand Up @@ -304,10 +304,10 @@ where

#[cfg(test)]
mod test {
use algorithm::centroid::Centroid;
use algorithm::euclidean_distance::EuclideanDistance;
use crate::algorithm::centroid::Centroid;
use crate::algorithm::euclidean_distance::EuclideanDistance;
use num_traits::Float;
use {Coordinate, Line, LineString, MultiPolygon, Point, Polygon, Rect, COORD_PRECISION};
use crate::{Coordinate, Line, LineString, MultiPolygon, Point, Polygon, Rect, COORD_PRECISION};

/// small helper to create a coordinate
fn c<T: Float>(x: T, y: T) -> Coordinate<T> {
Expand Down
4 changes: 2 additions & 2 deletions geo/src/algorithm/closest_point.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use num_traits::Float;
use prelude::*;
use crate::prelude::*;
use std::iter;
use {Closest, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};
use crate::{Closest, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};

/// Find the closest point between two objects, where the other object is
/// assumed to be a `Point` by default.
Expand Down
8 changes: 4 additions & 4 deletions geo/src/algorithm/contains.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use num_traits::Float;

use algorithm::intersects::Intersects;
use {Coordinate, CoordinateType, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle};
use crate::algorithm::intersects::Intersects;
use crate::{Coordinate, CoordinateType, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle};

/// Checks if the geometry A is completely inside the B geometry
pub trait Contains<Rhs = Self> {
Expand Down Expand Up @@ -272,8 +272,8 @@ where

#[cfg(test)]
mod test {
use algorithm::contains::Contains;
use {Coordinate, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle};
use crate::algorithm::contains::Contains;
use crate::{Coordinate, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle};
#[test]
// V doesn't contain rect because two of its edges intersect with V's exterior boundary
fn polygon_does_not_contain_polygon() {
Expand Down
8 changes: 4 additions & 4 deletions geo/src/algorithm/convexhull.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use algorithm::euclidean_distance::EuclideanDistance;
use crate::algorithm::euclidean_distance::EuclideanDistance;
use num_traits::Float;
use std::mem;
use utils::partition_slice;
use {Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};
use crate::utils::partition_slice;
use crate::{Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};

fn swap_remove_to_first<'a, T>(slice: &mut &'a mut [T], idx: usize) -> &'a mut T {
let tmp = mem::replace(slice, &mut []);
Expand Down Expand Up @@ -197,7 +197,7 @@ where
#[cfg(test)]
mod test {
use super::*;
use {Coordinate, Point};
use crate::{Coordinate, Point};

#[test]
fn quick_hull_test1() {
Expand Down
16 changes: 8 additions & 8 deletions geo/src/algorithm/euclidean_distance.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use algorithm::contains::{get_position, Contains, PositionPoint};
use algorithm::euclidean_length::EuclideanLength;
use algorithm::intersects::Intersects;
use algorithm::polygon_distance_fast_path::*;
use crate::algorithm::contains::{get_position, Contains, PositionPoint};
use crate::algorithm::euclidean_length::EuclideanLength;
use crate::algorithm::intersects::Intersects;
use crate::algorithm::polygon_distance_fast_path::*;
use num_traits::float::FloatConst;
use num_traits::{Bounded, Float, Signed};
use {Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Triangle};
use crate::{Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Triangle};

use rstar::RTree;
use rstar::RTreeNum;
Expand Down Expand Up @@ -488,10 +488,10 @@ where
#[cfg(test)]
mod test {
use super::*;
use algorithm::convexhull::ConvexHull;
use algorithm::euclidean_distance::EuclideanDistance;
use crate::algorithm::convexhull::ConvexHull;
use crate::algorithm::euclidean_distance::EuclideanDistance;
use geo_types::private_utils::line_segment_distance;
use {Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};
use crate::{Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};

#[test]
fn line_segment_distance_test() {
Expand Down
6 changes: 3 additions & 3 deletions geo/src/algorithm/euclidean_length.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use num_traits::Float;
use std::iter::Sum;

use {Line, LineString, MultiLineString};
use crate::{Line, LineString, MultiLineString};

/// Calculation of the length
Expand Down Expand Up @@ -56,8 +56,8 @@ where

#[cfg(test)]
mod test {
use algorithm::euclidean_length::EuclideanLength;
use {Coordinate, Line, LineString, MultiLineString};
use crate::algorithm::euclidean_length::EuclideanLength;
use crate::{Coordinate, Line, LineString, MultiLineString};

#[test]
fn empty_linestring_test() {
Expand Down
Loading

0 comments on commit b8a9514

Please sign in to comment.