29#include <libdap/BaseType.h>
30#include <libdap/dods-datatypes.h>
32#include <libdap/ServerFunction.h>
34#define STARE_STORAGE_PATH_KEY "FUNCTIONS.stareStoragePath"
35#define STARE_SIDECAR_SUFFIX_KEY "FUNCTIONS.stareSidecarSuffix"
48extern string stare_storage_path;
49extern string stare_sidecar_suffix;
51bool target_in_dataset(
const std::vector<STARE_ArrayIndexSpatialValue> &target_indices,
52 const std::vector<STARE_ArrayIndexSpatialValue> &data_stare_indices);
54unsigned int count(
const std::vector<STARE_ArrayIndexSpatialValue> &target_indices,
55 const std::vector<STARE_ArrayIndexSpatialValue> &dataset_indices,
bool all_target_matches =
false);
58void stare_subset_array_helper(vector<T> &result_data,
const vector<T> &src_data,
59 const vector<STARE_ArrayIndexSpatialValue> &target_indices,
60 const vector<STARE_ArrayIndexSpatialValue> &dataset_indices);
64 std::vector<libdap::dods_int32> row_indices;
65 std::vector<libdap::dods_int32> col_indices;
67 std::vector<STARE_ArrayIndexSpatialValue> stare_indices;
68 std::vector<STARE_ArrayIndexSpatialValue> target_indices;
71 stare_matches(std::vector<libdap::dods_int32> row, std::vector<libdap::dods_int32> col,
72 std::vector<STARE_ArrayIndexSpatialValue> si, std::vector<STARE_ArrayIndexSpatialValue> ti)
73 : row_indices(std::move(row)), col_indices(std::move(col)), stare_indices(std::move(si)),
74 target_indices(std::move(ti)) {}
78 void add(libdap::dods_int32 row, libdap::dods_int32 col, STARE_ArrayIndexSpatialValue si, STARE_ArrayIndexSpatialValue ti) {
79 row_indices.push_back(row);
80 col_indices.push_back(col);
81 stare_indices.push_back(si);
82 target_indices.push_back(ti);
88unique_ptr<stare_matches> stare_subset_helper(
const std::vector<STARE_ArrayIndexSpatialValue> &target_indices,
89 const std::vector<STARE_ArrayIndexSpatialValue> &dataset_indices,
90 size_t row,
size_t cols);
96 friend class StareFunctionsTest;
100 setName(
"stare_intersection");
101 setDescriptionString(
102 "The stare_intersection: Returns 1 if the coverage of the current dataset includes any of the given STARE indices, 0 otherwise.");
104 "stare_intersection(var, STARE index [, STARE index ...]) | stare_intersection(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
105 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_intersection");
106 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_intersection");
118 friend class StareFunctionsTest;
122 setName(
"stare_count");
123 setDescriptionString(
124 "The stare_count: Returns the number of the STARE indices that are included in the coverage of this dataset.");
126 "stare_count(var, STARE index [, STARE index ...]) | stare_count(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
127 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_count");
128 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_count");
140 friend class StareFunctionsTest;
144 setName(
"stare_subset");
145 setDescriptionString(
146 "The stare_subset: Returns the set of the STARE indices that are included in the coverage of this dataset.");
147 setUsageString(
"stare_subset(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
148 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_subset");
149 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_subset");
159 static libdap::BaseType *stare_subset_array_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr);
161 friend class StareFunctionsTest;
165 setName(
"stare_subset_array");
166 setDescriptionString(
167 "The stare_subset: Returns a masked copy of 'var' for the subset given the set of STARE indices that are included in the coverage of this dataset.");
168 setUsageString(
"stare_subset_array(var, mask-val, $UInt64(<size hint>:STARE index [, STARE index ...]))");
169 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_subset_array");
170 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_subset_array");
171 setFunction(stare_subset_array_dap4_function);
178 static void build_masked_data(libdap::Array *dependent_var,
179 const std::vector<STARE_ArrayIndexSpatialValue> &dep_var_stare_indices,
180 const std::vector<STARE_ArrayIndexSpatialValue> &target_s_indices, T mask_value,
181 unique_ptr<libdap::Array> &result);
191 point(
double lat_,
double lon_) : lat(lat_), lon(lon_) {}
194STARE_SpatialIntervals stare_box_helper(
const vector<point> &points,
int resolution = 6);
195STARE_SpatialIntervals stare_box_helper(
const point &top_left,
const point &bottom_right,
int resolution = 6);
199 static libdap::BaseType *stare_box_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr);
201 friend class StareFunctionsTest;
205 setName(
"stare_box");
206 setDescriptionString(
207 "The stare_box() function: Returns a STARE cover for the region within the four lat/lon corner points.");
208 setUsageString(
"stare_box(tl_lat, tl_lon, br_lat, br_lon) or stare_box(p1_lat, p1_lon, ..., p4_lat, p4_lon)");
209 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_box");
210 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_box");
211 setFunction(stare_box_dap4_function);
static libdap::BaseType * stare_count_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr)
Count the number of STARE indices in the arg that overlap the indices of this dataset.
static libdap::BaseType * stare_intersection_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr)
Return true/false indicating that the given stare indices intersect the variables.
static libdap::BaseType * stare_subset_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr)
For the given target STARE indices, return the overlapping dataset X, Y, and STARE indices.
Hold the result from the subset helper function as a collection of vectors.
friend std::ostream & operator<<(std::ostream &out, const stare_matches &m)
Write a collection of STARE Matches to an ostream.