Loading...
Searching...
No Matches
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=default
| 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
osmium::Timestamp | start_time () const noexcept
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 = nullptr
const osmium::OSMObject * | m_curr = nullptr
const osmium::OSMObject * | m_next = nullptr

## 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

## DiffObject() [1/2]

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

defaultnoexcept

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

## DiffObject() [2/2]

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

inlinenoexcept

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

## changeset()

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

inlinenoexcept

Return the changeset ID of the current object.

Precondition
  DiffObject must not be empty.

## curr()

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

inlinenoexcept

Get the current object stored.

Precondition
  DiffObject must not be empty.

## empty()

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

inlinenoexcept

Check whether the DiffObject was created empty.

## end_time()

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

inlinenoexcept

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.

## first()

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

inlinenoexcept

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

Precondition
  DiffObject must not be empty.

## id()

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

inlinenoexcept

Return the ID of the current object.

Precondition
  DiffObject must not be empty.

## is_between()

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

inlinenoexcept

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.

## is_visible_at()

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

inlinenoexcept

Current object version is visible at the given timestamp.

Precondition
  DiffObject must not be empty.

## last()

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

inlinenoexcept

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

Precondition
  DiffObject must not be empty.

## next()

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

inlinenoexcept

Get the next object stored.

Precondition
  DiffObject must not be empty.

## prev()

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

inlinenoexcept

Get the previous object stored.

Precondition
  DiffObject must not be empty.

## start_time()

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

inlinenoexcept

Return the timestamp when the current object version was created.

Precondition
  DiffObject must not be empty.

## type()

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

inlinenoexcept

Return the type of the current object.

Precondition
  DiffObject must not be empty.

## version()

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

inlinenoexcept

Return the version of the current object.

Precondition
  DiffObject must not be empty.

## Member Data Documentation

## m_curr

const osmium::OSMObject* osmium::DiffObject::m_curr = nullptr

private

## m_next

const osmium::OSMObject* osmium::DiffObject::m_next = nullptr

private

## m_prev

const osmium::OSMObject* osmium::DiffObject::m_prev = nullptr

private

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

- include/osmium/osm/diff_object.hpp