本文整理汇总了C++中position::lat方法的典型用法代码示例。如果您正苦于以下问题:C++ position::lat方法的具体用法?C++ position::lat怎么用?C++ position::lat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position
的用法示例。
在下文中一共展示了position::lat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/// Initializes the region by the specified corners
///
/// @code
/// a0
/// +--------------+
/// | |
/// | |
/// | |
/// +--------------+ a1
/// @endcode
///
/// @note There is no sorting of coordinates, the positions a0/a1 must
/// already be top/left,bottom/right ordering. There is no automatic
/// way to sort them because of the international date line.
///
/// @param[in] a0 Position top/left
/// @param[in] a1 Position bottom/right
/// @exception std::invalid_argument Positions are not correct. The latitude
/// of the second point <tt>p1</tt> is northerly than <tt>p0</tt>. Or positions
/// are party or fully the same.
///
region::region(const position & a0, const position & a1)
: p0_(a0)
, p1_(a1)
{
if ((a0.lat() == a1.lat()) || (a0.lon() == a1.lon()))
throw std::invalid_argument{"specified region lacks a dimension"};
if (a0.lat() < a1.lat())
throw std::invalid_argument{"specified region is upside down"};
}
示例2: inside
/// Returns true if the specified position is inside (inclusive)
/// the region.
///
/// @param[in] p Point to test.
/// @retval true Point is in the region or on regions boundary.
/// @retval false Point outside the region.
///
bool region::inside(const position & p) const
{
// testing latitude is easy, there is no date line, no wrap-arround
if (p.lat() > p0_.lat())
return false;
if (p.lat() < p1_.lat())
return false;
// testint longitude
// shifted longitudes, now between 0..360 (date line, eastwards)
const double plon_s = 180.0 + p.lon();
const double p0lon_s = 180.0 + p0_.lon();
const double p1lon_s = 180.0 + p1_.lon();
// p is west of p0, but not west enough to reach p1
if ((plon_s < p0lon_s) && (plon_s > p1lon_s))
return false;
return true;
}