# pdal::BOX2D¶

class BOX2D

BOX2D represents a two-dimensional box with double-precision bounds.

Subclassed by pdal::BOX3D

Public Functions

BOX2D()

Construct an “empty” bounds box.

BOX2D(double minx, double miny, double maxx, double maxy)

Construct and initialize a bounds box.

Parameters
• minx: Minimum X value.

• miny: Minimum Y value.

• maxx: Maximum X value.

• maxy: Maximum Y value.

bool empty() const

Determine whether a bounds box has not had any bounds set.

Return

Whether the bounds box is empty.

bool valid() const

Determine whether a bounds box has had any bounds set.

Return

Whether the bounds box is valid.

void clear()

Clear the bounds box to an empty state.

BOX2D &grow(double x, double y)

Expand the bounds of the box to include the specified point.

Parameters
• x: X point location.

• y: Y point location.

BOX2D &grow(double dist)

Expand the bounds of the box in all directions by a specified amount.

Parameters
• dist: Distance by which to expand the box.

bool contains(double x, double y) const

Determine if a bounds box contains a point.

Return

Whether both dimensions are equal to or less than the maximum box values and equal to or more than the minimum box values.

Parameters
• x: X dimension value.

• y: Y dimension value.

bool equal(const BOX2D &other) const

Determine if the bounds of this box are the same as that of another box.

Empty bounds boxes are always equal.

Return

true if the provided box has equal limits to this box, false otherwise.

Parameters
• other: Bounds box to check for equality.

bool operator==(BOX2D const &other) const

Determine if the bounds of this box are the same as that of another box.

Empty bounds boxes are always equal.

Return

true if the provided box has equal limits to this box, false otherwise.

Parameters
• other: Bounds box to check for equality.

bool operator!=(BOX2D const &other) const

Determine if the bounds of this box are different from that of another box.

Empty bounds boxes are never unequal.

Return

true if the provided box has limits different from this box, false otherwise.

Parameters
• other: Bounds box to check for inequality.

BOX2D &grow(const BOX2D &other)

Expand this box to contain another box.

Parameters
• other: Box that this box should contain.

void clip(const BOX2D &other)

Clip this bounds box by another so it will be contained by the other box.

Parameters
• other: Clipping box for this box.

bool contains(const BOX2D &other) const

Determine if another bounds box is contained in this bounds box.

Equal limits are considered to be contained.

Return

true if the provided box is contained in this box, false otherwise.

Parameters
• other: Bounds box to check for containment.

bool overlaps(const BOX2D &other) const

Determine if another box overlaps this box.

Return

Whether the provided box overlaps this box.

Parameters
• other: Box to test for overlap.

std::string toBox(uint32_t precision = 8) const

Convert this box to a string suitable for use in SQLite.

Return

String format of this box.

Parameters
• precision: Precision for output [default: 8]

std::string toWKT(uint32_t precision = 8) const

Convert this box to a well-known text string.

Return

String format of this box.

Parameters
• precision: Precision for output [default: 8]

std::string toGeoJSON(uint32_t precision = 8) const

Convert this box to a GeoJSON text string.

Return

String format of this box.

Parameters
• precision: Precision for output [default: 8]

void parse(const std::string &s, std::string::size_type &pos)

Parse a string as a BOX2D.

Parameters
• s: String representation of the box.

• pos: Position in the string at which to start parsing. On return set to parsing end position.

Public Members

double minx

Minimum X value.

double maxx

Maximum X value.

double miny

Minimum Y value.

double maxy

Maximum Y value.

Public Static Functions

const BOX2D &getDefaultSpatialExtent()

Return a staticly-allocated Bounds extent that represents infinity.

Return

A bounds box with infinite bounds,

struct error : public runtime_error

Public Functions

error(const std::string &err)
class BOX3D : private pdal::BOX2D

BOX3D represents a three-dimensional box with double-precision bounds.

Public Functions

BOX3D()

