Skip to content

Commit

Permalink
Merge pull request #16 from boydjohnson/tidy-up
Browse files Browse the repository at this point in the history
Switch from circleci -> github, tidy up
  • Loading branch information
boydjohnson authored Jul 26, 2021
2 parents be73a03 + 05160a9 commit 765af3f
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 61 deletions.
17 changes: 0 additions & 17 deletions .circleci/config.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
pull_request:
push:
branches:
- master

env:
RUSTFLAGS: -Dwarnings

jobs:
build_and_test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable, nightly]

steps:
- uses: actions/checkout@master

- name: Install ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples

- name: tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all

check_fmt_and_docs:
name: Checking fmt, clippy, and docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: setup
run: |
rustup component add clippy rustfmt
rustc --version
- name: clippy
run: cargo clippy --tests --examples -- -D warnings

- name: fmt
run: cargo fmt --all -- --check

- name: Docs
run: cargo doc --no-deps
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "space-time"
version = "0.1.3"
version = "0.2.0"
authors = ["Boyd Johnson <[email protected]>"]
description = "A nightly only library of space-time filling curves that supports no-std."
license-file = "LICENSE.txt"
Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ comment_width = 90
enum_discrim_align_threshold = 20
format_code_in_doc_comments = true
format_strings = true
imports_granularity = "crate"
4 changes: 2 additions & 2 deletions src/index_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl CoveredRange {
/// Constructor.
#[must_use]
pub fn new(lower: u64, upper: u64) -> Self {
CoveredRange { lower, upper }
CoveredRange { upper, lower }
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@ impl OverlappingRange {
/// Constructor.
#[must_use]
pub fn new(lower: u64, upper: u64) -> Self {
OverlappingRange { lower, upper }
OverlappingRange { upper, lower }
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.

#![no_std]
#![feature(const_fn)]
#![deny(missing_docs)]
//! Partial port of the scala-based geomesa-z3 library from [geomesa](http://github.com/locationtech/geomesa)
//! Partial port of [sfcurve](https://github.com/locationtech/sfcurve) scala space-filling curve library.
Expand Down Expand Up @@ -103,10 +102,8 @@ extern crate quickcheck_macros;

extern crate alloc;

use xzorder::xz2_sfc::XZ2SFC;
use xzorder::xz3_sfc::XZ3SFC;
use zorder::z_3::ZCurve3D;
use zorder::z_curve_2d::ZCurve2D;
use xzorder::{xz2_sfc::XZ2SFC, xz3_sfc::XZ3SFC};
use zorder::{z_3::ZCurve3D, z_curve_2d::ZCurve2D};

/// Factory providing space filling curves
pub struct SpaceFillingCurves;
Expand Down
5 changes: 1 addition & 4 deletions src/xzorder/xz2_sfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
//! SpaceFillingCurve for storing non-point features based on a bounding box.
use crate::index_range::{CoveredRange, IndexRange, OverlappingRange};
use alloc::boxed::Box;
use alloc::collections::VecDeque;
use alloc::vec;
use alloc::vec::Vec;
use alloc::{boxed::Box, collections::VecDeque, vec, vec::Vec};
use num_integer::div_floor;
#[allow(unused_imports)]
use num_traits::Float;
Expand Down
8 changes: 3 additions & 5 deletions src/xzorder/xz3_sfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
//! Space-Time filling curve for non-points
use crate::index_range::{CoveredRange, IndexRange, OverlappingRange};
use alloc::boxed::Box;
use alloc::collections::VecDeque;
use alloc::{vec, vec::Vec};
use alloc::{boxed::Box, collections::VecDeque, vec, vec::Vec};
use num_integer::div_floor;
#[allow(unused_imports)]
use num_traits::Float;
Expand Down Expand Up @@ -65,10 +63,10 @@ impl XZ3SFC {
XZ3SFC {
g,
x_min,
y_min,
z_min,
x_max,
y_min,
y_max,
z_min,
z_max,
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/zorder/z_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

//! A two dimensional Z-Order curve.
use crate::zorder::z_n::ZN;
use crate::zorder::z_range::ZRange;
use crate::zorder::{z_n::ZN, z_range::ZRange};
use core::convert::TryInto;

/// A two dimensional Z-Order curve.
Expand Down Expand Up @@ -133,14 +132,14 @@ mod tests {
if x > Z2::MAX_MASK as u32 || y > Z2::MAX_MASK as u32 {
true
} else {
let (x_, y_) = Z2::new(x.into(), y.into()).decode();
let (x_, y_) = Z2::new(x, y).decode();
x_ == x && y_ == y
}
}

#[quickcheck]
fn test_split_and_combine(x: u32) -> bool {
Z2::combine(Z2::split(x.into())) == x.into()
Z2::combine(Z2::split(x)) == x
}

#[test]
Expand Down
14 changes: 7 additions & 7 deletions src/zorder/z_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

//! A three dimensional space filling curve.
use crate::index_range::IndexRange;
use crate::zorder::z_n::ZN;
use crate::zorder::z_range::ZRange;
use crate::RangeComputeHints;
use alloc::boxed::Box;
use alloc::vec::Vec;
use crate::{
index_range::IndexRange,
zorder::{z_n::ZN, z_range::ZRange},
RangeComputeHints,
};
use alloc::{boxed::Box, vec::Vec};
use core::convert::TryInto;

/// Three dimensional space filling curve.
Expand Down Expand Up @@ -156,8 +156,8 @@ impl ZCurve3D {
ZCurve3D {
g,
x_min,
y_min,
x_max,
y_min,
y_max,
z_max,
}
Expand Down
12 changes: 7 additions & 5 deletions src/zorder/z_curve_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

//! Implementation of `SpaceFillingCurve2D` for zorder.
use crate::index_range::IndexRange;
use crate::zorder::{z_2::Z2, z_n::ZN, z_range::ZRange};
use crate::RangeComputeHints;
use crate::{
index_range::IndexRange,
zorder::{z_2::Z2, z_n::ZN, z_range::ZRange},
RangeComputeHints,
};
use alloc::{boxed::Box, vec::Vec};

/// 2-Dimensional `ZCurve`, with x as longitude and y as latitude.
Expand Down Expand Up @@ -51,8 +53,8 @@ impl ZCurve2D {
ZCurve2D {
resolution,
x_min,
y_min,
x_max,
y_min,
y_max,
}
}
Expand Down Expand Up @@ -161,7 +163,7 @@ mod tests {
let (l, r, contains) = ranges[0].tuple();
assert_eq!(l, 197616);
assert_eq!(r, 197631);
assert_eq!(contains, true);
assert!(contains);
}

#[test]
Expand Down
17 changes: 6 additions & 11 deletions src/zorder/z_n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

//! An N-Dimensional Z-Order Curve base class.
use crate::index_range::{CoveredRange, IndexRange, OverlappingRange};
use crate::zorder::z_range::ZRange;
use alloc::boxed::Box;
use alloc::collections::VecDeque;
use alloc::vec::Vec;
use crate::{
index_range::{CoveredRange, IndexRange, OverlappingRange},
zorder::z_range::ZRange,
};
use alloc::{boxed::Box, collections::VecDeque, vec, vec::Vec};

const DEFAULT_RECURSE: usize = 7;

Expand Down Expand Up @@ -88,12 +88,7 @@ pub trait ZN {
let lcp = Self::longest_common_prefix(
zbounds
.iter()
.flat_map(|b| {
let mut arr = Vec::with_capacity(2);
arr.push(b.min);
arr.push(b.max);
arr
})
.flat_map(|b| vec![b.min, b.max])
.collect::<Vec<u64>>()
.as_slice(),
);
Expand Down

0 comments on commit 765af3f

Please sign in to comment.