UFO
DistanceCalculator.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 Met Office UK
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #ifndef UFO_UTILS_DISTANCECALCULATOR_H_
9 #define UFO_UTILS_DISTANCECALCULATOR_H_
10 
11 namespace ufo
12 {
13 
14 /// \brief Calculates distances between observations and centres of bins used during thinning.
15 ///
16 /// It is assumed that the location of each point can be expressed in terms of its latitude x1,
17 /// longitude x2 and possibly other *nonspatial* coordinates xi (i >= 3), and that scale factors
18 /// si (i >= 1) are used to make all coordinates dimensionless. The distance between
19 /// two points is given by
20 ///
21 /// distance((x1, x2, x3, x4, ...), (y1, y2, y3, y4, ...), (s1, s2, s3, s4, ...)) = finalise(
22 /// spatialDistanceComponent((x1, x2), (y1, y2), (s1, s2)) @
23 /// nonspatialDistanceComponent(x3, y3, s3) @
24 /// nonspatialDistanceComponent(x4, y4, s4) @ ...),
25 ///
26 /// where @ is the binary operator implemented by combineDistanceComponents(). For example, to
27 /// use the Euclidean norm as the distance function, one would use
28 ///
29 /// spatialDistanceComponent((x1, x2), (y1, y2), (s1, s2)) = (s1*(x1 - y1))**2 + (s2*(x2 - y2))**2
30 /// nonspatialDistanceComponent(x, y, s) = (s*(x - y))**2
31 /// combineDistanceComponents(x, y) = x + y
32 /// finalise(x) = sqrt(x).
34  public:
35  virtual ~DistanceCalculator() {}
36 
37  virtual float spatialDistanceComponent(float obsLatitude, float obsLongitude,
38  float latitudeBinCenter, float longitudeBinCenter,
39  float inverseLatitudeBinWidth,
40  float inverseLongitudeBinWidth) const = 0;
41 
42  virtual float nonspatialDistanceComponent(float obs, float binCenter,
43  float inverseBinWidth) const = 0;
44 
45  virtual float combineDistanceComponents(float componentA, float componentB) const = 0;
46 
47  virtual float finalise(float combinedComponents) const = 0;
48 };
49 
50 } // namespace ufo
51 
52 #endif // UFO_UTILS_DISTANCECALCULATOR_H_
Calculates distances between observations and centres of bins used during thinning.
virtual float nonspatialDistanceComponent(float obs, float binCenter, float inverseBinWidth) const =0
virtual float finalise(float combinedComponents) const =0
virtual float spatialDistanceComponent(float obsLatitude, float obsLongitude, float latitudeBinCenter, float longitudeBinCenter, float inverseLatitudeBinWidth, float inverseLongitudeBinWidth) const =0
virtual float combineDistanceComponents(float componentA, float componentB) const =0
Definition: RunCRTM.h:27