MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLEnvelope Class Reference

Detailed Description

Helper class to manage and maintain object extents.

Also allows minor geometric manipulation.

An Envelope is axis aligned.

Public Member Functions

 TSLEnvelope ()
 
 TSLEnvelope (const TSLEnvelope &right)
 
 TSLEnvelope (const TSLCoord &bottomLeft, const TSLCoord &topRight)
 
 TSLEnvelope (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2)
 
 ~TSLEnvelope ()
 
bool operator== (const TSLEnvelope &rhs) const
 
bool operator!= (const TSLEnvelope &rhs) const
 
TSLEnvelopeoperator= (const TSLEnvelope &anotherEnvelope)
 
TSLEnvelopeoperator+= (const TSLCoord &c)
 
TSLEnvelopeoperator+= (const TSLEnvelope &e)
 
const TSLCoordbottomLeft () const
 
TSLCoord centre () const
 
bool contains (const TSLEnvelope &e) const
 
bool containsWithTolerance (const TSLEnvelope &e, TSLTMC tolerance) const
 
bool contains (const TSLCoord &coord) const
 
void corners (const TSLCoord &bottomLeft, const TSLCoord &topRight)
 
void corners (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2)
 
double distance (const TSLEnvelope &envelope) const
 
bool expand (TSLTMC inc)
 
bool expand (TSLTMC xInc, TSLTMC yInc)
 
TSLULong height () const
 
bool inside (const TSLEnvelope &e) const
 
bool intersect (const TSLEnvelope &e) const
 
TSLEnvelope intersection (const TSLEnvelope &other) const
 
bool overlaps (const TSLEnvelope &e) const
 
void reset (const TSLCoord &coord)
 
bool rotate (double angle, TSLTMC cx, TSLTMC cy)
 
bool scale (double scaleOnX, double scaleOnY, const TSLCoord *origin=NULL)
 
bool scale (double scaleParam, const TSLCoord *origin=NULL)
 
double squareDistance (const TSLEnvelope &envelope) const
 
const TSLCoordtopRight () const
 
bool translate (TSLTMC dx, TSLTMC dy)
 
void move (TSLTMC x, TSLTMC y)
 
TSLULong width () const
 
bool within (const TSLEnvelope &e) const
 
bool withinWithTolerance (const TSLEnvelope &e, TSLTMC tolerance) const
 
TSLTMC xMax () const
 
TSLTMC xMin () const
 
TSLTMC yMax () const
 
TSLTMC yMin () const
 

Public Attributes

TSLCoord m_bottomLeft
 
TSLCoord m_topRight
 

Constructor & Destructor Documentation

◆ TSLEnvelope() [1/4]

TSLEnvelope::TSLEnvelope ( )
inline

Class TSLEnvelope

◆ TSLEnvelope() [2/4]

TSLEnvelope::TSLEnvelope ( const TSLEnvelope & right)
inline

◆ TSLEnvelope() [3/4]

TSLEnvelope::TSLEnvelope ( const TSLCoord & bottomLeft,
const TSLCoord & topRight )
inline

Constructor of an Envelope object with specified bounds.

Although the arguments are typically bottom left and top right corners, the x and y values are sorted into the appropriate corner.

Parameters
bottomLeftTSLCoord containing the bottom left corner of the extent.
topRightTSLCoord containing the top right corner of the extent.

◆ TSLEnvelope() [4/4]

TSLEnvelope::TSLEnvelope ( TSLTMC x1,
TSLTMC y1,
TSLTMC x2,
TSLTMC y2 )
inline

Constructor of an Envelope object with specified bounds.

Although the arguments are typically bottom left and top right corners, the x and y values are sorted into the appropriate corner.

Parameters
(x1,y1)Corner of the extent.
(x2,y2)Opposite corner of the extent

◆ ~TSLEnvelope()

TSLEnvelope::~TSLEnvelope ( )
inline

Destructor.

Member Function Documentation

◆ bottomLeft()

const TSLCoord & TSLEnvelope::bottomLeft ( ) const
inline

Query the bottom left corner of the extent.

◆ centre()

TSLCoord TSLEnvelope::centre ( ) const
inline

Returns the centre of the envelope.

◆ contains() [1/2]

bool TSLEnvelope::contains ( const TSLCoord & coord) const
inline

Query if this envelope contains the specified coordinate.

For the purposes of this method, a coordinate is considered contained if it touches the boundary.

Parameters
coordCoordinate to check.
Returns
true if this envelope totally contains the specified coordinate, false otherwise.

◆ contains() [2/2]

bool TSLEnvelope::contains ( const TSLEnvelope & e) const
inline

Query if this envelope contains the specified envelope.

For the purposes of this method, an envelope is considered contained if it touches the boundary.

Parameters
eEnvelope to check.
Returns
true if this envelope totally contains the specified envelope, false otherwise.

