Skip to content

Commit

Permalink
BUG: Handle prefix whitespace when guessing WKT dialiect
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Snow committed Jul 27, 2023
1 parent fde3d58 commit d2794d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8015,7 +8015,12 @@ WKTParser::attachDatabaseContext(const DatabaseContextPtr &dbContext) {
/** \brief Guess the "dialect" of the WKT string.
*/
WKTParser::WKTGuessedDialect
WKTParser::guessDialect(const std::string &wkt) noexcept {
WKTParser::guessDialect(const std::string &inputWkt) noexcept {
std::string wkt = inputWkt;
std::size_t idxFirstCharNotSpace = wkt.find_first_not_of(" \t\r\n");
if (idxFirstCharNotSpace > 0 && idxFirstCharNotSpace != std::string::npos) {
wkt = wkt.substr(idxFirstCharNotSpace);
}
if (ci_starts_with(wkt, WKTConstants::VERTCS)) {
return WKTGuessedDialect::WKT1_ESRI;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ TEST_F(CApi, proj_context_guess_wkt_dialect) {

EXPECT_EQ(proj_context_guess_wkt_dialect(
nullptr,
"GEOGCRS[\"WGS 84\",\n"
" \n\t\rGEOGCRS[\"WGS 84\",\n"
" DATUM[\"World Geodetic System 1984\",\n"
" ELLIPSOID[\"WGS 84\",6378137,298.257223563]],\n"
" CS[ellipsoidal,2],\n"
Expand Down

0 comments on commit d2794d7

Please sign in to comment.