Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Unreleased

* BREAKING: Fix typo in `TimestampFormat::EpochNu_n_ber` -> `EpochNumber`
* The binary `osmio-changeset-tags-to-sqlite` will only be built when the
`with-changeset-sqlite` feature is enabled. This reduces the dependencies for
when osmio is used as a library.
Expand Down
6 changes: 3 additions & 3 deletions src/arcpbf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn decode_dense_nodes(
let timestamp = timestamps[index] as i32 + last_timestamp;
let timestamp = timestamp * date_granularity;
last_timestamp = timestamp;
let timestamp = TimestampFormat::EpochNunber(timestamp as i64);
let timestamp = TimestampFormat::EpochNumber(timestamp as i64);
assert!(uid_id < i32::MAX);

results.push(ArcOSMObj::Node(ArcNode {
Expand Down Expand Up @@ -273,7 +273,7 @@ fn decode_ways(
//let timestamp = timestamp * date_granularity;
//last_timestamp = timestamp;
//let timestamp = epoch_to_iso(timestamp);
let timestamp = TimestampFormat::EpochNunber(way.get_info().get_timestamp());
let timestamp = TimestampFormat::EpochNumber(way.get_info().get_timestamp());

results.push(ArcOSMObj::Way(ArcWay {
_id: id,
Expand Down Expand Up @@ -359,7 +359,7 @@ fn decode_relations(
//let timestamp = timestamp * date_granularity;
//last_timestamp = timestamp;
//let timestamp = epoch_to_iso(timestamp);
let timestamp = TimestampFormat::EpochNunber(relation.get_info().get_timestamp());
let timestamp = TimestampFormat::EpochNumber(relation.get_info().get_timestamp());

results.push(ArcOSMObj::Relation(ArcRelation {
_id: id,
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@ impl From<std::num::ParseFloatError> for ParseLatLonError {
#[derive(Debug, Clone, Eq, Serialize, Deserialize)]
pub enum TimestampFormat {
ISOString(String),
EpochNunber(i64),
EpochNumber(i64),
}

impl TimestampFormat {
pub fn to_iso_string(&self) -> String {
match self {
TimestampFormat::ISOString(s) => s.clone(),
TimestampFormat::EpochNunber(t) => epoch_to_iso(*t as i32),
TimestampFormat::EpochNumber(t) => epoch_to_iso(*t as i32),
}
}

pub fn to_epoch_number(&self) -> i64 {
match self {
TimestampFormat::ISOString(s) => iso_to_epoch(s) as i64,
&TimestampFormat::EpochNunber(t) => t,
&TimestampFormat::EpochNumber(t) => t,
}
}
}
Expand All @@ -271,7 +271,7 @@ where
T: Into<i64>,
{
fn from(v: T) -> Self {
TimestampFormat::EpochNunber(v.into())
TimestampFormat::EpochNumber(v.into())
}
}

Expand All @@ -282,7 +282,7 @@ impl std::str::FromStr for TimestampFormat {
let date: i64 = chrono::DateTime::parse_from_rfc3339(s)
.map_err(|_| "invalid date")?
.timestamp();
Ok(TimestampFormat::EpochNunber(date))
Ok(TimestampFormat::EpochNumber(date))
}
}

Expand All @@ -296,7 +296,7 @@ impl std::cmp::PartialOrd for TimestampFormat {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match (self, other) {
(TimestampFormat::ISOString(a), TimestampFormat::ISOString(b)) => a.partial_cmp(b),
(TimestampFormat::EpochNunber(a), TimestampFormat::EpochNunber(b)) => a.partial_cmp(b),
(TimestampFormat::EpochNumber(a), TimestampFormat::EpochNumber(b)) => a.partial_cmp(b),
(a, b) => a.to_epoch_number().partial_cmp(&b.to_epoch_number()),
}
}
Expand All @@ -305,7 +305,7 @@ impl std::cmp::PartialEq for TimestampFormat {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(TimestampFormat::ISOString(a), TimestampFormat::ISOString(b)) => a.eq(b),
(TimestampFormat::EpochNunber(a), TimestampFormat::EpochNunber(b)) => a.eq(b),
(TimestampFormat::EpochNumber(a), TimestampFormat::EpochNumber(b)) => a.eq(b),
(a, b) => a.to_epoch_number().eq(&b.to_epoch_number()),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/stringpbf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn decode_dense_nodes(
let timestamp = timestamps[index] as i32 + last_timestamp;
let timestamp = timestamp * date_granularity;
last_timestamp = timestamp;
let timestamp = TimestampFormat::EpochNunber(timestamp as i64);
let timestamp = TimestampFormat::EpochNumber(timestamp as i64);
assert!(uid_id < i32::MAX);

results.push_back(StringOSMObj::Node(StringNode {
Expand Down Expand Up @@ -259,7 +259,7 @@ fn decode_ways(
//let timestamp = timestamp * date_granularity;
//last_timestamp = timestamp;
//let timestamp = epoch_to_iso(timestamp);
let timestamp = TimestampFormat::EpochNunber(way.get_info().get_timestamp());
let timestamp = TimestampFormat::EpochNumber(way.get_info().get_timestamp());

results.push_back(StringOSMObj::Way(StringWay {
_id: id,
Expand Down Expand Up @@ -339,7 +339,7 @@ fn decode_relations(
//let timestamp = timestamp * date_granularity;
//last_timestamp = timestamp;
//let timestamp = epoch_to_iso(timestamp);
let timestamp = TimestampFormat::EpochNunber(relation.get_info().get_timestamp());
let timestamp = TimestampFormat::EpochNumber(relation.get_info().get_timestamp());

sink.push_back(StringOSMObj::Relation(StringRelation {
_id: id,
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ mod timestamp_format {

assert_cmp!(
int_iso3,
TimestampFormat::EpochNunber(1577836800),
TimestampFormat::EpochNumber(1577836800),
TimestampFormat::ISOString("2020-01-01T00:00:00Z".to_string()),
Equal
);
assert_cmp!(
int_iso4,
TimestampFormat::ISOString("2020-01-01T00:00:00Z".to_string()),
TimestampFormat::EpochNunber(1577836800),
TimestampFormat::EpochNumber(1577836800),
Equal
);
}
Expand Down