Skip to content

Commit ad5f658

Browse files
committed
for #2068
1 parent 09bbbf3 commit ad5f658

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/gdal_multidimensional.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ bool SpatRaster::constructFromFileMulti(std::string fname, std::vector<int> subd
483483
others.push_back(anms[i]);
484484
}
485485
}
486-
addWarning(std::string("using array \"") + s.m_arrayname + "\". Other array(s): " + concatenate(others, ", "));
486+
//addWarning(std::string("using array \"") + s.m_arrayname + "\". Other array(s): " + concatenate(others, ", "));
487487
}
488488
} else {
489489
s.m_arrayname = anms[0];
@@ -510,29 +510,6 @@ bool SpatRaster::constructFromFileMulti(std::string fname, std::vector<int> subd
510510
}
511511
s.m_arrayname = poVar->GetFullName();
512512

513-
std::string wkt = "";
514-
auto srs = poVar->GetSpatialRef();
515-
516-
if (srs != NULL) {
517-
char *cp;
518-
const char *options[3] = { "MULTILINE=YES", "FORMAT=WKT2", NULL };
519-
OGRErr err = srs->exportToWkt(&cp, options);
520-
if (err == OGRERR_NONE) {
521-
wkt = std::string(cp);
522-
}
523-
CPLFree(cp);
524-
}
525-
if (guessCRS && wkt.empty()) {
526-
if (s.extent.xmin >= -181 && s.extent.xmax <= 361 && s.extent.ymin >= -91 && s.extent.ymax <= 91) {
527-
wkt = "OGC:CRS84";
528-
s.parameters_changed = true;
529-
}
530-
}
531-
std::string msg = "";
532-
if (!s.srs.set({wkt}, msg)) {
533-
addWarning(msg);
534-
}
535-
536513

537514
// dimensions
538515
std::vector<size_t> dimcount;
@@ -753,6 +730,31 @@ bool SpatRaster::constructFromFileMulti(std::string fname, std::vector<int> subd
753730
}
754731
s.extent = e;
755732

733+
734+
std::string wkt = "";
735+
auto srs = poVar->GetSpatialRef();
736+
737+
if (srs != NULL) {
738+
char *cp;
739+
const char *options[3] = { "MULTILINE=YES", "FORMAT=WKT2", NULL };
740+
OGRErr err = srs->exportToWkt(&cp, options);
741+
if (err == OGRERR_NONE) {
742+
wkt = std::string(cp);
743+
}
744+
CPLFree(cp);
745+
}
746+
if (guessCRS && wkt.empty()) {
747+
if (s.extent.xmin >= -181 && s.extent.xmax <= 361 && s.extent.ymin >= -91 && s.extent.ymax <= 91) {
748+
wkt = "OGC:CRS84";
749+
s.parameters_changed = true;
750+
addWarning("guessed crs");
751+
}
752+
}
753+
std::string msg = "";
754+
if (!s.srs.set({wkt}, msg)) {
755+
addWarning(msg);
756+
}
757+
756758
bool app_so = true;
757759
size_t opsz = options.size();
758760
if (opsz > 0) {

0 commit comments

Comments
 (0)