1 /*
2   This file is part of CDO. CDO is a collection of Operators to manipulate and analyse Climate model Data.
3 
4   Author: Uwe Schulzweida
5 
6 */
7 #ifndef GRID_CELL_SEARCH_H
8 #define GRID_CELL_SEARCH_H
9 
10 #include <cstddef>
11 #include "varray.h"
12 
13 extern "C"
14 {
15 #include "lib/yac/grid_cell.h"
16 }
17 
18 enum class CellSearchMethod
19 {
20   spherepart,
21   latbins
22 };
23 
24 struct GridCellSearch
25 {
26   bool in_use = false;
27 
28   CellSearchMethod method{ CellSearchMethod::spherepart };
29 
30   bool is_reg2d = false;
31   size_t dims[2] = { 0 };
32 
33   // reg2d search
34   double gridBoundboxReg2d[4] = { 0 };
35   Varray<double> reg2d_corner_lon, reg2d_corner_lat;
36 
37   void *yacBndCircles = nullptr;
38   void *yacSearch = nullptr;
39 };
40 
41 void grid_cell_search_create_reg_2d(GridCellSearch &gcs, size_t dims[2], const Varray<double> &reg2d_corner_lon,
42                                     const Varray<double> &reg2d_corner_lat);
43 void grid_cell_search_create(GridCellSearch &gcs, size_t numCells, size_t numCellCorners, Varray<double> &cellCornerLon,
44                              Varray<double> &cellCornerLat);
45 void grid_cell_search_delete(GridCellSearch &gcs);
46 size_t do_grid_cell_search(GridCellSearch &gcs, bool isLonLatCell, grid_cell &gridCell, Varray<size_t> &srchAddr);
47 void set_cell_search_method(const char *methodstr);
48 
49 #endif
50