diff options
| author | Nyall Dawson <nyall.dawson@gmail.com> | 2019-03-21 17:30:06 +1000 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2019-03-21 08:30:06 +0100 |
| commit | 5d74522573291a8af698acf3102a662eb3a675eb (patch) | |
| tree | ab7d77d8c79497a80810598bb70dd4af9ae9f0f1 /src | |
| parent | dc1f9d8ba25d3fd35ef767e18903ac9dad91e7e3 (diff) | |
| download | PROJ-5d74522573291a8af698acf3102a662eb3a675eb.tar.gz PROJ-5d74522573291a8af698acf3102a662eb3a675eb.zip | |
Add -k ellipsoid option to projinfo (#1338)
Allows querying of ellipsoid definitions by auth:code lookup
Diffstat (limited to 'src')
| -rw-r--r-- | src/apps/projinfo.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 7e401887..ae97b9c1 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -77,7 +77,7 @@ struct OutputOptions { static void usage() { std::cerr - << "usage: projinfo [-o formats] [-k crs|operation] [--summary] [-q]" + << "usage: projinfo [-o formats] [-k crs|operation|ellipsoid] [--summary] [-q]" << std::endl << " ([--area name_or_code] | " "[--bbox west_long,south_lat,east_long,north_lat]) " @@ -138,7 +138,7 @@ static std::string c_ify_string(const std::string &str) { static BaseObjectNNPtr buildObject( DatabaseContextPtr dbContext, const std::string &user_string, - bool kindIsCRS, const std::string &context, bool buildBoundCRSToWGS84, + const std::string &kind, const std::string &context, bool buildBoundCRSToWGS84, CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS, bool quiet) { BaseObjectPtr obj; @@ -174,10 +174,14 @@ static BaseObjectNNPtr buildObject( try { auto tokens = split(l_user_string, ':'); - if (!kindIsCRS && tokens.size() == 2) { + if (kind == "operation" && tokens.size() == 2) { auto urn = "urn:ogc:def:coordinateOperation:" + tokens[0] + "::" + tokens[1]; obj = createFromUserInput(urn, dbContext).as_nullable(); + } else if (kind == "ellipsoid" && tokens.size() == 2) { + auto urn = "urn:ogc:def:ellipsoid:" + tokens[0] + "::" + + tokens[1]; + obj = createFromUserInput(urn, dbContext).as_nullable(); } else { // Convenience to be able to use C escaped strings... if (l_user_string.size() > 2 && l_user_string[0] == '"' && @@ -572,7 +576,7 @@ static void outputOperations( const std::string &authority, bool usePROJGridAlternatives, bool showSuperseded, const OutputOptions &outputOpt, bool summary) { auto sourceObj = buildObject( - dbContext, sourceCRSStr, true, "source CRS", false, + dbContext, sourceCRSStr, "crs", "source CRS", false, CoordinateOperationContext::IntermediateCRSUse::NEVER, outputOpt.quiet); auto sourceCRS = nn_dynamic_pointer_cast<CRS>(sourceObj); if (!sourceCRS) { @@ -581,7 +585,7 @@ static void outputOperations( } auto targetObj = buildObject( - dbContext, targetCRSStr, true, "target CRS", false, + dbContext, targetCRSStr, "crs", "target CRS", false, CoordinateOperationContext::IntermediateCRSUse::NEVER, outputOpt.quiet); auto targetCRS = nn_dynamic_pointer_cast<CRS>(targetObj); if (!targetCRS) { @@ -678,7 +682,7 @@ int main(int argc, char **argv) { std::string targetCRSStr; bool outputSwithSpecified = false; OutputOptions outputOpt; - bool kindIsCRS = true; + std::string objectKind; bool summary = false; ExtentPtr bboxFilter = nullptr; std::string area; @@ -806,9 +810,11 @@ int main(int argc, char **argv) { i++; std::string kind(argv[i]); if (ci_equal(kind, "crs") || ci_equal(kind, "srs")) { - kindIsCRS = true; + objectKind = "crs"; } else if (ci_equal(kind, "operation")) { - kindIsCRS = false; + objectKind = "operation"; + } else if (ci_equal(kind, "ellipsoid")) { + objectKind = "ellipsoid"; } else { std::cerr << "Unrecognized value for option -k: " << kind << std::endl; @@ -998,7 +1004,7 @@ int main(int argc, char **argv) { } if (!user_string.empty()) { - auto obj(buildObject(dbContext, user_string, kindIsCRS, "input string", + auto obj(buildObject(dbContext, user_string, objectKind, "input string", buildBoundCRSToWGS84, allowUseIntermediateCRS, outputOpt.quiet)); if (guessDialect) { |
