2 个不稳定版本

0.2.1 2022年6月23日
0.1.0 2022年6月22日

#268 in 地理空间

MIT 许可证

14KB
150

coordinates_outliers

Rust

在一系列位置关系中找到关系,假设 [A,B,A] 表示 A->B->AA,BPoint 类型。

简单的库,用于查找异常值或与其他路径相比出现频率较低或较高的路径。

我们以 Point(x: f64, y: f64) 的形式存储位置,它们在使用 Point 上的 new 方法时自动四舍五入到三位小数。我们假设 x,ylatitude and longitude,并且不需要超过 3 decimal places of precision

使用 cargo doc --open 生成文档或在此处查看此处

相关 xkcd

location precision

用法

use location_outliers::{Point, PointPlane};

fn main(){
    let a = Point::new(0.123, 0.123);
    let b = Point::new(1.123, 1.123);
    let c = Point::new(2.123, 2.123);
    let d = Point::new(3.123, 3.123);
    let e = Point::new(0.123, 0.123);
    let f = Point::new(1.123, 1.123);

    let points = vec![a, b, c, d, e, f];

    let k = PointPlane::new(points, 100);

    println!("{:#?}", k);
}

输出

PointPlane {
    points: {
        "3.123 3.123": 1,
        "1.123 1.123": 2,
        "0.123 0.123": 2,
        "2.123 2.123": 1,
    },
    graph: Graph(
        {
            Connection(
                "3.123-3.123",
                "0.123-0.123",
                Cell {
                    value: 1,
                },
            ),
            Connection(
                "1.123-1.123",
                "2.123-2.123",
                Cell {
                    value: 1,
                },
            ),
            Connection(
                "2.123-2.123",
                "3.123-3.123",
                Cell {
                    value: 1,
                },
            ),
            Connection(
                "0.123-0.123",
                "1.123-1.123",
                Cell {
                    value: 2,
                },
            ),
        },
    ),
    accumulate_xaxis: SimpleAccumulator {
        vec: [
            0.123,
            1.123,
            2.123,
            3.123,
            0.123,
            1.123,
        ],
        mean: 1.289666666666667,
        population_variance: 1.138888888888889,
        min: 0.123,
        min_: 0.123,
        max: 3.123,
        max_: 2.123,
        median: 1.123,
        len: 6,
        capacity: 100,
        fixed_capacity: true,
        last_write_position: 5,
        accumulate: true,
    },
    accumulate_yaxis: SimpleAccumulator {
        vec: [
            0.123,
            1.123,
            2.123,
            3.123,
            0.123,
            1.123,
        ],
        mean: 1.289666666666667,
        population_variance: 1.138888888888889,
        min: 0.123,
        min_: 0.123,
        max: 3.123,
        max_: 2.123,
        median: 1.123,
        len: 6,
        capacity: 100,
        fixed_capacity: true,
        last_write_position: 5,
        accumulate: true,
    },
    capacity: 100,
}

依赖项

~790KB
~14K SLoC