Gridpp 0.6.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

bool convert_coordinates (const vec &lats, const vec &lons, vec &x_coords, vec &y_coords, vec &z_coords) const
 Convert lat/lons to 3D cartesian coordinates with the centre of the earth as the origin. More...
 
bool convert_coordinates (float lat, float lon, float &x_coord, float &y_coord, float &z_coord) const
 Same as above, but convert a single lat/lon to 3D cartesian coordinates. More...
 
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...
 
 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)
 
static float calc_distance (float x0, float y0, float z0, float x1, float y1, float z1)
 
static float calc_distance_fast (float lat1, float lon1, float lat2, float lon2, CoordinateType type=Geodetic)
 
static float calc_distance_fast (const Point &p1, const Point &p2)
 
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
 

Detailed Description

Helper class for Grid and 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

◆ calc_distance() [2/2]

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

◆ calc_distance_fast() [1/2]

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

◆ calc_distance_fast() [2/2]

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

◆ convert_coordinates() [1/2]

bool gridpp::KDTree::convert_coordinates ( const vec lats,
const vec lons,
vec x_coords,
vec y_coords,
vec z_coords 
) const

Convert lat/lons to 3D cartesian coordinates with the centre of the earth as the origin.

Parameters
latsvector of latitudes [deg]
lonsvector of longitudes [deg]
x_coordsvector of x-coordinates [m]
y_coordsvector of y-coordinates [m]
z_coordsvector of z-coordinates [m]

◆ convert_coordinates() [2/2]

bool gridpp::KDTree::convert_coordinates ( float  lat,
float  lon,
float &  x_coord,
float &  y_coord,
float &  z_coord 
) const

Same as above, but convert a single lat/lon to 3D cartesian coordinates.

Parameters
latlatitude [deg]
lonlongitude [deg]
x_coordx-coordinate [m]
y_coordy-coordinate [m]
z_coordz-coordinate [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]

◆ 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

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