osmium::DiffObject Class Reference

`#include <diff_object.hpp>`

Inheritance diagram for osmium::DiffObject:
[legend]
Collaboration diagram for osmium::DiffObject:
[legend]

## Public Member Functions

| DiffObject () noexcept
| DiffObject (const osmium::OSMObject &prev, const osmium::OSMObject &curr, const osmium::OSMObject &next) noexcept
bool | empty () const noexcept
const osmium::OSMObject & | prev () const noexcept
const osmium::OSMObject & | curr () const noexcept
const osmium::OSMObject & | next () const noexcept
bool | first () const noexcept
bool | last () const noexcept
osmium::item_type | type () const noexcept
osmium::object_id_type | id () const noexcept
osmium::object_version_type | version () const noexcept
osmium::changeset_id_type | changeset () const noexcept
const osmium::Timestamp | start_time () const noexcept
const osmium::Timestamp | end_time () const noexcept
bool | is_between (const osmium::Timestamp &from, const osmium::Timestamp &to) const noexcept
bool | is_visible_at (const osmium::Timestamp &timestamp) const noexcept

## Private Attributes

const osmium::OSMObject * | m_prev
const osmium::OSMObject * | m_curr
const osmium::OSMObject * | m_next

## Detailed Description

A DiffObject holds pointers to three OSMObjects, the current object, the previous, and the next. They always have the same type (Node, Way, or Relation) and the same ID, but may have different versions.

It is used when iterating over OSM files with history data to make working with versioned OSM objects easier. Because you have access to the previous and next objects as well as the current one, comparisons between object versions is easy.

If the current object is the first version available, the previous pointer must be the same as the current one. If the current object is the last version available, the next pointer must be the same as the current one.

DiffObjects are immutable.

## Constructor & Destructor Documentation

osmium::DiffObject::DiffObject | ( |  | ) |

inline noexcept

Default construct an empty DiffObject. Most methods of this class can not be called on empty DiffObjects.

osmium::DiffObject::DiffObject | ( | const osmium::OSMObject & | prev,
|  | const osmium::OSMObject & | curr,
|  | const osmium::OSMObject & | next
| ) |  |

inline noexcept

Construct a non-empty DiffObject from the given OSMObjects. All OSMObjects must be of the same type (Node, Way, or Relation) and have the same ID.

## Member Function Documentation

osmium::changeset_id_type osmium::DiffObject::changeset | ( |  | ) | const

inline noexcept

Return the changeset ID of the current object.

Precondition
  DiffObject must not be empty.

const osmium::OSMObject& osmium::DiffObject::curr | ( |  | ) | const

inline noexcept

Get the current object stored.

Precondition
  DiffObject must not be empty.

bool osmium::DiffObject::empty | ( |  | ) | const

inline noexcept

Check whether the DiffObject was created empty.

const osmium::Timestamp osmium::DiffObject::end_time | ( |  | ) | const

inline noexcept

Return the timestamp when the current version of the object is not valid any more, ie the time when the next version of the object is valid. If this is the last version of the object, this will return a special "end of time" timestamp that is guaranteed to be larger than any normal timestamp.

Precondition
  DiffObject must not be empty.

bool osmium::DiffObject::first | ( |  | ) | const

inline noexcept

Is the current object version the first (with this type and ID)?

Precondition
  DiffObject must not be empty.

osmium::object_id_type osmium::DiffObject::id | ( |  | ) | const

inline noexcept

Return the ID of the current object.

Precondition
  DiffObject must not be empty.

bool osmium::DiffObject::is_between | ( | const osmium::Timestamp & | from,
|  | const osmium::Timestamp & | to
| ) |  | const

inline noexcept

Current object version is valid between time "from" (inclusive) and time "to" (not inclusive).

This is a bit more complex than you'd think, because we have to handle the case properly where the start_time() == end_time().

Precondition
  DiffObject must not be empty.

bool osmium::DiffObject::is_visible_at | ( | const osmium::Timestamp & | timestamp | ) | const

inline noexcept

Current object version is visible at the given timestamp.

Precondition
  DiffObject must not be empty.

bool osmium::DiffObject::last | ( |  | ) | const

inline noexcept

Is the current object version the last (with this type and ID)?

Precondition
  DiffObject must not be empty.

const osmium::OSMObject& osmium::DiffObject::next | ( |  | ) | const

inline noexcept

Get the next object stored.

Precondition
  DiffObject must not be empty.

const osmium::OSMObject& osmium::DiffObject::prev | ( |  | ) | const

inline noexcept

Get the previous object stored.

Precondition
  DiffObject must not be empty.

const osmium::Timestamp osmium::DiffObject::start_time | ( |  | ) | const

inline noexcept

Return the timestamp when the current object version was created.

Precondition
  DiffObject must not be empty.

osmium::item_type osmium::DiffObject::type | ( |  | ) | const

inline noexcept

Return the type of the current object.

Precondition
  DiffObject must not be empty.

osmium::object_version_type osmium::DiffObject::version | ( |  | ) | const

inline noexcept

Return the version of the current object.

Precondition
  DiffObject must not be empty.

## Member Data Documentation

const osmium::OSMObject* osmium::DiffObject::m_curr

private

const osmium::OSMObject* osmium::DiffObject::m_next

private

const osmium::OSMObject* osmium::DiffObject::m_prev

private

The documentation for this class was generated from the following file:

- osmium/osm/diff_object.hpp