| 71 | } |
| 72 | |
| 73 | std::string exportToWkt(OGRSpatialReference* srs, const std::vector<std::string>& options = {}) |
| 74 | { |
| 75 | std::string wkt; |
| 76 | if (!srs) |
| 77 | return wkt; |
| 78 | |
| 79 | // Make one more pointer than option to terminate the list with a nullptr. |
| 80 | std::vector<const char *> copts(options.size() + 1, nullptr); |
| 81 | for (size_t i = 0; i < options.size(); ++i) |
| 82 | copts[i] = options[i].c_str(); |
| 83 | |
| 84 | char *buf = nullptr; |
| 85 | srs->exportToWkt(&buf, copts.data()); |
| 86 | if (buf) |
| 87 | { |
| 88 | wkt = buf; |
| 89 | CPLFree(buf); |
| 90 | } |
| 91 | return wkt; |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |