Gridpp 0.7.0
A post-processing library for gridded weather forecasts
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | List of all members
gridpp::KDTree Class Reference

#include <gridpp.h>

Classes

struct  is_not_equal
 
struct  within_radius
 

Public Member Functions

ivec get_closest_neighbours (float lat, float lon, int num, bool include_match=true) const
 Find a set of nearest points. More...
 
CoordinateType get_coordinate_type () const
 
vec get_lats () const
 
vec get_lons () const
 
int get_nearest_neighbour (float lat, float lon, bool include_match=true) const
 Find single nearest points. More...
 
ivec get_neighbours (float lat, float lon, float radius, bool include_match=true) const
 Find all points with a radius. More...
 
ivec get_neighbours_with_distance (float lat, float lon, float radius, vec &distances, bool include_match=true) const
 Find all points with a radius. More...
 
int get_num_neighbours (float lat, float lon, float radius, bool include_match=true) const
 Find the number of points within a radius. More...
 
const vecget_x () const
 
const vecget_y () const
 
const vecget_z () const
 
 KDTree (vec lats, vec lons, CoordinateType type=Geodetic)
 
 KDTree (const KDTree &other)
 
 KDTree (CoordinateType type=Geodetic)
 
KDTreeoperator= (KDTree other)
 
int size () const
 

Static Public Member Functions

static float calc_distance (float lat1, float lon1, float lat2, float lon2, CoordinateType type=Geodetic)
 Calculate distance between two coordinates using Haversine function. More...
 
static float calc_distance (const Point &p1, const Point &p2)
 Calculate distance between two points using Haversine function. More...
 
static float calc_distance_fast (float lat1, float lon1, float lat2, float lon2, CoordinateType type=Geodetic)
 Calculate an approximate distance between two coordinates. More...
 
static float calc_straight_distance (float x0, float y0, float z0, float x1, float y1, float z1)
 Calculate straight line distance between two 3D coordinates. More...
 
static float calc_straight_distance (const Point &p1, const Point &p2)
 Calculate straight line distance between two points. More...
 
static float deg2rad (float deg)
 
static float rad2deg (float deg)
 

Protected Types

typedef boost::geometry::model::box< pointbox
 
typedef boost::geometry::model::point< float, 3, boost::geometry::cs::cartesian > point
 
typedef std::pair< point, unsigned > value
 

Protected Attributes

vec mLats
 
vec mLons
 
boost::geometry::index::rtree< value, boost::geometry::index::quadratic< 16 > > mTree
 
CoordinateType mType
 
vec mX
 
vec mY
 
vec mZ
 

Detailed Description

Helper class for Grid and Points representing a tree of points.

Member Typedef Documentation

◆ box

typedef boost::geometry::model::box<point> gridpp::KDTree::box
protected

◆ point

typedef boost::geometry::model::point<float, 3, boost::geometry::cs::cartesian> gridpp::KDTree::point
protected

◆ value

typedef std::pair<point, unsigned> gridpp::KDTree::value
protected

Constructor & Destructor Documentation

◆ KDTree() [1/3]

gridpp::KDTree::KDTree ( vec  lats,
vec  lons,
CoordinateType  type = Geodetic 
)

◆ KDTree() [2/3]

gridpp::KDTree::KDTree ( const KDTree other)

◆ KDTree() [3/3]

gridpp::KDTree::KDTree ( CoordinateType  type = Geodetic)
inline

Member Function Documentation

◆ calc_distance() [1/2]

float gridpp::KDTree::calc_distance ( float  lat1,
float  lon1,
float  lat2,
float  lon2,
CoordinateType  type = Geodetic 
)
static

Calculate distance between two coordinates using Haversine function.

Parameters
lat1Latitude [deg] or y-coordinate [m] for first point
lon1Longitude [deg] or x-coordinate [m] for first point
lat2Latitude [deg] or y-coordinate [m] for second point
lon2Longitude [deg] or x-coordinate [m] for second point
typeCoordinate type for both points
Returns
Distance [m]

◆ calc_distance() [2/2]

float gridpp::KDTree::calc_distance ( const Point p1,
const Point p2 
)
static

Calculate distance between two points using Haversine function.

Parameters
p1First point
p2Second point
Returns
Distance [m]

◆ calc_distance_fast()

float gridpp::KDTree::calc_distance_fast ( float  lat1,
float  lon1,
float  lat2,
float  lon2,
CoordinateType  type = Geodetic 
)
static

Calculate an approximate distance between two coordinates.

Parameters
lat1Latitude [deg] or y-coordinate [m] for first point
lon1Longitude [deg] or x-coordinate [m] for first point
lat2Latitude [deg] or y-coordinate [m] for second point
lon2Longitude [deg] or x-coordinate [m] for second point
typeCoordinate type for both points
Returns
Distance [m]

◆ calc_straight_distance() [1/2]

float gridpp::KDTree::calc_straight_distance ( float  x0,
float  y0,
float  z0,
float  x1,
float  y1,
float  z1 
)
static

Calculate straight line distance between two 3D coordinates.

This is much faster than calc_distance.

Parameters
x0x-coordinate of first point [m]
y0y-coordinate of first point [m]
z0z-coordinate of first point [m]
x1x-coordinate of second point [m]
y1y-coordinate of second point [m]
z1z-coordinate of second point [m]
Returns
Distance [m]

◆ calc_straight_distance() [2/2]

float gridpp::KDTree::calc_straight_distance ( const Point p1,
const Point p2 
)
static

Calculate straight line distance between two points.

This is much faster than calc_distance.

Parameters
p1First point
p2Second point
Returns
Distance [m]

◆ deg2rad()

float gridpp::KDTree::deg2rad ( float  deg)
static

◆ get_closest_neighbours()

ivec gridpp::KDTree::get_closest_neighbours ( float  lat,
float  lon,
int  num,
bool  include_match = true 
) const

Find a set of nearest points.

Parameters
latLatitude of lookup-point
lonLongitude of lookup-point
numNumber of points to find

◆ get_coordinate_type()

CoordinateType gridpp::KDTree::get_coordinate_type ( ) const

◆ get_lats()

vec gridpp::KDTree::get_lats ( ) const

◆ get_lons()

vec gridpp::KDTree::get_lons ( ) const

◆ get_nearest_neighbour()

int gridpp::KDTree::get_nearest_neighbour ( float  lat,
float  lon,
bool  include_match = true 
) const

Find single nearest points.

Parameters
latLatitude of lookup-point
lonLongitude of lookup-point

◆ get_neighbours()

ivec gridpp::KDTree::get_neighbours ( float  lat,
float  lon,
float  radius,
bool  include_match = true 
) const

Find all points with a radius.

Parameters
latLatitude of lookup-point
lonLongitude of lookup-point
radiusLookup radius [m]

◆ get_neighbours_with_distance()

ivec gridpp::KDTree::get_neighbours_with_distance ( float  lat,
float  lon,
float  radius,
vec distances,
bool  include_match = true 
) const

Find all points with a radius.

Parameters
latLatitude of lookup-point
lonLongitude of lookup-point
radiusLookup radius [m]
distancesVector to store separation distances [m]

◆ get_num_neighbours()

int gridpp::KDTree::get_num_neighbours ( float  lat,
float  lon,
float  radius,
bool  include_match = true 
) const

Find the number of points within a radius.

Parameters
latLatitude of lookup-point
lonLongitude of lookup-point
radiusLookup radius [m]

◆ get_x()

const vec & gridpp::KDTree::get_x ( ) const

◆ get_y()

const vec & gridpp::KDTree::get_y ( ) const

◆ get_z()

const vec & gridpp::KDTree::get_z ( ) const

◆ operator=()

gridpp::KDTree & gridpp::KDTree::operator= ( gridpp::KDTree  other)

◆ rad2deg()

float gridpp::KDTree::rad2deg ( float  deg)
static

◆ size()

int gridpp::KDTree::size ( ) const

Member Data Documentation

◆ mLats

vec gridpp::KDTree::mLats
protected

◆ mLons

vec gridpp::KDTree::mLons
protected

◆ mTree

boost::geometry::index::rtree< value, boost::geometry::index::quadratic<16> > gridpp::KDTree::mTree
protected

◆ mType

CoordinateType gridpp::KDTree::mType
protected

◆ mX

vec gridpp::KDTree::mX
protected

◆ mY

vec gridpp::KDTree::mY
protected

◆ mZ

vec gridpp::KDTree::mZ
protected

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