Clear the bounds box to an empty state.

BOX3D(const BOX3D &box)
BOX3D &operator=(const BOX3D &box)
BOX3D(const BOX2D &box)
BOX3D(double minx, double miny, double minz, double maxx, double maxy, double maxz)

Construct and initialize a bounds box.

Parameters
• minx: Minimum X value.

• miny: Minimum Y value.

• minx: Minimum Z value.

• maxx: Maximum X value.

• maxy: Maximum Y value.

• maxz: Maximum Z value.

bool empty() const

Determine whether a bounds box has not had any bounds set (is in a state as if default-constructed).

Return

Whether the bounds box is empty.

bool valid() const

Determine whether a bounds box has had any bounds set.

Return

if the bounds box is not empty

BOX3D &grow(double x, double y, double z)

Expand the bounds of the box if a value is less than the current minimum or greater than the current maximum.

If the bounds box is currently empty, both minimum and maximum box bounds will be set to the provided value.

Parameters
• x: X dimension value.

• y: Y dimension value.

• z: Z dimension value.

void clear()

Clear the bounds box to an empty state.

bool contains(double x, double y, double z) const

Determine if a bounds box contains a point.

Return

Whether both dimensions are equal to or less than the maximum box values and equal to or more than the minimum box values.

Parameters
• x: X dimension value.

• y: Y dimension value.

• z: Z dimension value.

bool contains(const BOX3D &other) const

Determine if another bounds box is contained in this bounds box.

Equal limits are considered to be contained.

Return

true if the provided box is contained in this box, false otherwise.

Parameters
• other: Bounds box to check for containment.

bool equal(const BOX3D &other) const

Determine if the bounds of this box are the same as that of another box.

Empty bounds boxes are always equal.

Return

true if the provided box has equal limits to this box, false otherwise.

Parameters
• other: Bounds box to check for equality.

bool operator==(BOX3D const &rhs) const

Determine if the bounds of this box are the same as that of another box.

Empty bounds boxes are always equal.

Return

true if the provided box has equal limits to this box, false otherwise.

Parameters
• other: Bounds box to check for equality.

bool operator!=(BOX3D const &rhs) const

Determine if the bounds of this box are different from that of another box.

Empty bounds boxes are never unequal.

Return

true if the provided box has limits different from this box, false otherwise.

Parameters
• other: Bounds box to check for inequality.

BOX3D &grow(const BOX3D &other)

Expand this box to contain another box.

Parameters
• other: Box that this box should contain.

BOX3D &grow(double dist)

Expand this box by a specified amount.

Parameters
• dist: Distance by which box should be expanded.

void clip(const BOX3D &other)

Clip this bounds box by another so it will be contained by the other box.

Parameters
• other: Clipping box for this box.

bool overlaps(const BOX3D &other) const

Determine if another box overlaps this box.

Return

Whether the provided box overlaps this box.

Parameters
• other: Box to test for overlap.

BOX2D to2d() const

Convert this box to 2-dimensional bounding box.

Return

Bounding box with Z dimension stripped.

std::string toBox(uint32_t precision = 8) const

Convert this box to a string suitable for use in SQLite.

Return

String format of this box.

Parameters
• precision: Precision for output [default: 8]

std::string toWKT(uint32_t precision = 8) const

Convert this box to a well-known text string.

Return

String format of this box.

Parameters
• precision: Precision for output [default: 8]

void parse(const std::string &s, std::string::size_type &pos)

Parse a string as a BOX3D.

Parameters
• s: String representation of the box.

• pos: Position in the string at which to start parsing. On return set to parsing end position.

Public Members

double minz

Minimum Z value.

double maxz

Maximum Z value.

Public Static Functions

const BOX3D &getDefaultSpatialExtent()

Return a staticly-allocated Bounds extent that represents infinity.

Return

A bounds box with infinite bounds,

struct error : public runtime_error

Public Functions

error(const std::string &err)