diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-10-18 18:42:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-18 18:42:31 +0200 |
| commit | 2357d264d477c5eee363514fb094772980509726 (patch) | |
| tree | c4bdcbe7d36d961a9a55241844fe1977d3434aad /src/iso19111/c_api.cpp | |
| parent | 3a2df3462c851b7dc823b1cd84fc8a61dc9c2d08 (diff) | |
| parent | ffe1922d54d4ce379c96f5472dba2e76223348f1 (diff) | |
| download | PROJ-2357d264d477c5eee363514fb094772980509726.tar.gz PROJ-2357d264d477c5eee363514fb094772980509726.zip | |
Merge pull request #2381 from rouault/fix_1453
Add multi-line PROJ string export capability, and use it by default in projinfo (unless --single-line is specified) (fixes #1543)
Diffstat (limited to 'src/iso19111/c_api.cpp')
| -rw-r--r-- | src/iso19111/c_api.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index cad76431..8d77437a 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1504,9 +1504,16 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type, * @param obj Object (must not be NULL) * @param type PROJ String version. * @param options NULL-terminated list of strings with "KEY=VALUE" format. or - * NULL. - * The currently recognized option is USE_APPROX_TMERC=YES to add the +approx - * flag to +proj=tmerc or +proj=utm + * NULL. Currently supported options are: + * <ul> + * <li>USE_APPROX_TMERC=YES to add the +approx flag to +proj=tmerc or + * +proj=utm.</li> + * <li>MULTILINE=YES/NO. Defaults to NO</li> + * <li>INDENTATION_WIDTH=number. Defaults to 2 (when multiline output is + * on).</li> + * <li>MAX_LINE_LENGTH=number. Defaults to 80 (when multiline output is + * on).</li> + * </ul> * @return a string, or NULL in case of error. */ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, @@ -1542,9 +1549,21 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, auto dbContext = getDBcontextNoException(ctx, __FUNCTION__); try { auto formatter = PROJStringFormatter::create(convention, dbContext); - if (options != nullptr && options[0] != nullptr) { - if (ci_equal(options[0], "USE_APPROX_TMERC=YES")) { - formatter->setUseApproxTMerc(true); + for (auto iter = options; iter && iter[0]; ++iter) { + const char *value; + if ((value = getOptionValue(*iter, "MULTILINE="))) { + formatter->setMultiLine(ci_equal(value, "YES")); + } else if ((value = getOptionValue(*iter, "INDENTATION_WIDTH="))) { + formatter->setIndentationWidth(std::atoi(value)); + } else if ((value = getOptionValue(*iter, "MAX_LINE_LENGTH="))) { + formatter->setMaxLineLength(std::atoi(value)); + } else if ((value = getOptionValue(*iter, "USE_APPROX_TMERC="))) { + formatter->setUseApproxTMerc(ci_equal(value, "YES")); + } else { + std::string msg("Unknown option :"); + msg += *iter; + proj_log_error(ctx, __FUNCTION__, msg.c_str()); + return nullptr; } } obj->lastPROJString = exportable->exportToPROJString(formatter.get()); |
