28#include <libdap/D4Connect.h>
29#include <libdap/Connect.h>
30#include <libdap/Array.h>
31#include <libdap/Error.h>
36static bool verbose =
false;
37#define VERBOSE(x) do { if (verbose) x; } while(false)
38static bool very_verbose =
false;
39#define VERY_VERBOSE(x) do { if (very_verbose) x; } while(false)
70 vector<unsigned long> x;
71 vector<unsigned long> y;
76 STARE_ArrayIndexSpatialValues s_index;
85 coordinates(vector<float64>latitude, vector<float64>longitude) {
86 assert(latitude.size() == longitude.size());
87 set_size(latitude.size());
89 copy(latitude.begin(), latitude.end(), lat.begin());
90 copy(longitude.begin(), longitude.end(), lon.begin());
97 void set_size(
size_t size) {
102 s_index.resize(size);
111 hsize_t *get_dims() {
return dims.data(); }
113 unsigned long *get_x() {
return x.data(); }
114 unsigned long *get_y() {
return y.data(); }
116 float64 *get_lon() {
return lon.data(); }
117 float64 *get_lat() {
return lat.data(); }
119 STARE_ArrayIndexSpatialValue *get_s_index() {
return s_index.data(); }
130void read_lat_lon_url(
const string &data_url,
const string &lat_name,
const string &lon_name, coordinates *c) {
132 unique_ptr<libdap::Connect> url(
new libdap::Connect(data_url));
134 string latlon_ce = lat_name +
"," + lon_name;
136 std::vector<float> lat;
137 std::vector<float> lon;
139 vector<coord> indexArray;
142 libdap::BaseTypeFactory factory;
143 libdap::DataDDS dds(&factory);
145 VERBOSE(cerr <<
"\n\n\tRequesting data from " << data_url << endl);
148 url->request_data(dds, latlon_ce);
151 libdap::Array *url_lat =
dynamic_cast<libdap::Array *
>(dds.var(lat_name));
152 libdap::Array *url_lon =
dynamic_cast<libdap::Array *
>(dds.var(lon_name));
155 if (url_lat == 0 || url_lon == 0) {
156 throw libdap::Error(
"Expected both lat and lon arrays");
159 if (url_lat->dimensions() != 2) {
160 throw libdap::Error(
"Incorrect latitude dimensions");
163 if (url_lon->dimensions() != 2) {
164 throw libdap::Error(
"Incorrect longitude dimensions");
167 int size_y = url_lat->dimension_size(url_lat->dim_begin());
168 int size_x = url_lat->dimension_size(url_lat->dim_begin() + 1);
170 if (size_y != url_lon->dimension_size(url_lon->dim_begin())
171 || size_x != url_lon->dimension_size(url_lon->dim_begin() + 1)) {
172 throw libdap::Error(
"The size of the latitude and longitude arrays are not the same");
182 c->set_size(url_lat->size());
183 url_lat->value(c->get_lat());
184 url_lon->value(c->get_lon());
186 catch (libdap::Error &e) {
187 cerr <<
"ERROR: " << e.get_error_message() << endl;
191 VERBOSE(cerr <<
"\tsize of lat array: " << c->lat.size() << endl);
192 VERBOSE(cerr <<
"\tsize of lon array: " << c->lon.size() << endl);
206vector<hsize_t> read_lat_lon(
const string &filename,
const string &lat_name,
const string &lon_name,
207 vector<float64> &lat, vector<float64> &lon) {
210 hid_t file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
212 throw Error(
string(
"Could not open the file '").append(filename).append(
"'"), __FILE__, __LINE__);
214 hid_t latDataset = H5Dopen(file, lat_name.c_str(), H5P_DEFAULT);
216 throw Error(
string(
"Could not open the HDF5 dataset '").append(lat_name).append(
"'"), __FILE__,
219 hid_t lonDataset = H5Dopen(file, lon_name.c_str(), H5P_DEFAULT);
221 throw Error(
string(
"Could not open the HDF5 dataset '").append(lon_name).append(
"'"), __FILE__,
227 hid_t dspace = H5Dget_space(latDataset);
229 throw Error(
string(
"Could not open the HDF5 data space for '").append(lat_name).append(
"'"),
232 const int ndims = H5Sget_simple_extent_ndims(dspace);
234 throw Error(
string(
"The latitude variable '").append(lat_name).append(
"' should be a 2D array"),
237 vector<hsize_t> dims(ndims);
241 H5Sget_simple_extent_dims(dspace, dims.data(), NULL);
244 hid_t latFilespace = H5Dget_space(latDataset);
245 if (latFilespace < 0)
246 throw Error(
string(
"Could not open the HDF5 file space for '").append(lat_name).append(
"'"),
249 hid_t lonFilespace = H5Dget_space(lonDataset);
250 if (lonFilespace < 0)
251 throw Error(
string(
"Could not open the HDF5 file space for '").append(lon_name).append(
"'"),
256 hssize_t latSize = H5Sget_select_npoints(latFilespace);
257 VERBOSE(cerr <<
"\n\tlat dataspace size: " << latSize);
258 hssize_t lonSize = H5Sget_select_npoints(lonFilespace);
259 VERBOSE(cerr <<
"\n\tlon dataspace size: " << lonSize << endl);
261 if (latSize != lonSize)
263 string(
"The size of the Latitude and Longitude arrays must be equal in '").append(filename).append(
"'"),
269 hid_t memspace = H5Screate_simple(ndims, dims.data(), NULL);
272 string(
"Could not make an HDF5 memory space while working with '").append(filename).append(
"'"),
277 herr_t status = H5Dread(latDataset, H5T_NATIVE_DOUBLE, memspace, latFilespace, H5P_DEFAULT, lat.data());
279 throw Error(
string(
"Could not read data for '").append(lat_name).append(
"'"), __FILE__, __LINE__);
282 status = H5Dread(lonDataset, H5T_NATIVE_DOUBLE, memspace, lonFilespace, H5P_DEFAULT, lon.data());
284 throw Error(
string(
"Could not read data for '").append(lon_name).append(
"'"), __FILE__, __LINE__);
286 VERBOSE(cerr <<
"\tsize of lat array: " << lat.size() << endl);
287 VERBOSE(cerr <<
"\tsize of lon array: " << lon.size() << endl);
299void read_lat_lon(
const string &filename,
const string &lat_name,
const string &lon_name, coordinates *c) {
302 hid_t file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
304 throw Error(
string(
"Could not open the file '").append(filename).append(
"'"), __FILE__, __LINE__);
306 hid_t latDataset = H5Dopen(file, lat_name.c_str(), H5P_DEFAULT);
308 throw Error(
string(
"Could not open the HDF5 dataset '").append(lat_name).append(
"'"), __FILE__,
311 hid_t lonDataset = H5Dopen(file, lon_name.c_str(), H5P_DEFAULT);
313 throw Error(
string(
"Could not open the HDF5 dataset '").append(lon_name).append(
"'"), __FILE__,
319 hid_t dspace = H5Dget_space(latDataset);
321 throw Error(
string(
"Could not open the HDF5 data space for '").append(lat_name).append(
"'"),
324 const int ndims = H5Sget_simple_extent_ndims(dspace);
326 throw Error(
string(
"The latitude variable '").append(lat_name).append(
"' should be a 2D array"),
329 c->dims.resize(ndims);
333 H5Sget_simple_extent_dims(dspace, c->get_dims(), NULL);
336 hid_t latFilespace = H5Dget_space(latDataset);
337 if (latFilespace < 0)
338 throw Error(
string(
"Could not open the HDF5 file space for '").append(lat_name).append(
"'"),
341 hid_t lonFilespace = H5Dget_space(lonDataset);
342 if (lonFilespace < 0)
343 throw Error(
string(
"Could not open the HDF5 file space for '").append(lon_name).append(
"'"),
348 hssize_t latSize = H5Sget_select_npoints(latFilespace);
349 VERBOSE(cerr <<
"\n\tlat dataspace size: " << latSize);
350 hssize_t lonSize = H5Sget_select_npoints(lonFilespace);
351 VERBOSE(cerr <<
"\n\tlon dataspace size: " << lonSize << endl);
353 if (latSize != lonSize)
355 string(
"The size of the Latitude and Longitude arrays must be equal in '").append(filename).append(
"'"),
358 c->set_size(latSize);
360 hid_t memspace = H5Screate_simple(ndims, c->get_dims(), NULL);
363 string(
"Could not make an HDF5 memory space while working with '").append(filename).append(
"'"),
368 herr_t status = H5Dread(latDataset, H5T_NATIVE_DOUBLE, memspace, latFilespace, H5P_DEFAULT, c->get_lat());
370 throw Error(
string(
"Could not read data for '").append(lat_name).append(
"'"), __FILE__, __LINE__);
373 status = H5Dread(lonDataset, H5T_NATIVE_DOUBLE, memspace, lonFilespace, H5P_DEFAULT, c->get_lon());
375 throw Error(
string(
"Could not read data for '").append(lon_name).append(
"'"), __FILE__, __LINE__);
377 VERBOSE(cerr <<
"\tsize of lat array: " << c->lat.size() << endl);
378 VERBOSE(cerr <<
"\tsize of lon array: " << c->lon.size() << endl);
390unique_ptr< vector<coord> > build_coords(STARE &stare,
const vector<hsize_t> &dims,
391 const vector<float64> &latitude,
const vector<float64> &longitude) {
393 unique_ptr< vector<coord> > coords(
new vector<coord>(latitude.size()));
395 auto lat = latitude.begin();
396 auto lon = longitude.begin();
398 unsigned long long n = 0;
399 for (
unsigned long r = 0; r < dims[0]; ++r) {
400 for (
unsigned long c = 0; c < dims[1]; ++c) {
404 (*coords)[n].lat = *lat;
405 (*coords)[n].lon = *lon;
407 (*coords)[n].s_index = stare.ValueFromLatLonDegrees(*lat, *lon);
409 VERY_VERBOSE(cerr <<
"Coord: " << *lat <<
", " << *lon <<
" -> " << hex << (*coords)[n].s_index << dec << endl);
429unique_ptr<coordinates>
430build_coordinates(STARE &stare,
const vector<hsize_t> &dims,
431 const vector<float64> &latitude,
const vector<float64> &longitude) {
434 unique_ptr<coordinates> c(
new coordinates(latitude, longitude));
438 for (
unsigned long row = 0; row < dims[0]; ++row) {
439 for (
unsigned long col = 0; col < dims[1]; ++col) {
443 c->s_index[n] = stare.ValueFromLatLonDegrees(c->lat[n], c->lon[n]);
445 VERY_VERBOSE(cerr <<
"Coord: " << c->lat[n] <<
", " << c->lon[n] <<
" -> " << hex << c->s_index[n] << dec << endl);
461compute_coordinates(STARE &stare, coordinates *c) {
465 for (
unsigned long row = 0; row < c->dims[0]; ++row) {
466 for (
unsigned long col = 0; col < c->dims[1]; ++col) {
470 c->s_index[n] = stare.ValueFromLatLonDegrees(c->lat[n], c->lon[n]);
472 VERY_VERBOSE(cerr <<
"Coord: " << c->lat[n] <<
", " << c->lon[n] <<
" -> " << hex << c->s_index[n] << dec << endl);
486STARE_ArrayIndexSpatialValue
487set_s_index_resolution(STARE &stare, STARE_ArrayIndexSpatialValue target, STARE_ArrayIndexSpatialValue adjacent) {
488 static EmbeddedLevelNameEncoding lj;
489 int lvl = stare.cmpSpatialResolutionEstimateI(target, adjacent);
490 return (target & ~lj.levelMaskSciDB) | lvl;
513compute_coordinates_resolution(STARE &stare, coordinates *c) {
514 EmbeddedLevelNameEncoding lj;
517 unsigned long max_row = c->dims[0];
518 for (
unsigned long row = 0; row < max_row; ++row) {
520 unsigned long max_col = c->dims[1];
521 unsigned long mid_col = max_col / 2;
522 for (
unsigned long col = 0; col < mid_col; ++col) {
524 c->s_index[n] = set_s_index_resolution(stare, c->s_index[n], c->s_index[n+1]);
527 for (
unsigned long col = mid_col; col < max_col; ++col) {
529 c->s_index[n] = set_s_index_resolution(stare, c->s_index[n], c->s_index[n-1]);
545void writeHDF5(
const string &filename,
string tmpStorage, vector<coord> *coords) {
549 hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
551 H5Pset_libver_bounds (fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18);
553 H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST);
557 hid_t file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
561 hsize_t coords_size = coords->size();
562 hid_t dataspace = H5Screate_simple(1 , &coords_size, NULL);
574 VERBOSE(cerr <<
"\nCreating datatypes: x, y, lat, lon, stareIndex -> ");
576 dataTypes = H5Tcreate (H5T_COMPOUND,
sizeof(coords));
577 H5Tinsert(dataTypes,
"x", HOFFSET(coords, x), H5T_NATIVE_INT);
578 H5Tinsert(dataTypes,
"y", HOFFSET(coords, y), H5T_NATIVE_INT);
579 H5Tinsert(dataTypes,
"lat", HOFFSET(coords, lat), H5T_NATIVE_FLOAT);
580 H5Tinsert(dataTypes,
"lon", HOFFSET(coords, lon), H5T_NATIVE_FLOAT);
581 H5Tinsert(dataTypes,
"stareIndex", HOFFSET(coords, stareIndex), H5T_NATIVE_INT);
586 const char *datasetName =
"StareData";
587 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
588 dataset = H5Dcreate2(file, datasetName, dataTypes, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
590 VERBOSE(cerr <<
"Writing data to dataset" << endl);
591 H5Dwrite(dataset, dataTypes, H5S_ALL, H5S_ALL, H5P_DEFAULT, keyVals.data());
597 const char *datasetName =
"X";
598 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
599 hid_t datasetX = H5Dcreate2(file, datasetName, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
602 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
603 hid_t datasetY = H5Dcreate2(file, datasetName, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
605 datasetName =
"Latitude";
606 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
608 hid_t datasetLat = H5Dcreate2(file, datasetName, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
610 datasetName =
"Longitude";
611 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
612 hid_t datasetLon = H5Dcreate2(file, datasetName, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
614 datasetName =
"Stare Index";
615 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
616 hid_t datasetStare = H5Dcreate2(file, datasetName, H5T_NATIVE_INT64, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
622 vector<unsigned long> xArray;
623 vector<unsigned long> yArray;
624 vector<float64> latArray;
625 vector<float64> lonArray;
626 vector<uint64> s_indices;
629 xArray.push_back(i->x);
630 yArray.push_back(i->y);
631 latArray.push_back(i->lat);
632 lonArray.push_back(i->lon);
633 s_indices.push_back(i->s_index);
636 VERBOSE(cerr <<
"Writing data to dataset" << endl);
637 H5Dwrite(datasetX, H5T_NATIVE_ULONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, xArray.data());
638 H5Dwrite(datasetY, H5T_NATIVE_ULONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, yArray.data());
639 H5Dwrite(datasetLat, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, latArray.data());
640 H5Dwrite(datasetLon, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, lonArray.data());
641 H5Dwrite(datasetStare, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, s_indices.data());
649 VERBOSE(cerr <<
"\nData written to file: " << filename << endl);
653 if (tmpStorage.empty())
654 tmpStorage =
"/tmp/" + filename;
656 tmpStorage = tmpStorage + filename;
658 rename(filename.c_str(), tmpStorage.c_str());
659 VERBOSE(cerr <<
"Data moved to: " << tmpStorage << endl);
671void writeHDF5(
const string &filename,
string tmp_storage, coordinates *c) {
675 hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
677 H5Pset_libver_bounds (fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18);
679 H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST);
683 hid_t file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
687 hsize_t coords_size = c->x.size();
688 hid_t dataspace = H5Screate_simple(1 , &coords_size, NULL);
700 VERBOSE(cerr <<
"\nCreating datatypes: x, y, lat, lon, stareIndex -> ");
702 dataTypes = H5Tcreate (H5T_COMPOUND,
sizeof(coords));
703 H5Tinsert(dataTypes,
"x", HOFFSET(coords, x), H5T_NATIVE_INT);
704 H5Tinsert(dataTypes,
"y", HOFFSET(coords, y), H5T_NATIVE_INT);
705 H5Tinsert(dataTypes,
"lat", HOFFSET(coords, lat), H5T_NATIVE_FLOAT);
706 H5Tinsert(dataTypes,
"lon", HOFFSET(coords, lon), H5T_NATIVE_FLOAT);
707 H5Tinsert(dataTypes,
"stareIndex", HOFFSET(coords, stareIndex), H5T_NATIVE_INT);
712 const char *datasetName =
"StareData";
713 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
714 dataset = H5Dcreate2(file, datasetName, dataTypes, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
716 VERBOSE(cerr <<
"Writing data to dataset" << endl);
717 H5Dwrite(dataset, dataTypes, H5S_ALL, H5S_ALL, H5P_DEFAULT, keyVals.data());
723 const char *datasetName =
"X";
724 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
725 hid_t datasetX = H5Dcreate2(file, datasetName, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
728 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
729 hid_t datasetY = H5Dcreate2(file, datasetName, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
731 datasetName =
"Latitude";
732 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
734 hid_t datasetLat = H5Dcreate2(file, datasetName, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
736 datasetName =
"Longitude";
737 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
738 hid_t datasetLon = H5Dcreate2(file, datasetName, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
740 datasetName =
"Stare_Index";
741 VERBOSE(cerr <<
"Creating dataset: " << datasetName <<
" -> ");
742 hid_t datasetStare = H5Dcreate2(file, datasetName, H5T_NATIVE_INT64, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
748 VERBOSE(cerr <<
"Writing data to dataset" << endl);
749 H5Dwrite(datasetX, H5T_NATIVE_ULONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(c->x[0]));
750 H5Dwrite(datasetY, H5T_NATIVE_ULONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(c->y[0]));
751 H5Dwrite(datasetLat, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(c->lat[0]));
752 H5Dwrite(datasetLon, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(c->lon[0]));
753 H5Dwrite(datasetStare, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(c->s_index[0]));
761 VERBOSE(cerr <<
"\nData written to file: " << filename << endl);
765 if (tmp_storage.empty())
766 tmp_storage =
"/tmp/" + filename;
768 tmp_storage = tmp_storage + filename;
770 rename(filename.c_str(), tmp_storage.c_str());
771 VERBOSE(cerr <<
"Data moved to: " << tmp_storage << endl);
775 cerr <<
"build_sidecar [options] <filename> <latitude-name> <longitude-name>" << endl;
776 cerr <<
"-o output file: \tOutput the STARE data to the given output file" << endl;
777 cerr <<
"-v|V verbose/very verbose" << endl;
778 cerr <<
"-t transfer location: \tTransfer the generated sidecar file to the given directory" << endl;
779 cerr <<
"-b STARE Build Level: \tHigher levels -> longer initialization time. (default is 5)" << endl;
780 cerr <<
"-s STARE default Level: \tHigher levels -> finer resolution. (default is 27)" << endl;
781 cerr <<
"-a Algotithm: \t1, 2 or 3 (default is 3)" << endl;
782 cerr <<
"-r Include resolution information in the indices. Works for algorithm 2 and 3 only" << endl;
786get_sidecar_filename(
const string &dataUrl,
const string &suffix =
"_sidecar.h5") {
794 size_t granulePos = dataUrl.find_last_of(
'/');
795 string granuleName = dataUrl.substr(granulePos + 1);
796 size_t findDot = granuleName.find_last_of(
'.');
797 return granuleName.substr(0, findDot).append(suffix);
801is_url(
const string &name) {
802 return (name.find(
"https://") != string::npos
803 || name.find(
"http://") != string::npos);
818int main(
int argc,
char *argv[]) {
824 string tmpStorage =
"./";
825 string extension =
"_stare.h5";
826 float build_level = 5.0;
829 bool compute_resolution =
false;
831 while ((c = getopt(argc, argv,
"hvVro:t:b:s:a:e:")) != -1) {
847 build_level = atof(optarg);
850 level = atof(optarg);
856 compute_resolution =
true;
874 cerr <<
"Expected 3 required arguments" << endl;
880 string dataset = argv[0];
881 string lat_name = argv[1];
882 string lon_name = argv[2];
885 newName = get_sidecar_filename(dataset, extension);
888 STARE stare(level, build_level);
889 using namespace std::chrono;
890 auto start = high_resolution_clock::now();
898 vector<hsize_t> dims = read_lat_lon(dataset, lat_name, lon_name, lat, lon);
899 unique_ptr<vector<coord> > coords = build_coords(stare, dims, lat, lon);
901 if (compute_resolution)
902 VERBOSE(cerr <<
"STARE index resolution is not available for algorithm one.");
904 writeHDF5(newName, tmpStorage, coords.get());
912 vector<hsize_t> dims = read_lat_lon(dataset, lat_name, lon_name, lat, lon);
913 unique_ptr<coordinates> c = build_coordinates(stare, dims, lat, lon);
915 if (compute_resolution)
916 compute_coordinates_resolution(stare, c.get());
918 writeHDF5(newName, tmpStorage, c.get());
925 unique_ptr<coordinates> c(
new coordinates());
927 read_lat_lon_url(dataset, lat_name, lon_name, c.get());
929 read_lat_lon(dataset, lat_name, lon_name, c.get());
931 compute_coordinates(stare, c.get());
933 if (compute_resolution)
934 compute_coordinates_resolution(stare, c.get());
936 writeHDF5(newName, tmpStorage, c.get());
941 auto total = duration_cast<milliseconds>(high_resolution_clock::now()-start).count();
942 VERBOSE(cerr <<
"Time for the algorithm " << alg <<
": " << total <<
"ms." << endl);
944 catch (libdap::Error &e) {
945 cerr <<
"Error: " << e.get_error_message() << endl;
948 catch (exception &e) {
949 cerr <<
"C++ Error: " << e.what() << endl;