File: border.h

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (118 lines) | stat: -rw-r--r-- 3,988 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/***********************************************/
/**
* @file border.h
*
* @brief Borders of an area on sphere/ellipsoid.
*
* @author Torsten Mayer-Guerr
* @date 2004-10-28
*
*/
/***********************************************/

#ifndef __GROOPS_BORDER__
#define __GROOPS_BORDER__

// Latex documentation
#ifdef DOCSTRING_Border
static const char *docstringBorder = R"(
\section{Border}\label{borderType}
With this class you can select one or more region on the surface of the Earth.
In every instance of Border you can choose whether the specific region is excluded
from the overall result with the switch \config{exclude}.
To determine whether a specific point will be used furthermore the following algorithm will be applied:
In a first step all points are selected if first border excludes points otherwise all points excluded.
When every point will be tested for each instance of border from top to bottom.
If the point is not in the selected region nothing happens.
Otherwise it will included or excluded depending on the switch \config{exclude}.

First Example: The border excludes all continental areas.
The result are points on the oceans only.

Second Example: First border describes the continent north america. The next borders
excludes the great lakes and the last border describes Washington island.
In this configuration points are selected if they are inside north america
but not in the area of the great lakes. But if the point is on Washington island
it will be included again.
)";
#endif

/***********************************************/

#include "base/import.h"
#include "config/config.h"

/**
* @defgroup borderGroup Border
* @brief Borders of an area on sphere/ellipsoid.
* @ingroup classesGroup
* The interface is given by @ref Border. */
/// @{

/***** TYPES ***********************************/

class Border;
class BorderBase;
typedef std::shared_ptr<Border> BorderPtr;

/***** CLASS ***********************************/

/** @brief Borders of an area on sphere/ellipsoid.
* An instance of this class can be created with @ref readConfig. */
class Border
{
public:
  /// Constructor.
  Border(Config &config, const std::string &name);

  /// Destructor.
  ~Border();

  /** @brief Is this point inside the area?
  * @param lambda longitude (-PI,PI]
  * @param phi    latitude [PI/2,PI/2] */
  Bool isInnerPoint(Angle lambda, Angle phi) const;

  /** @brief Is this point inside the area?
  * @param point point
  * @param ellipsoid longitude, latitude of point relates to this ellipsoid. */
  Bool isInnerPoint(const Vector3d &point, const Ellipsoid &ellipsoid=Ellipsoid()) const;

  /** @brief creates an derived instance of this class. */
  static BorderPtr create(Config &config, const std::string &name) {return BorderPtr(new Border(config, name));}

private:
  std::vector<BorderBase*> border;
};

/***** FUNCTIONS *******************************/

/** @brief Creates an instance of the class Border.
* Search for a node with @a name in the Config node.
* if @a name is not found the function returns FALSE and a global border is created.
* @param config The config node which includes the node with the options for this class
* @param name Tag name in the config.
* @param[out] border Created class.
* @param mustSet If is MUSTSET and @a name is not found, this function throws an exception instead of returning with FALSE.
* @param defaultValue Ignored at the moment.
* @param annotation Description of the function of this class.
* @relates Border */
template<> Bool readConfig(Config &config, const std::string &name, BorderPtr &border, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation);

/// @}

/***** CLASS ***********************************/

// Internal class
class BorderBase
{
public:
  virtual ~BorderBase() {}

  virtual Bool isInnerPoint(Angle lambda, Angle phi) const = 0;
  virtual Bool isExclude() const = 0;
};

/***********************************************/

#endif /* __GROOPS_BORDER__ */