diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-06-29 12:23:37 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-06-30 11:14:46 +0200 |
| commit | a9c3567cf5f69d08a869bf17a9e284e8c8142956 (patch) | |
| tree | c7704fa27b47c2b79e19a23edc6594da02a464d9 /src | |
| parent | 7a131de134e40c73795c7d2c1834bee1e45b16a6 (diff) | |
| download | PROJ-a9c3567cf5f69d08a869bf17a9e284e8c8142956.tar.gz PROJ-a9c3567cf5f69d08a869bf17a9e284e8c8142956.zip | |
Database: import scope/remarks for coordinate operation and add C API
- Import scope and remarks for coordinate operations of the EPSG dataset.
Database size goes from 5.2 MB to 5.55 MB
- Add proj_get_scope() and proj_get_remarks()
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/c_api.cpp | 58 | ||||
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 5 | ||||
| -rw-r--r-- | src/iso19111/factory.cpp | 55 | ||||
| -rw-r--r-- | src/proj.h | 4 |
4 files changed, 112 insertions, 10 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 1e3a331c..bc1d0bd8 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1085,13 +1085,32 @@ const char *proj_get_name(const PJ *obj) { if (!desc.has_value()) { return nullptr; } - // The object will still be alived after the function call. + // The object will still be alive after the function call. // cppcheck-suppress stlcstr return desc->c_str(); } // --------------------------------------------------------------------------- +/** \brief Get the remarks of an object. + * + * The lifetime of the returned string is the same as the input obj parameter. + * + * @param obj Object (must not be NULL) + * @return a string, or NULL in case of error. + */ +const char *proj_get_remarks(const PJ *obj) { + assert(obj); + if (!obj->iso_obj) { + return nullptr; + } + // The object will still be alive after the function call. + // cppcheck-suppress stlcstr + return obj->iso_obj->remarks().c_str(); +} + +// --------------------------------------------------------------------------- + /** \brief Get the authority name / codespace of an identifier of an object. * * The lifetime of the returned string is the same as the input obj parameter. @@ -1113,7 +1132,7 @@ const char *proj_get_id_auth_name(const PJ *obj, int index) { if (!codeSpace.has_value()) { return nullptr; } - // The object will still be alived after the function call. + // The object will still be alive after the function call. // cppcheck-suppress stlcstr return codeSpace->c_str(); } @@ -1295,8 +1314,43 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, // --------------------------------------------------------------------------- +/** \brief Get the scope of an object. + * + * In case of multiple usages, this will be the one of first usage. + * + * The lifetime of the returned string is the same as the input obj parameter. + * + * @param obj Object (must not be NULL) + * @return a string, or NULL in case of error or missing scope. + */ +const char *proj_get_scope(const PJ *obj) { + assert(obj); + if (!obj->iso_obj) { + return nullptr; + } + auto objectUsage = dynamic_cast<const ObjectUsage *>(obj->iso_obj.get()); + if (!objectUsage) { + return nullptr; + } + const auto &domains = objectUsage->domains(); + if (domains.empty()) { + return nullptr; + } + const auto &scope = domains[0]->scope(); + if (!scope.has_value()) { + return nullptr; + } + // The object will still be alive after the function call. + // cppcheck-suppress stlcstr + return scope->c_str(); +} + +// --------------------------------------------------------------------------- + /** \brief Return the area of use of an object. * + * In case of multiple usages, this will be the one of first usage. + * * @param ctx PROJ context, or NULL for default context * @param obj Object (must not be NULL) * @param out_west_lon_degree Pointer to a double to receive the west longitude diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 1982e234..7f3a2137 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -7342,6 +7342,11 @@ createPropertiesForInverse(const CoordinateOperation *op, bool derivedFrom, map.set(common::IdentifiedObject::NAME_KEY, name); } + const std::string &remarks = op->remarks(); + if (!remarks.empty()) { + map.set(common::IdentifiedObject::REMARKS_KEY, remarks); + } + addModifiedIdentifier(map, op, true, derivedFrom); return map; diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 4515188a..1f40f1f0 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -1222,6 +1222,13 @@ struct AuthorityFactory::Private { const std::string &area_of_use_auth_name, const std::string &area_of_use_code); + util::PropertyMap createProperties(const std::string &code, + const std::string &name, bool deprecated, + const std::string &remarks, + const std::string &scope, + const std::string &area_of_use_auth_name, + const std::string &area_of_use_code); + SQLResultSet run(const std::string &sql, const ListOfParams ¶meters = ListOfParams()); @@ -1307,6 +1314,26 @@ util::PropertyMap AuthorityFactory::Private::createProperties( // --------------------------------------------------------------------------- +util::PropertyMap AuthorityFactory::Private::createProperties( + const std::string &code, const std::string &name, bool deprecated, + const std::string &remarks, const std::string &scope, + const std::string &area_of_use_auth_name, + const std::string &area_of_use_code) { + auto props = createProperties(code, name, deprecated, + area_of_use_auth_name.empty() + ? nullptr + : createFactory(area_of_use_auth_name) + ->createExtent(area_of_use_code) + .as_nullable()); + if (!remarks.empty()) + props.set(common::IdentifiedObject::REMARKS_KEY, remarks); + if (!scope.empty()) + props.set(common::ObjectUsage::SCOPE_KEY, scope); + return props; +} + +// --------------------------------------------------------------------------- + bool AuthorityFactory::Private::rejectOpDueToMissingGrid( const operation::CoordinateOperationNNPtr &op, bool discardIfMissingGrid) { if (discardIfMissingGrid) { @@ -2604,7 +2631,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( if (type == "helmert_transformation") { auto res = d->runWithCodeParam( - "SELECT name, method_auth_name, method_code, method_name, " + "SELECT name, description, scope, " + "method_auth_name, method_code, method_name, " "source_crs_auth_name, source_crs_code, target_crs_auth_name, " "target_crs_code, area_of_use_auth_name, area_of_use_code, " "accuracy, tx, ty, tz, translation_uom_auth_name, " @@ -2629,6 +2657,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( const auto &row = res.front(); size_t idx = 0; const auto &name = row[idx++]; + const auto &description = row[idx++]; + const auto &scope = row[idx++]; const auto &method_auth_name = row[idx++]; const auto &method_code = row[idx++]; const auto &method_name = row[idx++]; @@ -2817,7 +2847,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( } auto props = - d->createProperties(code, name, deprecated, + d->createProperties(code, name, deprecated, description, scope, area_of_use_auth_name, area_of_use_code); if (!operation_version.empty()) { props.set(operation::CoordinateOperation::OPERATION_VERSION_KEY, @@ -2846,7 +2876,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( if (type == "grid_transformation") { auto res = d->runWithCodeParam( - "SELECT name, method_auth_name, method_code, method_name, " + "SELECT name, description, scope, " + "method_auth_name, method_code, method_name, " "source_crs_auth_name, source_crs_code, target_crs_auth_name, " "target_crs_code, area_of_use_auth_name, area_of_use_code, " "accuracy, grid_param_auth_name, grid_param_code, grid_param_name, " @@ -2866,6 +2897,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( const auto &row = res.front(); size_t idx = 0; const auto &name = row[idx++]; + const auto &description = row[idx++]; + const auto &scope = row[idx++]; const auto &method_auth_name = row[idx++]; const auto &method_code = row[idx++]; const auto &method_name = row[idx++]; @@ -2930,7 +2963,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( } auto props = - d->createProperties(code, name, deprecated, + d->createProperties(code, name, deprecated, description, scope, area_of_use_auth_name, area_of_use_code); if (!operation_version.empty()) { props.set(operation::CoordinateOperation::OPERATION_VERSION_KEY, @@ -2964,7 +2997,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( std::ostringstream buffer; buffer.imbue(std::locale::classic()); buffer - << "SELECT name, method_auth_name, method_code, method_name, " + << "SELECT name, description, scope, " + "method_auth_name, method_code, method_name, " "source_crs_auth_name, source_crs_code, target_crs_auth_name, " "target_crs_code, area_of_use_auth_name, area_of_use_code, " "accuracy"; @@ -2990,6 +3024,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( const auto &row = res.front(); size_t idx = 0; const auto &name = row[idx++]; + const auto &description = row[idx++]; + const auto &scope = row[idx++]; const auto &method_auth_name = row[idx++]; const auto &method_code = row[idx++]; const auto &method_name = row[idx++]; @@ -3044,7 +3080,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( ->createCoordinateReferenceSystem(target_crs_code); auto props = - d->createProperties(code, name, deprecated, + d->createProperties(code, name, deprecated, description, scope, area_of_use_auth_name, area_of_use_code); if (!operation_version.empty()) { props.set(operation::CoordinateOperation::OPERATION_VERSION_KEY, @@ -3099,7 +3135,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( if (allowConcatenated && type == "concatenated_operation") { auto res = d->runWithCodeParam( - "SELECT name, source_crs_auth_name, source_crs_code, " + "SELECT name, description, scope, " + "source_crs_auth_name, source_crs_code, " "target_crs_auth_name, target_crs_code, " "area_of_use_auth_name, area_of_use_code, accuracy, " "step1_auth_name, step1_code, step2_auth_name, step2_code, " @@ -3115,6 +3152,8 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( const auto &row = res.front(); size_t idx = 0; const auto &name = row[idx++]; + const auto &description = row[idx++]; + const auto &scope = row[idx++]; const auto &source_crs_auth_name = row[idx++]; const auto &source_crs_code = row[idx++]; const auto &target_crs_auth_name = row[idx++]; @@ -3160,7 +3199,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation( operations); auto props = - d->createProperties(code, name, deprecated, + d->createProperties(code, name, deprecated, description, scope, area_of_use_auth_name, area_of_use_code); if (!operation_version.empty()) { props.set(operation::CoordinateOperation::OPERATION_VERSION_KEY, @@ -826,6 +826,10 @@ const char PROJ_DLL* proj_get_id_auth_name(const PJ *obj, int index); const char PROJ_DLL* proj_get_id_code(const PJ *obj, int index); +const char PROJ_DLL* proj_get_remarks(const PJ *obj); + +const char PROJ_DLL* proj_get_scope(const PJ *obj); + int PROJ_DLL proj_get_area_of_use(PJ_CONTEXT *ctx, const PJ *obj, double* out_west_lon_degree, |
