26 #include <dods-datatypes.h>
31 #include "ServerFunction.h"
42 const string s_index_name =
"Stare_Index";
44 const std::string STARE_STORAGE_PATH_KEY =
"FUNCTIONS.stareStoragePath";
45 const std::string STARE_SIDECAR_SUFFIX_KEY =
"FUNCTIONS.stareSidecarSuffix";
49 extern string stare_storage_path;
50 extern string stare_sidecar_suffix;
52 std::string get_sidecar_file_pathname(
const std::string &pathName,
const string &token =
"_sidecar");
53 void get_sidecar_int32_values(hid_t file,
const std::string &variable, std::vector<libdap::dods_int32> &values);
54 void get_sidecar_uint64_values(hid_t file,
const std::string &variable, std::vector<libdap::dods_uint64> &values);
56 bool target_in_dataset(
const std::vector<libdap::dods_uint64> &targetIndices,
57 const std::vector<libdap::dods_uint64> &dataStareIndices);
58 unsigned int count(
const std::vector<libdap::dods_uint64> &target_indices,
59 const std:: vector<libdap::dods_uint64> &dataset_indices,
bool all_target_matches =
false);
62 void stare_subset_array_helper(vector<T> &result_data,
const vector<T> &src_data,
63 const vector<libdap::dods_uint64> &target_indices,
64 const vector<libdap::dods_uint64> &dataset_indices);
71 point(
int x,
int y): x(x), y(y) {}
72 friend std::ostream & operator << (std::ostream &out,
const point &c);
78 libdap::dods_uint64 stare_index;
80 stare_match(
const point &p, libdap::dods_uint64 si): coord(p), stare_index(si) {}
81 stare_match(
int x,
int y, libdap::dods_uint64 si): coord(x, y), stare_index(si) {}
82 friend std::ostream & operator << (std::ostream &out,
const stare_match &m);
88 std::vector<libdap::dods_int32> x_indices;
89 std::vector<libdap::dods_int32> y_indices;
91 std::vector<libdap::dods_uint64> stare_indices;
92 std::vector<libdap::dods_uint64> target_indices;
95 stare_matches(std::vector<libdap::dods_int32> x,
const std::vector<libdap::dods_int32> y,
96 const std::vector<libdap::dods_uint64> si,
const std::vector<libdap::dods_uint64> ti)
97 : x_indices(std::move(x)), y_indices(std::move(y)), stare_indices(std::move(si)), target_indices(std::move(ti)) {}
101 void add(libdap::dods_int32 x, libdap::dods_int32 y, libdap::dods_uint64 si, libdap::dods_uint64 ti) {
102 x_indices.push_back(x);
103 y_indices.push_back(y);
104 stare_indices.push_back(si);
105 target_indices.push_back(ti);
111 unique_ptr<stare_matches> stare_subset_helper(
const std::vector<libdap::dods_uint64> &target_indices,
112 const std::vector<libdap::dods_uint64> &dataset_indices,
113 const std::vector<int> &dataset_x_coords,
const std::vector<int> &dataset_y_coords);
119 friend class StareFunctionsTest;
123 setName(
"stare_intersection");
124 setDescriptionString(
"The stare_intersection: Returns 1 if the coverage of the current dataset includes any of the given STARE indices, 0 otherwise.");
125 setUsageString(
"stare_intersection(var, STARE index [, STARE index ...]) | stare_intersection(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
126 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_intersection");
127 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_intersection");
140 friend class StareFunctionsTest;
144 setName(
"stare_count");
145 setDescriptionString(
"The stare_count: Returns the number of the STARE indices that are included in the coverage of this dataset.");
146 setUsageString(
"stare_count(var, STARE index [, STARE index ...]) | stare_count(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
147 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_count");
148 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_count");
161 friend class StareFunctionsTest;
165 setName(
"stare_subset");
166 setDescriptionString(
"The stare_subset: Returns the set of the STARE indices that are included in the coverage of this dataset.");
167 setUsageString(
"stare_subset(var, $UInt64(<size hint>:STARE index [, STARE index ...]))");
168 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_subset");
169 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_subset");
180 static libdap::BaseType *stare_subset_array_dap4_function(libdap::D4RValueList *args, libdap::DMR &dmr);
182 friend class StareFunctionsTest;
186 setName(
"stare_subset_array");
187 setDescriptionString(
"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.");
188 setUsageString(
"stare_subset_array(var, mask-val, $UInt64(<size hint>:STARE index [, STARE index ...]))");
189 setRole(
"http://services.opendap.org/dap4/server-side-function/stare_subset_array");
190 setDocUrl(
"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#stare_subset_array");
191 setFunction(stare_subset_array_dap4_function);
199 static void build_masked_data(libdap::Array *dependent_var,
const vector<libdap::dods_uint64> &dep_var_stare_indices,
200 const vector<libdap::dods_uint64> &target_s_indices, unique_ptr<libdap::Array> &result);
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.