◆ containsWithTolerance()

bool TSLEnvelope::containsWithTolerance ( const TSLEnvelope & e,
TSLTMC tolerance ) const
inline

Query if this envelope contains the specified envelope.

For the purposes of this method, an envelope is considered contained if it touches the boundary. The tolerance is used to reduce the size of this envelope (only for the purpose of this check) at both max and min corners.

Parameters
eEnvelope to check.
toleranceA TMC value that this envelope is reduced by.
Returns
true if this envelope totally contains the specified envelope taking into account the tolerance value, false otherwise.

◆ corners() [1/2]

void TSLEnvelope::corners ( const TSLCoord & bottomLeft,
const TSLCoord & topRight )
inline

Sets both corners of the envelope.

Although the arguments are typically bottom left and top right corners, the x and y values are sorted into the appropriate corner.

Parameters
bottomLeftTSLCoord containing the bottom left corner of the extent.
topRightTSLCoord containing the top right corner of the extent.

◆ corners() [2/2]

void TSLEnvelope::corners ( TSLTMC x1,
TSLTMC y1,
TSLTMC x2,
TSLTMC y2 )
inline

Sets both corners of the envelope.

Although the arguments are typically bottom left and top right corners, the x and y values are sorted into the appropriate corner.

Parameters
(x1,y1)Corner of the extent.
(x2,y2)Opposite corner of the extent.

◆ distance()

double TSLEnvelope::distance ( const TSLEnvelope & envelope) const
inline

The method returns the Euclidean distance between this envelope and another TSLEnvelope.

If the envelopes intersect (overlap) then the distance is 0.

Parameters
envelopethe envelope to find the distance too.
Returns
the distance between the closest points.

◆ expand() [1/2]

bool TSLEnvelope::expand ( TSLTMC inc)
inline

Expand envelope in all directions.

Makes the envelope bigger in all directions, by the specified amount. Thus the specific increment will be added to the top right corner values and subtracted from the bottom left corner values.

Parameters
incIncrement, in internal TMC units.

◆ expand() [2/2]

bool TSLEnvelope::expand ( TSLTMC xInc,
TSLTMC yInc )
inline

Expand envelope in all directions, with different factors in X and Y axis.

Makes the envelope bigger in all directions, by the specified amounts. Thus the specific increments will be added to the top right corner values and subtracted from the bottom left corner values.

Parameters
xIncIncrement applied to X axis, in internal TMC units.
yIncIncrement applied to Y axis, in internal TMC units

◆ height()

TSLULong TSLEnvelope::height ( ) const
inline

Query the height of envelope.

This method should be used rather than just taking the difference of yMax and yMin directly since numeric overflow may occur if the values are not converted correctly.

Returns the height of the envelope.

◆ inside()

bool TSLEnvelope::inside ( const TSLEnvelope & e) const
inline

Query if the specified envelope lies inside this envelope.

For the purposes of this method, an envelope is considered inside if it touches the boundary.

Note: This is a synonym for the 'contains' method.

Parameters
eEnvelope to check.
Returns
true if the envelope, e, lies inside this envelope, false otherwise.

◆ intersect()

bool TSLEnvelope::intersect ( const TSLEnvelope & e) const
inline

Query if envelopes intersect.

For the purposes of this method, an envelope is considered intersecting if it touches the boundary.

Note: This is a synonym for the 'overlaps' method.

Parameters
eEnvelope to check.
Returns
true if this envelope intersects the specified envelope, false otherwise.

◆ intersection()

TSLEnvelope TSLEnvelope::intersection ( const TSLEnvelope & other) const
inline

If this envelope intersects the given envelope, then the intersection of the two (as a TSLEnvelope) is returned. Otherwise an empty envelope is returned.

◆ move()

void TSLEnvelope::move ( TSLTMC x,
TSLTMC y )
inline

Move the envelope to the specified location. The envelope will be clipped to the maximum TMC extent if necessary.

Parameters
xx-position in TMCs
yx-position in TMCs

◆ operator!=()

bool TSLEnvelope::operator!= ( const TSLEnvelope & rhs) const
inline

Compares two envelopes.

Parameters
rhsSource for comparison.
Returns
true if the corners of this envelope are different from that of the rhs envelope, false otherwise.

◆ operator+=() [1/2]

TSLEnvelope & TSLEnvelope::operator+= ( const TSLCoord & c)
inline

Merge with specified coordinate.

Expands this envelope to include the specified coordinate.

Parameters
cCoordinate to include.
Returns
reference to newly updated value.

◆ operator+=() [2/2]

TSLEnvelope & TSLEnvelope::operator+= ( const TSLEnvelope & e)
inline

Merge with specified envelope.

Expands this envelope to include the specified envelope.

Parameters
eEnvelope to include.
Returns
reference to newly updated value.

◆ operator=()

