Skip to content

Commit

Permalink
ecCharts/opencharts: improve tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Nov 8, 2023
1 parent 8070f67 commit 9c60aef
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions src/decoders/TileDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ PointsHandler& TileDecoder::points(const Transformation& t, bool) {
map<string, string> first, last;

if ( mode_ == "opencharts") {

// netcdf.get(projection_ + "_lat", latitudes, first, last);
// netcdf.get(projection_ + "_lon", longitudes, first, last);
netcdf.get(projection_ + "_index", values, first, last);
Expand Down Expand Up @@ -477,8 +476,10 @@ Data* TileDecoder::next() {


void TileDecoder::decode() {
if (matrix_.size())
return;
if (matrix_.size()) {
matrix_ = Matrix();

}

string path = weights();

Expand Down Expand Up @@ -513,39 +514,41 @@ void TileDecoder::decode() {
int nblat = netcdf.getDimension("lat") - 1;
int nblon = netcdf.getDimension("lon") - 1;

if (bbox.empty()) {
netcdf.get("bounding-box", bbox, first, last);

netcdf.get("bounding-box", bbox, first, last);

int error;
FILE* in = fopen(file_name_.c_str(), "rb");
if (!in) {
if (MagicsGlobal::strict()) {
throw CannotOpenFile(file_name_);
}
MagLog::error() << "ERROR: unable to create handle from file" << file_name_ << endl;
return;
int error;
FILE* in = fopen(file_name_.c_str(), "rb");
if (!in) {
if (MagicsGlobal::strict()) {
throw CannotOpenFile(file_name_);
}

// Adding a gutter of 5 points to avoid borders in tiles
int miny = std::min(bbox[1], bbox[3]);
miny = std::max(0, miny - 5);
int maxy = std::max(bbox[1], bbox[3]);
maxy = std::min(nblat, maxy + 5);
int minx = std::min(bbox[0], bbox[2]);
minx = std::max(0, minx - 5);
int maxx = std::max(bbox[0], bbox[2]);
maxx = std::min(nblon, maxx + 5);

first["lat"] = tostring(miny);
first["lon"] = tostring(minx);
last["lat"] = tostring(maxy);
last["lon"] = tostring(maxx);

netcdf.get("lat", latitudes, first, last);
netcdf.get("lon", longitudes, first, last);
netcdf.get("index", dindex, first, last);
netcdf.get("distances", distances, first, last);
MagLog::error() << "ERROR: unable to create handle from file" << file_name_ << endl;
return;
}

// Adding a gutter of 5 points to avoid borders in tiles
int miny = std::min(bbox[1], bbox[3]);
miny = std::max(0, miny - 5);
int maxy = std::max(bbox[1], bbox[3]);
maxy = std::min(nblat, maxy + 5);
int minx = std::min(bbox[0], bbox[2]);
minx = std::max(0, minx - 5);
int maxx = std::max(bbox[0], bbox[2]);
maxx = std::min(nblon, maxx + 5);

first["lat"] = tostring(miny);
first["lon"] = tostring(minx);
last["lat"] = tostring(maxy);
last["lon"] = tostring(maxx);



netcdf.get("lat", latitudes, first, last);
netcdf.get("lon", longitudes, first, last);
netcdf.get("index", dindex, first, last);
netcdf.get("distances", distances, first, last);

}

int index[4];
Expand Down

0 comments on commit 9c60aef

Please sign in to comment.