PointWriter module¶
Module contents¶
-
class
PointWriter
¶ Write points of any type as delimited text.
This class writes a sequence of points to a file in delimited text format. You can control the destination, the delimiter, the record separator (usually newline) and whether or not a header line is written.
The header line contains information about the point’s dimension, coordinate system, object ID and timestamp (for trajectory points) and custom properties (if any).
Public Functions
-
PointWriter
()¶
-
PointWriter
(PointWriter const &other)¶
-
PointWriter
(std::ostream &_output)¶
-
PointWriter &
operator=
(PointWriter const &other)¶
-
bool
operator==
(PointWriter const &other) const¶
-
bool
operator!=
(PointWriter const &other) const¶
-
void
set_output
(std::ostream &out)¶ Set the stream where points will be written.
This can be any std::ostream.
NOTE: You are resposible for ensuring that the stream does not go out of scope until you are done writing points.
- Parameters
[in] out
: Stream where points will be written
-
std::ostream &
output
() const¶ Return the stream where points will be written.
-
void
set_field_delimiter
(string_type const &delim)¶ Set the field delimiter.
This string will be inserted between each field as points are written.
- Parameters
[in] delim
: Delimiter string
-
string_type
field_delimiter
() const¶ Return the field delimiter.
-
void
set_record_delimiter
(string_type const &sep)¶ Set the record separator (end-of-line string)
This string will be written after each point. By default it’s std::endl (the newline string).
- Parameters
[in] sep
: String separator
-
void
set_timestamp_format
(string_type const &format)¶ Set format for writing timestamps.
There are as many ways to write timestamps as there are programs to write them. We have our default (YYYY-MM-DD HH:MM:SS) but sometimes you will need to specify some other format for interoperability.
This method sets a format string for timestamps using the flags in boost::date_time::time_facet. If you do not call it,
- Parameters
[in] format
: Format string for timestamps
-
string_type
timestamp_format
() const¶
-
string_type
record_delimiter
() const¶ Return the record separator (end-of-line string)
-
void
set_quote_character
(string_type const "es)¶ Set the quote character.
This character may be used to enclose a field containing lots of characters that would otherwise need to be escaped. We have to know what it is so that we can escape it ourselves when we encounter the quote character inside fields.
- Parameters
[in] quotes
: Zero or one character to be used as quotation marks
-
string_type
quote_character
() const¶ Return the current quote characters.
-
void
set_write_header
(bool onoff)¶ Set whether or not to write a header.
The header string describes the contents of a point: coordinate system, properties (if any), number of coordinates. By default it will be written at the beginning of a sequence of points. You can turn it off with this function.
- Parameters
[in] onoff
: Boolean flag
-
bool
write_header
() const¶ Return whether or not the header will be written.
-
template<typename
point_iter_type
>
intwrite
(point_iter_type point_begin, point_iter_type point_end)¶
-
void
set_coordinate_precision
(std::size_t num_digits)¶ Set the decimal precision for writing coordinates.
Internally, Tracktable stores coordinates as double-precision floating numbers. It is highly unlikely that trajectory data needs absolutely all of that precision. Since it takes up lots of space when we write data to disk, it is useful to be able to ask for reduced (or increased) precision.
- Parameters
[in] num_digits
: Number of digits of precision
-
std::size_t
coordinate_precision
() const¶
-
void
set_null_value
(string_type const &_null_value)¶ Set the string representation for nulls.
Property values that were never set are considered to hold a null value. This method lets you set how nulls will be written to disk. The default value is the empty string “”.
- Parameters
[in] _null_value
: Desired string representation of nulls
-
string_type
null_value
() const¶
Private Functions
-
void
set_default_configuration
()¶
-
template<typename
point_type
, typenameout_iter_type
>
voidwrite_point_header_tokens
(point_type const &example_point, out_iter_type _output)¶
-
template<typename
point_iter_type
, typenameout_iter_type
>
intwrite_many_points_to_tokens
(point_iter_type point_begin, point_iter_type point_end, out_iter_type _output)¶
-
template<typename
point_type
, typenameout_iter_type
>
voidwrite_point_tokens
(point_type const &point, out_iter_type _output, std::size_t num_properties_expected)¶
-
template<typename
token_iter_type
>
voidwrite_tokens_to_stream
(token_iter_type begin, token_iter_type end)¶
Private Members
-
std::size_t
CoordinatePrecision
¶
-
PropertyConverter
PropertyWriter
¶
-
string_type
TimestampFormat
¶
-
TokenWriter
TokenSink
¶
-
bool
WriteHeader
¶
Friends
-
friend
tracktable::PointWriter::TrajectoryWriter
-