GeoDesk for C++
Fast and storage-efficient spatial database engine for OpenStreetMap features
Loading...
Searching...
No Matches
geodesk::Box Class Reference

An axis-aligned bounding box. More...

#include <Box.h>

Public Member Functions

constexpr Box ()
 
constexpr Box (int minX, int minY, int maxX, int maxY)
 
constexpr Box (Coordinate c)
 
bool isSimple () const
 A Box is simple if it is non-empty and does not straddle the Antimeridian.
 
bool intersects (const Box &other) const
 
bool contains (int32_t x, int32_t y) const
 
bool containsSimple (int32_t x, int32_t y) const
 
bool containsSimple (Coordinate c) const
 
bool contains (Coordinate c) const
 
bool containsSimple (const Box &other) const
 Assumes neither box is empty, and neither crosses Antimeridian.
 
bool contains (const Box &other) const
 
int64_t widthSimple () const
 
int64_t height () const
 
double area () const
 
void buffer (int32_t b)
 
Coordinate center () const
 
int minX () const
 
int minY () const
 
int maxX () const
 
int maxY () const
 
double minLon () const
 
double minLat () const
 
double maxLon () const
 
double maxLat () const
 
Coordinate topLeft () const
 
Coordinate bottomRight () const
 
Coordinate topRight () const
 
Coordinate bottomLeft () const
 
void setMinX (int32_t v)
 
void setMinY (int32_t v)
 
void setMaxX (int32_t v)
 
void setMaxY (int32_t v)
 
bool isEmpty () const
 
bool operator== (const Box &other) const
 
bool operator!= (const Box &other) const
 
int32_t & operator[] (size_t index)
 
const int32_t & operator[] (size_t index) const
 
void expandToIncludeSimple (const Box &b)
 
void expandToInclude (Coordinate c)
 
void expandToIncludeX (int32_t x)
 
void setEmpty ()
 
GEODESK_API void format (char *buf) const
 
GEODESK_API std::string toString () const
 

Static Public Member Functions

static constexpr Box ofWorld ()
 Returns a Box that encompasses the entire world.
 
static Box normalizedSimple (Coordinate a, Coordinate b)
 Creates a simple Box regardless of order of coordinates.
 
static Box unitsAroundXY (int32_t d, Coordinate pt)
 
static Box simpleIntersection (const Box &a, const Box &b)
 Returns a Box that represents the intersection of two Box objects.
 
static const BoxsimpleSmaller (const Box &a, const Box &b)
 

Detailed Description

An axis-aligned bounding box.

A Box represents minimum and maximum X and Y coordinates in a Mercator-projected plane. It can straddle the Antimeridian (in which case minX is larger than maxX). A Box can also be empty (in which case minY is larger than maxY).

A Box is considered simple if it is non-empty and does not straddle the Antimeridian (i.e. maxX >= minX && maxY >= minY). Box methods with Simple in their name assume that a Box is simple, allowing a more efficient implementation (but return an invalid result in case the Box is not).

Constructor & Destructor Documentation

◆ Box() [1/3]

geodesk::Box::Box ( )
inlineconstexpr

◆ Box() [2/3]

geodesk::Box::Box ( int minX,
int minY,
int maxX,
int maxY )
inlineconstexpr

◆ Box() [3/3]

geodesk::Box::Box ( Coordinate c)
inlineconstexpr

Member Function Documentation

◆ area()

double geodesk::Box::area ( ) const
inline

◆ bottomLeft()

Coordinate geodesk::Box::bottomLeft ( ) const
inline

◆ bottomRight()

Coordinate geodesk::Box::bottomRight ( ) const
inline

◆ buffer()

void geodesk::Box::buffer ( int32_t b)
inline

◆ center()

Coordinate geodesk::Box::center ( ) const
inline

◆ contains() [1/3]

bool geodesk::Box::contains ( const Box & other) const
inline

◆ contains() [2/3]

bool geodesk::Box::contains ( Coordinate c) const
inline

