CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CartoTypeCore::CoordSet Class Reference

#include <cartotype_base.h>

Inheritance diagram for CartoTypeCore::CoordSet:
CartoTypeCore::CoordPair CartoTypeCore::CoordSetOfTwoPoints CartoTypeCore::WritableCoordSet

Public Member Functions

 CoordSet (const double *aX, const double *aY, size_t aCount) noexcept
 
 CoordSet (const double *aCoordArray, size_t aCount) noexcept
 
template<class point_t >
 CoordSet (const point_t *aPointArray, size_t aCount) noexcept
 
template<class point_t >
 CoordSet (const std::vector< point_t > &aPointArray) noexcept
 
double X (size_t aIndex) const noexcept
 
double Y (size_t aIndex) const noexcept
 
PointFP Point (size_t aIndex) const noexcept
 
size_t Count () const noexcept
 
double DistanceFromPoint (bool aIsPolygon, double aX, double aY, double &aNearestX, double &aNearestY) const noexcept
 
bool PolygonContains (double aX, double aY) const noexcept
 

Protected Member Functions

constexpr CoordSet () noexcept
 

Protected Attributes

const double * m_x { nullptr }
 
const double * m_y { nullptr }
 
size_t m_stride { 0 }
 
size_t m_count { 0 }
 

Detailed Description

A non-owned ordered set of 2D coordinates accessed via pointers to the first X and first Y coordinate.

Constructor & Destructor Documentation

◆ CoordSet() [1/5]

CartoTypeCore::CoordSet::CoordSet ( const double *  aX,
const double *  aY,
size_t  aCount 
)
inlinenoexcept

Creates a coordinate set from two separate contiguous arrays of points. aX points to a contiguous array of X coordinates. aY points to a contiguous array of Y coordinates. aCount is the number of coordinate pairs.

◆ CoordSet() [2/5]

CartoTypeCore::CoordSet::CoordSet ( const double *  aCoordArray,
size_t  aCount 
)
inlinenoexcept

Creates a coordinate set from an array of aCount numbers, arranged in x,y pairs; aCount must be an even number.

◆ CoordSet() [3/5]

template<class point_t >
CartoTypeCore::CoordSet::CoordSet ( const point_t *  aPointArray,
size_t  aCount 
)
inlinenoexcept

Creates a coordinate set from an array of aCount point objects.

◆ CoordSet() [4/5]

template<class point_t >
CartoTypeCore::CoordSet::CoordSet ( const std::vector< point_t > &  aPointArray)
inlinenoexcept

Creates a coordinate set from a vector of point objects.

◆ CoordSet() [5/5]

constexpr CartoTypeCore::CoordSet::CoordSet ( )
inlineconstexprprotectednoexcept

Creates an empty coordinate set.

Member Function Documentation

◆ Count()

size_t CartoTypeCore::CoordSet::Count ( ) const
inlinenoexcept

Returns the number of points in the coordinate set.

◆ DistanceFromPoint()

double CartoTypeCore::CoordSet::DistanceFromPoint ( bool  aIsPolygon,
double  aX,
double  aY,
double &  aNearestX,
double &  aNearestY 
) const
noexcept

Finds the distance from a point to a set of coordinates treated as either a line or a polygon.

This function ignores curves. It treats the contour as a series of straight lines.

If the contour is open (aIsPolygon is true) the distance is to the nearest point on a line segment. If the contour is closed (aIsPolygon is false) the distance is zero if the point is inside, otherwise it is the distance to the nearest point on an edge.

Use aNearestX and aNearestY to return the coordinates of the nearest point on the contour, or the original point if the contour is closed and the point is inside.

If the contour is empty return DBL_MAX.

◆ Point()

PointFP CartoTypeCore::CoordSet::Point ( size_t  aIndex) const
inlinenoexcept

Returns the point at a specified index.

◆ PolygonContains()

bool CartoTypeCore::CoordSet::PolygonContains ( double  aX,
double  aY 
) const
noexcept

Return true if a polygon defined by a list of coordinates contains the point (aX,aY).

◆ X()

double CartoTypeCore::CoordSet::X ( size_t  aIndex) const
inlinenoexcept

Returns the X coordinate at a specified index.

◆ Y()

double CartoTypeCore::CoordSet::Y ( size_t  aIndex) const
inlinenoexcept

Returns the Y coordinate at a specified index.

Member Data Documentation

◆ m_count

size_t CartoTypeCore::CoordSet::m_count { 0 }
protected

The number of points (pairs of coordinates).

◆ m_stride

size_t CartoTypeCore::CoordSet::m_stride { 0 }
protected

The distance in bytes between successive X or Y coordinates.

◆ m_x

const double* CartoTypeCore::CoordSet::m_x { nullptr }
protected

A pointer to the first X coordinate.

◆ m_y

const double* CartoTypeCore::CoordSet::m_y { nullptr }
protected

A pointer to the first Y coordinate.


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