atlas
PolygonXY.h
1 /*
2  * (C) Copyright 2013 ECMWF.
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  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <type_traits>
14 
15 #include "atlas/util/Polygon.h"
16 
17 namespace atlas {
18 namespace util {
19 
20 class PartitionPolygon;
21 class PolygonXY;
22 class ListPolygonXY;
23 
24 //------------------------------------------------------------------------------------------------------
25 
27 class PolygonXY : public PolygonCoordinates {
28 public:
29  using Vector = ListPolygonXY;
30 
31  PolygonXY( const PartitionPolygon& );
32 
37  bool contains( const Point2& Pxy ) const override;
38 
39 private:
40  PointLonLat centroid_;
41  double inner_radius_squared_{0};
42  PointLonLat inner_coordinatesMin_;
43  PointLonLat inner_coordinatesMax_;
44 };
45 
46 
47 //------------------------------------------------------------------------------------------------------
48 
51 public:
52  ListPolygonXY( const PartitionPolygons& partition_polygons ) {
53  reserve( partition_polygons.size() );
54  for ( auto& partition_polygon : partition_polygons ) {
55  emplace_back( new PolygonXY( partition_polygon ) );
56  }
57  }
58 };
59 
60 //------------------------------------------------------------------------------------------------------
61 
62 } // namespace util
63 } // namespace atlas
bool contains(const Point2 &Pxy) const override
Point-in-polygon test based on winding number.
Definition: PolygonXY.cc:97
Definition: Polygon.h:159
Definition: Polygon.h:155
Vector of all polygons with functionality to find partition using a KDTree.
Definition: PolygonXY.h:50
Point in longitude-latitude coordinate system.
Definition: Point.h:103
Definition: Polygon.h:98
Implement PolygonCoordinates::contains for a polygon defined in XY space.
Definition: PolygonXY.h:27
Definition: VectorOfAbstract.h:52
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33