#spatial #space-filling-curve #2d-3d #bounding-box #no-std #spatio-temporal

no-std space-time

A nightly only library of space-time filling curves that supports no-std

6 releases

0.3.0 Aug 11, 2024
0.2.0 Jul 26, 2021
0.1.3 Dec 13, 2020
0.1.1 Apr 29, 2020

#285 in Graphics APIs

Download history 107/week @ 2024-08-10 8/week @ 2024-08-17 9/week @ 2024-09-14 1/week @ 2024-09-21 30/week @ 2024-09-28 2/week @ 2024-10-05

263 downloads per month

Custom license

77KB
2K SLoC

Space-time filling curves Rust library

This is a partial port of the geomesa-z3 package from geomesa.

It is also a partial port of sfcurve.

This library has 2D and 3D z-order curves that index points as well as 2D and 3D extended z-order curves for indexing objects by bounding box.


lib.rs:

Partial port of the scala-based geomesa-z3 library from geomesa Partial port of sfcurve scala space-filling curve library.

Useful for representing and querying spatial objects

Z2 curve is used for two dimensional point indexing and can be accessed through the SpaceFillingCurves factory.

use space_time::SpaceFillingCurves;

let curve = SpaceFillingCurves::get_point_curve(1024, -180.0, -90.0, 180.0, 90.0);
let indexed_point = curve.index(2.3522, 48.8566);
let range_of_index = curve.ranges(2.35, 48.85, 2.354, 48.857, &[]);

assert!(range_of_index
    .iter()
    .any(|r| r.lower() <= indexed_point && r.upper() >= indexed_point));

Z3 curve is used for two dimensional point and time indexing and can be accessed through the SpaceTimeFillingCurves factory.

use space_time::SpaceTimeFillingCurves;

let curve = SpaceTimeFillingCurves::get_point_curve(1024, -180.0, -90.0, 180.0, 90.0, 159753997829.0);
let indexed_point_in_time = curve.index(2.3522, 48.8566, 1587583997829.0); // Paris, France. April 22, 2020 as milliseconds since Unix Epoch.
let range_of_index = curve.ranges(2.3522, 48.85, 2.354, 48.857, 1587583997828.0, 1587583997828.0, &[]);

assert!(range_of_index.iter().any(|r| r.lower() <= indexed_point_in_time && r.upper() >= indexed_point_in_time));

Extended Z-order curves are used for non-points. XZ2SFC for spatial indexing of non-points.

use space_time::SpaceFillingCurves;

let curve = SpaceFillingCurves::get_non_point_curve(12, -180.0, -90.0, 180.0, 90.0);
let indexed_polygon = curve.index(2.3522, 48.8466, 2.39, 49.9325);
let range_of_index = curve.ranges(2.0, 48.0, 3.0, 50.0, None);

assert!(range_of_index
    .iter()
    .any(|r| r.lower() <= indexed_polygon && r.upper() >= indexed_polygon));

XZ3SFC for spatial-temporal indexing of non-points.

use space_time::SpaceTimeFillingCurves;

let curve = SpaceTimeFillingCurves::get_non_point_curve(
    12,
    -180.0,
    -90.0,
    0.0,
    180.0,
    90.0,
    1_893_456_000.0,
);

let indexed_polygon = curve.index(
    2.3522,
    48.8466,
    1_556_496_000.0,
    2.39,
    49.9325,
    1_556_496_000.0,
);

let range_of_index = curve.ranges(2.0, 48.0, 1_556_300_000.0, 3.0, 50.0, 1_557_496_000.0, None);

assert!(range_of_index
    .iter()
    .any(|r| r.lower() <= indexed_polygon && r.upper() >= indexed_polygon));

Dependencies

~595KB
~11K SLoC