Skip to content

Commit

Permalink
Sync with 1.2 remote version and upgrade version
Browse files Browse the repository at this point in the history
  • Loading branch information
Davichet-e committed Oct 17, 2024
1 parent f868df4 commit 9174ac6
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 68 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ jobs:
- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
- name: Run lib tests
# They need to be run in sequence because MEOS doesn't support multi-threading
run: cargo test --verbose --lib -- --test-threads 1

- name: Run doc tests
run: cargo test --verbose --doc
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "meos"
version = "0.1.2"
version = "0.1.3"
license-file = "LICENSE"
authors = ["David García Morillo <[email protected]>"]
repository = "https://github.com/MobilityDB/RustMEOS"
Expand All @@ -13,7 +13,7 @@ edition = "2021"

[dependencies]
paste = "1.0.15"
meos-sys = { path = "sys", version = "0.1.0" }
meos-sys = { path = "sys", version = "0.1.3" }
chrono = "0.4.38"
libc = "0.2.155"
bitmask-enum = "2.2.4"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can check the examples in the `examples/` directory.
```rust
use meos::{meos_initialize, TGeomPoint};

meos_initialize("UTC");
meos_initialize();

let trajectory: TGeomPoint = "[POINT(1 1)@2000-01-01 08:00, POINT(2 2)@2000-01-01 08:01]".parse().unwrap();
```
Expand All @@ -27,7 +27,7 @@ let trajectory: TGeomPoint = "[POINT(1 1)@2000-01-01 08:00, POINT(2 2)@2000-01-0
```rust
use meos::{meos_initialize, TGeomPoint};

meos_initialize("UTC");
meos_initialize();

let tpoint1: TGeomPoint = "[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-03, Point(0 0 0)@2001-01-05)".parse().unwrap();
let tpoint2: TGeomPoint = "[Point(2 0 0)@2001-01-02, Point(1 1 1)@2001-01-04, Point(2 2 2)@2001-01-06)".parse().unwrap();
Expand All @@ -42,7 +42,7 @@ println!("{distance}"); // Prints 0.5
use meos::{meos_initialize, TGeomPoint};
use geos::{Geometry}

meos_initialize("UTC");
meos_initialize();

let trajectory: TGeomPoint = "[Point(0 0 0)@2001-01-01, Point(2 2 2)@2001-01-05)".parse().unwrap();
let geom = Geometry::new_from_wkt("Point (1 1 1)").expect("Invalid geometry");
Expand Down
2 changes: 1 addition & 1 deletion examples/01_hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use meos::{meos_initialize, MeosEnum, TGeomPoint};

fn main() {
meos_initialize("UTC");
meos_initialize();
// Input temporal points in WKT format
let instant_wkt = "POINT(1 1)@2000-01-01";
let sequence_discrete_wkt = "{POINT(1 1)@2000-01-01, POINT(2 2)@2000-01-02}";
Expand Down
2 changes: 1 addition & 1 deletion examples/02_ais_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct AISRecord {
}

fn main() {
meos_initialize("UTC");
meos_initialize();
// https://github.com/MobilityDB/MobilityDB/blob/master/meos/examples/data/ais_instants.csv
let file = File::open("data/ais_instants.csv").unwrap_or_else(|_| {
println!("Error opening input file");
Expand Down
2 changes: 1 addition & 1 deletion examples/03_ais_assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct TripRecord {
}

fn main() {
meos_initialize("UTC");
meos_initialize();
let start_time = Instant::now();

let mut trips: Vec<TripRecord> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/ais_full_assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct TripRecord {
}

fn main() {
meos_initialize("UTC");
meos_initialize();
let start_time = Instant::now();

let mut trips: Vec<TripRecord> = Vec::with_capacity(MAX_SHIPS);
Expand Down
4 changes: 2 additions & 2 deletions src/boxes/stbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl cmp::PartialEq for STBox {
/// # use meos::boxes::stbox::STBox;
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span1: STBox = STBox::from_str("STBOX ZT(((1.0,2.0,3.0),(4.0,5.0,6.0)),[2001-01-01, 2001-01-02])").unwrap();
/// let span2: STBox = STBox::from_str("STBOX ZT(((1.0,2.0,3.0),(4.0,5.0,6.0)),[2001-01-01, 2001-01-02])").unwrap();
/// assert_eq!(span1, span2);
Expand Down Expand Up @@ -345,7 +345,7 @@ impl std::str::FromStr for STBox {
/// use meos::boxes::r#box::Box;
/// use std::str::FromStr;
/// # use meos::meos_initialize;
/// # meos_initialize("UTC");
/// # meos_initialize();
///
/// let stbox: STBox = "STBOX ZT(((1.0,2.0,3.0),(4.0,5.0,6.0)),[2001-01-01, 2001-01-02])".parse().expect("Failed to parse span");
/// let temporal_span: TsTzSpan = stbox.tstzspan();
Expand Down
8 changes: 4 additions & 4 deletions src/boxes/tbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl MeosBox for TBox {
/// use meos::boxes::r#box::Box;
/// # use meos::meos_initialize;
/// use chrono::{Utc, TimeZone, TimeDelta};
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let datetime = Utc.with_ymd_and_hms(2020, 5, 15, 12, 0, 0).unwrap();
/// let tbox = TBox::from_time(datetime);
/// let tstzspan = tbox.tstzspan();
Expand Down Expand Up @@ -635,7 +635,7 @@ impl TBox {
/// use meos::boxes::r#box::Box;
/// # use std::str::FromStr;
/// # use meos::meos_initialize;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let tbox = TBox::from_str("TBOXFLOAT XT([0, 10),[2020-06-01, 2020-06-05])").unwrap();
/// let shifted_scaled_tbox = tbox.shift_scale_value(Some(2.0), Some(4.0));
///
Expand Down Expand Up @@ -675,7 +675,7 @@ impl cmp::PartialEq for TBox {
/// use meos::boxes::r#box::Box;
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span1: TBox = TBox::from_str("TBOXFLOAT XT([0, 10),[2020-06-01, 2020-06-05])").unwrap();
/// let span2: TBox = TBox::from_str("TBOXFLOAT XT([0, 10),[2020-06-01, 2020-06-05])").unwrap();
/// assert_eq!(span1, span2);
Expand Down Expand Up @@ -726,7 +726,7 @@ impl std::str::FromStr for TBox {
/// # use meos::collections::datetime::tstz_span::TsTzSpan;
/// use std::str::FromStr;
/// # use meos::meos_initialize;
/// # meos_initialize("UTC");
/// # meos_initialize();
///
/// let tbox: TBox = "TBOXINT XT([0, 10),[2020-06-01, 2020-06-05])".parse().expect("Failed to parse span");
/// let value_span: IntSpan = tbox.intspan();
Expand Down
6 changes: 3 additions & 3 deletions src/collections/datetime/date_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl span::Span for DateSpan {
/// use std::str::FromStr;
/// # use meos::collections::base::span::Span;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span1 = DateSpan::from_str("[2019-09-08, 2019-09-10]").unwrap();
/// let span2 = DateSpan::from_str("[2019-09-12, 2019-09-14]").unwrap();
/// let distance = span1.distance_to_span(&span2);
Expand Down Expand Up @@ -255,7 +255,7 @@ impl span::Span for DateSpan {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = DateSpan::from_str("[2019-09-08, 2019-09-10]").unwrap();
/// let span_set2 = DateSpan::from_str("[2018-08-07, 2018-08-17]").unwrap();
/// let distance = span_set1.distance_to_span(&span_set2);
Expand Down Expand Up @@ -311,7 +311,7 @@ impl std::str::FromStr for DateSpan {
/// # use std::str::FromStr;
/// # use meos::meos_initialize;
/// use chrono::NaiveDate;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let from_ymd_opt = |y, m, d| NaiveDate::from_ymd_opt(y, m, d).unwrap();
///
/// let span: DateSpan = "(2019-09-08, 2019-09-10)".parse().expect("Failed to parse span");
Expand Down
16 changes: 8 additions & 8 deletions src/collections/datetime/date_span_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-16, 2019-09-20]}").unwrap();
/// let shifted_span_set = span_set.shift(TimeDelta::days(5));
///
Expand All @@ -96,7 +96,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-13, 2019-09-15]}").unwrap();
/// let scaled_span_set = span_set.scale(TimeDelta::days(5));
///
Expand Down Expand Up @@ -124,7 +124,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-11, 2019-09-12]}").unwrap();
/// let shifted_scaled_span_set = span_set.shift_scale(Some(TimeDelta::days(5)), Some(TimeDelta::days(10)));
///
Expand Down Expand Up @@ -164,7 +164,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use chrono::{TimeDelta, TimeZone, NaiveDate};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-11, 2019-09-12]}").unwrap();
/// let timestamp = NaiveDate::from_ymd_opt(2019, 9, 5).unwrap();
/// let distance = span_set.distance_to_value(&timestamp);
Expand Down Expand Up @@ -200,7 +200,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-11, 2019-09-12]}").unwrap();
/// let span_set2 = DateSpanSet::from_str("{[2018-08-07, 2018-08-17], [2018-10-17, 2018-10-20]}").unwrap();
/// let distance = span_set1.distance_to_span_set(&span_set2);
Expand Down Expand Up @@ -231,7 +231,7 @@ impl span_set::SpanSet for DateSpanSet {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-11, 2019-09-12]}").unwrap();
/// let span = DateSpan::from_str("[2018-08-07, 2018-08-17]").unwrap();
/// let distance = span_set.distance_to_span(&span);
Expand Down Expand Up @@ -310,7 +310,7 @@ impl BitAnd<DateSpanSet> for DateSpanSet {
/// # use meos::meos_initialize;
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-15, 2019-09-20]}").unwrap();
/// let span_set2 = DateSpanSet::from_str("{[2019-09-15, 2019-09-30], [2019-11-11, 2019-11-12]}").unwrap();
///
Expand Down Expand Up @@ -342,7 +342,7 @@ impl BitOr for DateSpanSet {
/// # use meos::meos_initialize;
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = DateSpanSet::from_str("{[2019-09-08, 2019-09-10], [2019-09-15, 2019-09-20]}").unwrap();
/// let span_set2 = DateSpanSet::from_str("{[2019-09-15, 2019-09-30], [2019-11-11, 2019-11-12]}").unwrap();
///
Expand Down
15 changes: 8 additions & 7 deletions src/collections/datetime/tstz_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl span::Span for TsTzSpan {
/// # use meos::meos_initialize;
/// use chrono::naive::NaiveDate;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
///
/// let from_ymd_opt = |y, m, d| NaiveDate::from_ymd_opt(y, m, d)
/// .unwrap().and_hms_opt(0, 0, 0)
Expand Down Expand Up @@ -150,7 +150,7 @@ impl span::Span for TsTzSpan {
/// # use meos::meos_initialize;
/// use chrono::naive::NaiveDate;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
///
/// let from_ymd_opt = |y, m, d| NaiveDate::from_ymd_opt(y, m, d)
/// .unwrap().and_hms_opt(0, 0, 0)
Expand Down Expand Up @@ -181,7 +181,7 @@ impl span::Span for TsTzSpan {
/// use chrono::naive::NaiveDate;
/// use chrono::TimeDelta;
/// # use meos::meos_initialize;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let from_ymd_opt = |y, m, d| NaiveDate::from_ymd_opt(y, m, d)
/// .unwrap().and_hms_opt(0, 0, 0)
/// .unwrap().and_utc();
Expand Down Expand Up @@ -226,7 +226,7 @@ impl span::Span for TsTzSpan {
/// use std::str::FromStr;
/// # use meos::collections::base::span::Span;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span1 = TsTzSpan::from_str("[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00]").unwrap();
/// let span2 = TsTzSpan::from_str("[2019-09-12 00:00:00+00, 2019-09-14 00:00:00+00]").unwrap();
/// let distance = span1.distance_to_span(&span2);
Expand Down Expand Up @@ -255,7 +255,7 @@ impl span::Span for TsTzSpan {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = TsTzSpan::from_str("[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00]").unwrap();
/// let span_set2 = TsTzSpan::from_str("[2018-08-07 00:00:00+00, 2018-08-17 00:00:00+00]").unwrap();
/// let distance = span_set1.distance_to_span(&span_set2);
Expand Down Expand Up @@ -311,9 +311,10 @@ impl std::str::FromStr for TsTzSpan {
/// # use meos::collections::datetime::tstz_span::TsTzSpan;
/// # use meos::collections::base::span::Span;
/// # use std::str::FromStr;
/// # use meos::meos_initialize;
/// # use meos::{meos_initialize, meos_initialize_timezone};
/// use chrono::NaiveDate;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// # meos_initialize_timezone("UTC");
/// let from_ymd_opt = |y, m, d| NaiveDate::from_ymd_opt(y, m, d)
/// .unwrap().and_hms_opt(0, 0, 0)
/// .unwrap().and_utc();
Expand Down
16 changes: 8 additions & 8 deletions src/collections/datetime/tstz_span_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-16 00:00:00+00, 2019-09-20 00:00:00+00]}").unwrap();
/// let shifted_span_set = span_set.shift(TimeDelta::days(5));
///
Expand All @@ -98,7 +98,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-13 00:00:00+00, 2019-09-15 00:00:00+00]}").unwrap();
/// let scaled_span_set = span_set.scale(TimeDelta::days(5));
///
Expand Down Expand Up @@ -126,7 +126,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// use chrono::TimeDelta;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-11 00:00:00+00, 2019-09-12 00:00:00+00]}").unwrap();
/// let shifted_scaled_span_set = span_set.shift_scale(Some(TimeDelta::days(5)), Some(TimeDelta::days(10)));
///
Expand Down Expand Up @@ -170,7 +170,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-11 00:00:00+00, 2019-09-12 00:00:00+00]}").unwrap();
/// let timestamp = Utc.with_ymd_and_hms(2019, 9, 5, 0, 0, 0).unwrap();
/// let distance = span_set.distance_to_value(&timestamp);
Expand Down Expand Up @@ -200,7 +200,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-11 00:00:00+00, 2019-09-12 00:00:00+00]}").unwrap();
/// let span_set2 = TsTzSpanSet::from_str("{[2018-08-07 00:00:00+00, 2018-08-17 00:00:00+00], [2018-10-17 00:00:00+00, 2018-10-20 00:00:00+00]}").unwrap();
/// let distance = span_set1.distance_to_span_set(&span_set2);
Expand Down Expand Up @@ -232,7 +232,7 @@ impl span_set::SpanSet for TsTzSpanSet {
/// # use chrono::{TimeDelta, TimeZone, Utc};
/// # use meos::meos_initialize;
/// use std::str::FromStr;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-11 00:00:00+00, 2019-09-12 00:00:00+00]}").unwrap();
/// let span = TsTzSpan::from_str("[2018-08-07 00:00:00+00, 2018-08-17 00:00:00+00]").unwrap();
/// let distance = span_set.distance_to_span(&span);
Expand Down Expand Up @@ -311,7 +311,7 @@ impl BitAnd<TsTzSpanSet> for TsTzSpanSet {
/// # use meos::meos_initialize;
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-15 00:00:00+00, 2019-09-20 00:00:00+00]}").unwrap();
/// let span_set2 = TsTzSpanSet::from_str("{[2019-09-15 00:00:00+00, 2019-09-30 00:00:00+00], [2019-11-11 00:00:00+00, 2019-11-12 00:00:00+00]}").unwrap();
///
Expand Down Expand Up @@ -343,7 +343,7 @@ impl BitOr for TsTzSpanSet {
/// # use meos::meos_initialize;
/// # use std::str::FromStr;
/// # use meos::collections::base::span_set::SpanSet;
/// # meos_initialize("UTC");
/// # meos_initialize();
/// let span_set1 = TsTzSpanSet::from_str("{[2019-09-08 00:00:00+00, 2019-09-10 00:00:00+00], [2019-09-15 00:00:00+00, 2019-09-20 00:00:00+00]}").unwrap();
/// let span_set2 = TsTzSpanSet::from_str("{[2019-09-15 00:00:00+00, 2019-09-30 00:00:00+00], [2019-11-11 00:00:00+00, 2019-11-12 00:00:00+00]}").unwrap();
///
Expand Down
Loading

0 comments on commit 9174ac6

Please sign in to comment.