aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-04 16:22:44 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-04 17:05:32 +0100
commit57b00a63c6caee1a53961d542904f7c9b1f014c9 (patch)
tree599ca27d29cda4519687ca324f96b2662ba456f9 /src
parentd06c1c55c1c3fc7209abdbdfbf2e3cf34f18cf98 (diff)
downloadPROJ-57b00a63c6caee1a53961d542904f7c9b1f014c9.tar.gz
PROJ-57b00a63c6caee1a53961d542904f7c9b1f014c9.zip
Improve management of 'deprecated' suffix in object names
Diffstat (limited to 'src')
-rw-r--r--src/c_api.cpp11
-rw-r--r--src/crs.cpp49
-rw-r--r--src/io.cpp4
3 files changed, 42 insertions, 22 deletions
diff --git a/src/c_api.cpp b/src/c_api.cpp
index 5c873dcf..718d46bf 100644
--- a/src/c_api.cpp
+++ b/src/c_api.cpp
@@ -1805,9 +1805,14 @@ PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_CONTEXT *ctx, const PJ_OBJ *crs,
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
-static PropertyMap createPropertyMapName(const char *name) {
- return PropertyMap().set(common::IdentifiedObject::NAME_KEY,
- name ? name : "unnamed");
+static PropertyMap createPropertyMapName(const char *c_name) {
+ std::string name(c_name ? c_name : "unnamed");
+ PropertyMap properties;
+ if (ends_with(name, " (deprecated)")) {
+ name.resize(name.size() - strlen(" (deprecated)"));
+ properties.set(common::IdentifiedObject::DEPRECATED_KEY, true);
+ }
+ return properties.set(common::IdentifiedObject::NAME_KEY, name);
}
// ---------------------------------------------------------------------------
diff --git a/src/crs.cpp b/src/crs.cpp
index 31682644..d4d98fa4 100644
--- a/src/crs.cpp
+++ b/src/crs.cpp
@@ -213,9 +213,16 @@ GeographicCRSPtr CRS::extractGeographicCRS() const {
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
-static util::PropertyMap createPropertyMapName(const std::string &name) {
- return util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, name);
+static util::PropertyMap
+createPropertyMap(const common::IdentifiedObject *obj) {
+ auto props = util::PropertyMap().set(common::IdentifiedObject::NAME_KEY,
+ obj->nameStr());
+ if (obj->isDeprecated()) {
+ props.set(common::IdentifiedObject::DEPRECATED_KEY, true);
+ }
+ return props;
}
+
//! @endcond
// ---------------------------------------------------------------------------
@@ -229,9 +236,9 @@ CRSNNPtr CRS::alterGeodeticCRS(const GeodeticCRSNNPtr &newGeodCRS) const {
auto projCRS = dynamic_cast<const ProjectedCRS *>(this);
if (projCRS) {
- return ProjectedCRS::create(
- createPropertyMapName(nameStr()), newGeodCRS,
- projCRS->derivingConversionRef(), projCRS->coordinateSystem());
+ return ProjectedCRS::create(createPropertyMap(this), newGeodCRS,
+ projCRS->derivingConversionRef(),
+ projCRS->coordinateSystem());
}
auto compoundCRS = dynamic_cast<const CompoundCRS *>(this);
@@ -240,8 +247,7 @@ CRSNNPtr CRS::alterGeodeticCRS(const GeodeticCRSNNPtr &newGeodCRS) const {
for (const auto &subCrs : compoundCRS->componentReferenceSystems()) {
components.emplace_back(subCrs->alterGeodeticCRS(newGeodCRS));
}
- return CompoundCRS::create(createPropertyMapName(nameStr()),
- components);
+ return CompoundCRS::create(createPropertyMap(this), components);
}
return NN_NO_CHECK(
@@ -257,8 +263,8 @@ CRSNNPtr CRS::alterCSLinearUnit(const common::UnitOfMeasure &unit) const {
auto projCRS = dynamic_cast<const ProjectedCRS *>(this);
if (projCRS) {
return ProjectedCRS::create(
- createPropertyMapName(projCRS->nameStr().c_str()),
- projCRS->baseCRS(), projCRS->derivingConversionRef(),
+ createPropertyMap(this), projCRS->baseCRS(),
+ projCRS->derivingConversionRef(),
projCRS->coordinateSystem()->alterUnit(unit));
}
}
@@ -270,9 +276,8 @@ CRSNNPtr CRS::alterCSLinearUnit(const common::UnitOfMeasure &unit) const {
geodCRS->coordinateSystem().get());
assert(cs);
return GeodeticCRS::create(
- createPropertyMapName(geodCRS->nameStr().c_str()),
- geodCRS->datum(), geodCRS->datumEnsemble(),
- cs->alterUnit(unit));
+ createPropertyMap(this), geodCRS->datum(),
+ geodCRS->datumEnsemble(), cs->alterUnit(unit));
}
}
@@ -280,8 +285,8 @@ CRSNNPtr CRS::alterCSLinearUnit(const common::UnitOfMeasure &unit) const {
auto geogCRS = dynamic_cast<const GeographicCRS *>(this);
if (geogCRS && geogCRS->coordinateSystem()->axisList().size() == 3) {
return GeographicCRS::create(
- createPropertyMapName(geogCRS->nameStr().c_str()),
- geogCRS->datum(), geogCRS->datumEnsemble(),
+ createPropertyMap(this), geogCRS->datum(),
+ geogCRS->datumEnsemble(),
geogCRS->coordinateSystem()->alterLinearUnit(unit));
}
}
@@ -290,8 +295,8 @@ CRSNNPtr CRS::alterCSLinearUnit(const common::UnitOfMeasure &unit) const {
auto vertCRS = dynamic_cast<const VerticalCRS *>(this);
if (vertCRS) {
return VerticalCRS::create(
- createPropertyMapName(vertCRS->nameStr().c_str()),
- vertCRS->datum(), vertCRS->datumEnsemble(),
+ createPropertyMap(this), vertCRS->datum(),
+ vertCRS->datumEnsemble(),
vertCRS->coordinateSystem()->alterUnit(unit));
}
}
@@ -501,8 +506,14 @@ CRSNNPtr CRS::shallowClone() const { return _shallowClone(); }
CRSNNPtr CRS::alterName(const std::string &newName) const {
auto crs = shallowClone();
- crs->setProperties(
- util::PropertyMap().set(common::IdentifiedObject::NAME_KEY, newName));
+ auto newNameMod(newName);
+ auto props = util::PropertyMap();
+ if (ends_with(newNameMod, " (deprecated)")) {
+ newNameMod.resize(newNameMod.size() - strlen(" (deprecated)"));
+ props.set(common::IdentifiedObject::DEPRECATED_KEY, true);
+ }
+ props.set(common::IdentifiedObject::NAME_KEY, newNameMod);
+ crs->setProperties(props);
return crs;
}
@@ -2671,7 +2682,7 @@ bool ProjectedCRS::_isEquivalentTo(
ProjectedCRSNNPtr
ProjectedCRS::alterParametersLinearUnit(const common::UnitOfMeasure &unit,
bool convertToNewUnit) const {
- return create(createPropertyMapName(nameStr()), baseCRS(),
+ return create(createPropertyMap(this), baseCRS(),
derivingConversionRef()->alterParametersLinearUnit(
unit, convertToNewUnit),
coordinateSystem());
diff --git a/src/io.cpp b/src/io.cpp
index e0f74f10..f396f1df 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -1449,6 +1449,10 @@ PropertyMap &WKTParser::Private::buildProperties(const WKTNodeNNPtr &node) {
if (!nodeChildren.empty()) {
const auto &nodeName(nodeP->value());
auto name(stripQuotes(nodeChildren[0]));
+ if (ends_with(name, " (deprecated)")) {
+ name.resize(name.size() - strlen(" (deprecated)"));
+ properties->set(common::IdentifiedObject::DEPRECATED_KEY, true);
+ }
const char *tableNameForAlias = nullptr;
if (ci_equal(nodeName, WKTConstants::GEOGCS)) {