Skip to content

Commit

Permalink
adjust as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Mar 1, 2020
1 parent c4a673b commit 8790296
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pdal/SpatialReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,27 @@ std::string SpatialReference::convertToWKT1(const std::string& wkt)

// WKT flavors only exist in GDAL 3.x+
#if GDAL_VERSION_MAJOR >= 3

OGRScopedSpatialReference srs = ogrCreateSrs(wkt);
if (!srs)
return outWkt;

char *buf = nullptr;

char **papszOptions = nullptr;
papszOptions = CSLAddNameValue(papszOptions, "FORMAT", "WKT1_GDAL");
srs->exportToWkt(&buf, papszOptions);
const char* apszOptions[] = { "FORMAT=WKT1_GDAL", nullptr };
srs->exportToWkt(&buf, apszOptions);

// If we couldn't convert to WKT1, return empty
if (buf == nullptr)
{
outWkt = "";
}
else
{
outWkt = buf;
CPLFree(buf);
}

outWkt = buf;
CPLFree(buf);
#endif
return outWkt;
}
Expand Down

0 comments on commit 8790296

Please sign in to comment.