TSLEnvelope & TSLEnvelope::operator= ( const TSLEnvelope & anotherEnvelope)
inline

Assignment operator.

Sets the envelope to be equal to that specified.

Parameters
anotherEnvelopeSource for new corners.
Returns
reference to newly updated value.

◆ operator==()

bool TSLEnvelope::operator== ( const TSLEnvelope & rhs) const
inline

Compares two envelopes.

Parameters
rhsSource for comparison.
Returns
true if the corners of this envelope are the same as that of the rhs envelope, false otherwise.

◆ overlaps()

bool TSLEnvelope::overlaps ( const TSLEnvelope & e) const
inline

Query if envelopes overlap.

For the purposes of this method, an envelope is considered overlapping if it touches the boundary.

Note: This is a synonym for the 'intersect' method.

Parameters
eEnvelope to check.
Returns
true if this envelope intersects the specified envelope, false otherwise.

◆ reset()

void TSLEnvelope::reset ( const TSLCoord & coord)
inline

Resets the envelope to the specified coordinate.

Resets the envelope so that both corners are at the specified point.

Parameters
coordPoint to reset to.

◆ rotate()

bool TSLEnvelope::rotate ( double angle,
TSLTMC cx,
TSLTMC cy )
inline

Rotate the envelope.

Updates an envelope with the extent of its rotated rectangle. The angle specified is in radians, +ve anti-clockwise from the x-axis. Rotates about specified centre.

Parameters
anglethe angle for rotation
cxthe centre x coordinate
cythe centre y coordinate
Returns
true if ok, false if the maths would blow up (ie. if the resultant coordinate would not fit into TMC space.).

◆ scale() [1/2]

bool TSLEnvelope::scale ( double scaleOnX,
double scaleOnY,
const TSLCoord * origin = NULL )
inline

Scales an envelope allowing different scale parameters in x and y.

If origin = NULL, the origin of the scale is the centre of the Envelope.

A scale parameter of 0 is not valid.

Parameters
scaleOnXScale factor for X axis
scaleOnYScale factor for Y axis.
originPosition to scale around, NULL scales around centre.

◆ scale() [2/2]

bool TSLEnvelope::scale ( double scaleParam,
const TSLCoord * origin = NULL )
inline

Scales an envelope equally.

If origin = NULL, the origin of the scale is the centre of the Envelope.

A scale parameter of 0 is not valid.

Parameters
scaleParamScale factor.
originPosition to scale around, NULL scales around centre.

◆ squareDistance()

double TSLEnvelope::squareDistance ( const TSLEnvelope & envelope) const
inline

The method returns the Euclidean square distance between this envelope and another TSLEnvelope.

If the envelopes intersect (overlap) then the distance is 0.

Parameters
envelopethe envelope to find the distance too.
Returns
the square distance between the closest points.

◆ topRight()

const TSLCoord & TSLEnvelope::topRight ( ) const
inline

Query the top right corner of the extent.

◆ translate()

bool TSLEnvelope::translate ( TSLTMC dx,
TSLTMC dy )
inline

Translates the envelope by a delta.

Translates the corners of the envelope by the specified delta values.

Parameters
dxX delta value.
dyY delta value.

◆ width()

TSLULong TSLEnvelope::width ( ) const
inline

Query the width of the envelope.

This method should be used rather than just taking the difference of xMax and xMin directly since numeric overflow may occur if the values are not converted correctly.

Returns
the width of the envelope.

◆ within()

bool TSLEnvelope::within ( const TSLEnvelope & e) const
inline

For the purposes of this method, an envelope is considered within, if it touches the boundary.

Parameters
eEnvelope to check against.
Returns
true if this envelope is totally within the specified envelope, false otherwise.

◆ withinWithTolerance()

bool TSLEnvelope::withinWithTolerance ( const TSLEnvelope & e,
TSLTMC tolerance ) const
inline

For the purposes of this method, an envelope is considered within, if it touches the boundary. The passed envelope is reduced by the size of the tolerance at both max and min corners.

Parameters
eEnvelope to check against.
toleranceA TMC value that the passed envelope is reduced by.
Returns
true if this envelope is totally within the specified envelope plus/minus the tolerance value, false otherwise.

◆ xMax()

TSLTMC TSLEnvelope::xMax ( ) const
inline

Query the maximum X value of the envelope.

◆ xMin()

TSLTMC TSLEnvelope::xMin ( ) const
inline

Query the minimum X value of the envelope.

◆ yMax()

TSLTMC TSLEnvelope::yMax ( ) const
inline

Query the maximum Y value of the envelope.

◆ yMin()

TSLTMC TSLEnvelope::yMin ( ) const
inline

Query the minimum Y value of the envelope.

Member Data Documentation

◆ m_bottomLeft

TSLCoord TSLEnvelope::m_bottomLeft

Data Members for Associations

◆ m_topRight

TSLCoord TSLEnvelope::m_topRight