Skip to content

Commit 889cfb7

Browse files
committed
Fix doc tests
1 parent d6e8504 commit 889cfb7

File tree

25 files changed

+111
-140
lines changed

25 files changed

+111
-140
lines changed

rust/geo-generic-alg/README.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
# Generic Algorithms for Geo-Traits
22

3-
This crate provides the same algorithms as the `geo` crate, but applies traits
4-
defined in `geo-traits` instead of concrete geometry types defined in
3+
This crate contains algorithms ported from the [`geo` crate](https://github.com/georust/geo),
4+
but works with traits defined in `geo-traits-ext` instead of concrete geometry types defined in
55
`geo-types`.
6-
7-
We are still in the early stage of migrating the algorithms, and the crate is
8-
not ready for production use yet.
9-
10-
## Status
11-
12-
- [ ] Area calculation
13-
- [ ] Centroid calculation
14-
- [ ] Convex hull calculation
15-
- [ ] Relationships (contains, within, etc)
16-
- [ ] Simplification
17-
- [ ] Buffer
18-
- [ ] Distance
19-
- [ ] Intersection
20-
- [ ] Union
21-
- [ ] Difference
22-
- [ ] Symmetric difference

rust/geo-generic-alg/src/algorithm/affine_ops.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::{fmt, ops::Mul, ops::Neg};
1818
/// # Examples
1919
/// ## Build up transforms by beginning with a constructor, then chaining mutation operations
2020
/// ```
21-
/// use geo::{AffineOps, AffineTransform};
22-
/// use geo::{point, line_string, BoundingRect};
21+
/// use geo_generic_alg::{AffineOps, AffineTransform};
22+
/// use geo_generic_alg::{point, line_string, BoundingRect};
2323
/// use approx::assert_relative_eq;
2424
///
2525
/// let line_string = line_string![(x: 0.0, y: 0.0),(x: 1.0, y: 1.0)];
@@ -108,8 +108,8 @@ impl<T: CoordNum, M: MapCoordsInPlace<T>> AffineOpsMut<T> for M {
108108
/// # Examples
109109
/// ## Build up transforms by beginning with a constructor, then chaining mutation operations
110110
/// ```
111-
/// use geo::{AffineOps, AffineTransform};
112-
/// use geo::{point, line_string, BoundingRect};
111+
/// use geo_generic_alg::{AffineOps, AffineTransform};
112+
/// use geo_generic_alg::{point, line_string, BoundingRect};
113113
/// use approx::assert_relative_eq;
114114
///
115115
/// let line_string = line_string![(x: 0.0, y: 0.0),(x: 1.0, y: 1.0)];
@@ -126,7 +126,7 @@ impl<T: CoordNum, M: MapCoordsInPlace<T>> AffineOpsMut<T> for M {
126126
///
127127
/// ## Create affine transform manually, and access elements using getter methods
128128
/// ```
129-
/// use geo::AffineTransform;
129+
/// use geo_generic_alg::AffineTransform;
130130
///
131131
/// let transform = AffineTransform::new(10.0, 0.0, 400_000.0, 0.0, -10.0, 500_000.0);
132132
///
@@ -198,7 +198,7 @@ impl<T: CoordNum> AffineTransform<T> {
198198
///
199199
/// This is a **cumulative** operation; the new transform is *added* to the existing transform.
200200
/// ```
201-
/// use geo::AffineTransform;
201+
/// use geo_generic_alg::AffineTransform;
202202
/// let mut transform = AffineTransform::identity();
203203
///
204204
/// // create two transforms that cancel each other
@@ -242,7 +242,7 @@ impl<T: CoordNum> AffineTransform<T> {
242242
/// that is, whether it's application will be a a no-op.
243243
///
244244
/// ```
245-
/// use geo::AffineTransform;
245+
/// use geo_generic_alg::AffineTransform;
246246
/// let mut transform = AffineTransform::identity();
247247
/// assert!(transform.is_identity());
248248
///

rust/geo-generic-alg/src/algorithm/area.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub(crate) fn twice_signed_ring_area<T: CoordNum, LS: LineStringTraitExt<T = T>>
4848
/// # Examples
4949
///
5050
/// ```
51-
/// use geo::polygon;
52-
/// use geo::Area;
51+
/// use geo_generic_alg::polygon;
52+
/// use geo_generic_alg::Area;
5353
///
5454
/// let mut polygon = polygon![
5555
/// (x: 0., y: 0.),

rust/geo-generic-alg/src/algorithm/bounding_rect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub trait BoundingRect<T: CoordNum> {
1313
/// # Examples
1414
///
1515
/// ```
16-
/// use geo::BoundingRect;
17-
/// use geo::line_string;
16+
/// use geo_generic_alg::BoundingRect;
17+
/// use geo_generic_alg::line_string;
1818
///
1919
/// let line_string = line_string![
2020
/// (x: 40.02f64, y: 116.34),

rust/geo-generic-alg/src/algorithm/centroid.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::GeoFloat;
2020
/// # Examples
2121
///
2222
/// ```
23-
/// use geo::Centroid;
24-
/// use geo::{point, polygon};
23+
/// use geo_generic_alg::Centroid;
24+
/// use geo_generic_alg::{point, polygon};
2525
///
2626
/// // rhombus shaped polygon
2727
/// let polygon = polygon![
@@ -45,8 +45,8 @@ pub trait Centroid {
4545
/// # Examples
4646
///
4747
/// ```
48-
/// use geo::Centroid;
49-
/// use geo::{line_string, point};
48+
/// use geo_generic_alg::Centroid;
49+
/// use geo_generic_alg::{line_string, point};
5050
///
5151
/// let line_string = line_string![
5252
/// (x: 40.02f64, y: 116.34),
@@ -90,8 +90,8 @@ where
9090
/// # Examples
9191
///
9292
/// ```
93-
/// use geo::Centroid;
94-
/// use geo::{Line, point};
93+
/// use geo_generic_alg::Centroid;
94+
/// use geo_generic_alg::{Line, point};
9595
///
9696
/// let line = Line::new(
9797
/// point!(x: 1.0f64, y: 3.0),
@@ -125,8 +125,8 @@ where
125125
/// # Examples
126126
///
127127
/// ```
128-
/// use geo::Centroid;
129-
/// use geo::{line_string, point};
128+
/// use geo_generic_alg::Centroid;
129+
/// use geo_generic_alg::{line_string, point};
130130
///
131131
/// let line_string = line_string![
132132
/// (x: 1.0f32, y: 1.0),
@@ -160,8 +160,8 @@ where
160160
/// # Examples
161161
///
162162
/// ```
163-
/// use geo::Centroid;
164-
/// use geo::{MultiLineString, line_string, point};
163+
/// use geo_generic_alg::Centroid;
164+
/// use geo_generic_alg::{MultiLineString, line_string, point};
165165
///
166166
/// let multi_line_string = MultiLineString::new(vec![
167167
/// // centroid: (2.5, 2.5)
@@ -195,8 +195,8 @@ where
195195
/// # Examples
196196
///
197197
/// ```
198-
/// use geo::Centroid;
199-
/// use geo::{polygon, point};
198+
/// use geo_generic_alg::Centroid;
199+
/// use geo_generic_alg::{polygon, point};
200200
///
201201
/// let polygon = polygon![
202202
/// (x: 0.0f32, y: 0.0),
@@ -230,8 +230,8 @@ where
230230
/// # Examples
231231
///
232232
/// ```
233-
/// use geo::Centroid;
234-
/// use geo::{MultiPolygon, polygon, point};
233+
/// use geo_generic_alg::Centroid;
234+
/// use geo_generic_alg::{MultiPolygon, polygon, point};
235235
///
236236
/// let multi_polygon = MultiPolygon::new(vec![
237237
/// // centroid (1.0, 0.5)
@@ -275,8 +275,8 @@ where
275275
/// # Examples
276276
///
277277
/// ```
278-
/// use geo::Centroid;
279-
/// use geo::{Rect, point};
278+
/// use geo_generic_alg::Centroid;
279+
/// use geo_generic_alg::{Rect, point};
280280
///
281281
/// let rect = Rect::new(
282282
/// point!(x: 0.0f32, y: 0.0),
@@ -305,8 +305,8 @@ where
305305
/// # Examples
306306
///
307307
/// ```
308-
/// use geo::Centroid;
309-
/// use geo::{Triangle, coord, point};
308+
/// use geo_generic_alg::Centroid;
309+
/// use geo_generic_alg::{Triangle, coord, point};
310310
///
311311
/// let triangle = Triangle::new(
312312
/// coord!(x: 0.0f32, y: -1.0),
@@ -340,8 +340,8 @@ where
340340
/// # Examples
341341
///
342342
/// ```
343-
/// use geo::Centroid;
344-
/// use geo::point;
343+
/// use geo_generic_alg::Centroid;
344+
/// use geo_generic_alg::point;
345345
///
346346
/// let point = point!(x: 1.0f32, y: 2.0);
347347
///
@@ -368,8 +368,8 @@ where
368368
/// # Example
369369
///
370370
/// ```
371-
/// use geo::Centroid;
372-
/// use geo::{MultiPoint, Point};
371+
/// use geo_generic_alg::Centroid;
372+
/// use geo_generic_alg::{MultiPoint, Point};
373373
///
374374
/// let empty: Vec<Point> = Vec::new();
375375
/// let empty_multi_points: MultiPoint<_> = empty.into();
@@ -397,8 +397,8 @@ where
397397
/// # Examples
398398
///
399399
/// ```
400-
/// use geo::Centroid;
401-
/// use geo::{Geometry, Rect, point};
400+
/// use geo_generic_alg::Centroid;
401+
/// use geo_generic_alg::{Geometry, Rect, point};
402402
///
403403
/// let rect = Rect::new(
404404
/// point!(x: 0.0f32, y: 0.0),
@@ -456,8 +456,8 @@ where
456456
/// # Examples
457457
///
458458
/// ```
459-
/// use geo::Centroid;
460-
/// use geo::{Geometry, GeometryCollection, Rect, Triangle, point, coord};
459+
/// use geo_generic_alg::Centroid;
460+
/// use geo_generic_alg::{Geometry, GeometryCollection, Rect, Triangle, point, coord};
461461
///
462462
/// let rect_geometry = Geometry::from(Rect::new(
463463
/// point!(x: 0.0f32, y: 0.0),

rust/geo-generic-alg/src/algorithm/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{Coord, CoordNum, MapCoords};
55
/// # Examples
66
///
77
/// ```rust
8-
/// use geo::{Convert, LineString, line_string};
8+
/// use geo_generic_alg::{Convert, LineString, line_string};
99
///
1010
/// let line_string_32: LineString<f32> = line_string![
1111
/// (x: 5., y: 10.),
@@ -41,7 +41,7 @@ where
4141
/// # Examples
4242
///
4343
/// ```rust
44-
/// use geo::{TryConvert, LineString, line_string};
44+
/// use geo_generic_alg::{TryConvert, LineString, line_string};
4545
///
4646
/// let line_string_64: LineString<i64> = line_string![
4747
/// (x: 5, y: 10),

rust/geo-generic-alg/src/algorithm/coordinate_position.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::cmp::Ordering;
44
use crate::geometry::*;
55
use crate::intersects::{point_in_rect, value_in_between};
66
use crate::kernels::*;
7-
use crate::{BoundingRect, HasDimensions, Intersects};
87
use crate::GeoNum;
8+
use crate::{BoundingRect, HasDimensions, Intersects};
99
use geo_traits_ext::*;
1010

1111
/// The position of a `Coord` relative to a `Geometry`
@@ -21,8 +21,8 @@ pub enum CoordPos {
2121
/// # Examples
2222
///
2323
/// ```rust
24-
/// use geo::{polygon, coord};
25-
/// use geo::coordinate_position::{CoordinatePosition, CoordPos};
24+
/// use geo_generic_alg::{polygon, coord};
25+
/// use geo_generic_alg::coordinate_position::{CoordinatePosition, CoordPos};
2626
///
2727
/// let square_poly = polygon![(x: 0.0, y: 0.0), (x: 2.0, y: 0.0), (x: 2.0, y: 2.0), (x: 0.0, y: 2.0), (x: 0.0, y: 0.0)];
2828
///

rust/geo-generic-alg/src/algorithm/coords_iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait CoordsIter {
2727
/// # Examples
2828
///
2929
/// ```
30-
/// use geo::coords_iter::CoordsIter;
30+
/// use geo_generic_alg::coords_iter::CoordsIter;
3131
///
3232
/// let multi_point = geo::MultiPoint::new(vec![
3333
/// geo::point!(x: -10., y: 0.),
@@ -48,8 +48,8 @@ pub trait CoordsIter {
4848
/// # Examples
4949
///
5050
/// ```
51-
/// use geo::coords_iter::CoordsIter;
52-
/// use geo::line_string;
51+
/// use geo_generic_alg::coords_iter::CoordsIter;
52+
/// use geo_generic_alg::line_string;
5353
///
5454
/// let ls = line_string![
5555
/// (x: 1., y: 2.),
@@ -66,8 +66,8 @@ pub trait CoordsIter {
6666
/// # Examples
6767
///
6868
/// ```
69-
/// use geo::coords_iter::CoordsIter;
70-
/// use geo::polygon;
69+
/// use geo_generic_alg::coords_iter::CoordsIter;
70+
/// use geo_generic_alg::polygon;
7171
///
7272
/// // a diamond shape
7373
/// let polygon = polygon![

rust/geo-generic-alg/src/algorithm/dimensions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{CoordNum, GeoNum};
1111
///
1212
/// ```
1313
/// use geo_types::{Point, Rect, line_string};
14-
/// use geo::dimensions::{HasDimensions, Dimensions};
14+
/// use geo_generic_alg::dimensions::{HasDimensions, Dimensions};
1515
///
1616
/// let point = Point::new(0.0, 5.0);
1717
/// let line_string = line_string![(x: 0.0, y: 0.0), (x: 5.0, y: 5.0), (x: 0.0, y: 5.0)];
@@ -44,7 +44,7 @@ pub trait HasDimensions {
4444
/// never be considered empty.
4545
/// ```
4646
/// use geo_types::{Point, coord, LineString};
47-
/// use geo::HasDimensions;
47+
/// use geo_generic_alg::HasDimensions;
4848
///
4949
/// let line_string = LineString::new(vec![
5050
/// coord! { x: 0., y: 0. },
@@ -69,7 +69,7 @@ pub trait HasDimensions {
6969
///
7070
/// ```
7171
/// use geo_types::{GeometryCollection, Rect, Point};
72-
/// use geo::dimensions::{Dimensions, HasDimensions};
72+
/// use geo_generic_alg::dimensions::{Dimensions, HasDimensions};
7373
///
7474
/// // normal rectangle
7575
/// let rect = Rect::new((0.0, 0.0), (10.0, 10.0));
@@ -103,7 +103,7 @@ pub trait HasDimensions {
103103
///
104104
/// ```
105105
/// use geo_types::{GeometryCollection, Rect, Point};
106-
/// use geo::dimensions::{Dimensions, HasDimensions};
106+
/// use geo_generic_alg::dimensions::{Dimensions, HasDimensions};
107107
///
108108
/// // a point has no boundary
109109
/// let point = Point::new(10.0, 10.0);
@@ -307,7 +307,7 @@ where
307307

308308
/// ```
309309
/// use geo_types::line_string;
310-
/// use geo::dimensions::{HasDimensions, Dimensions};
310+
/// use geo_generic_alg::dimensions::{HasDimensions, Dimensions};
311311
///
312312
/// let ls = line_string![(x: 0., y: 0.), (x: 0., y: 1.), (x: 1., y: 1.)];
313313
/// assert_eq!(Dimensions::ZeroDimensional, ls.boundary_dimensions());

rust/geo-generic-alg/src/algorithm/euclidean_length.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub trait EuclideanLength<T, RHS = Self> {
1515
/// # Examples
1616
///
1717
/// ```
18-
/// use geo::EuclideanLength;
19-
/// use geo::line_string;
18+
/// use geo_generic_alg::EuclideanLength;
19+
/// use geo_generic_alg::line_string;
2020
///
2121
/// let line_string = line_string![
2222
/// (x: 40.02f64, y: 116.34),

0 commit comments

Comments
 (0)