◆ contains() [3/3]

bool geodesk::Box::contains ( int32_t x,
int32_t y ) const
inline

◆ containsSimple() [1/3]

bool geodesk::Box::containsSimple ( const Box & other) const
inline

Assumes neither box is empty, and neither crosses Antimeridian.

◆ containsSimple() [2/3]

bool geodesk::Box::containsSimple ( Coordinate c) const
inline

◆ containsSimple() [3/3]

bool geodesk::Box::containsSimple ( int32_t x,
int32_t y ) const
inline

◆ expandToInclude()

void geodesk::Box::expandToInclude ( Coordinate c)
inline

◆ expandToIncludeSimple()

void geodesk::Box::expandToIncludeSimple ( const Box & b)
inline

◆ expandToIncludeX()

void geodesk::Box::expandToIncludeX ( int32_t x)
inline

◆ format()

GEODESK_API void geodesk::Box::format ( char * buf) const

◆ height()

int64_t geodesk::Box::height ( ) const
inline

◆ intersects()

bool geodesk::Box::intersects ( const Box & other) const
inline

◆ isEmpty()

bool geodesk::Box::isEmpty ( ) const
inline

◆ isSimple()

bool geodesk::Box::isSimple ( ) const
inline

A Box is simple if it is non-empty and does not straddle the Antimeridian.

◆ maxLat()

double geodesk::Box::maxLat ( ) const
inline

◆ maxLon()

double geodesk::Box::maxLon ( ) const
inline

◆ maxX()

int geodesk::Box::maxX ( ) const
inline

◆ maxY()

int geodesk::Box::maxY ( ) const
inline

◆ minLat()

double geodesk::Box::minLat ( ) const
inline

◆ minLon()

double geodesk::Box::minLon ( ) const
inline

◆ minX()

int geodesk::Box::minX ( ) const
inline

◆ minY()

int geodesk::Box::minY ( ) const
inline

◆ normalizedSimple()

static Box geodesk::Box::normalizedSimple ( Coordinate a,
Coordinate b )
inlinestatic

Creates a simple Box regardless of order of coordinates.

◆ ofWorld()

static constexpr Box geodesk::Box::ofWorld ( )
inlinestaticconstexpr

Returns a Box that encompasses the entire world.

◆ operator!=()

bool geodesk::Box::operator!= ( const Box & other) const
inline

◆ operator==()

bool geodesk::Box::operator== ( const Box & other) const
inline

◆ operator[]() [1/2]

int32_t & geodesk::Box::operator[] ( size_t index)
inline

◆ operator[]() [2/2]

const int32_t & geodesk::Box::operator[] ( size_t index) const
inline

◆ setEmpty()

void geodesk::Box::setEmpty ( )
inline

◆ setMaxX()

void geodesk::Box::setMaxX ( int32_t v)
inline

◆ setMaxY()

void geodesk::Box::setMaxY ( int32_t v)
inline

◆ setMinX()

void geodesk::Box::setMinX ( int32_t v)
inline

◆ setMinY()

void geodesk::Box::setMinY ( int32_t v)
inline

◆ simpleIntersection()

static Box geodesk::Box::simpleIntersection ( const Box & a,
const Box & b )
inlinestatic

Returns a Box that represents the intersection of two Box objects.

This method assumes both are non-empty. Returns an empty Box if the boxes don't intersect.

◆ simpleSmaller()

static const Box & geodesk::Box::simpleSmaller ( const Box & a,
const Box & b )
inlinestatic

◆ topLeft()

Coordinate geodesk::Box::topLeft ( ) const
inline

◆ topRight()

Coordinate geodesk::Box::topRight ( ) const
inline

◆ toString()

GEODESK_API std::string geodesk::Box::toString ( ) const

◆ unitsAroundXY()

static Box geodesk::Box::unitsAroundXY ( int32_t d,
Coordinate pt )
inlinestatic

◆ widthSimple()

int64_t geodesk::Box::widthSimple ( ) const
inline

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