From e63e0109c033235d48ef706eeb4f567b8d5255cb Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Mon, 12 Dec 2011 17:41:47 -0600 Subject: [PATCH] rejigger the getDimension method to fall through to try the uuid if it doesn't find a dimension with the given name --- src/Schema.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Schema.cpp b/src/Schema.cpp index 6ff47d7196..0355f56ab5 100644 --- a/src/Schema.cpp +++ b/src/Schema.cpp @@ -184,34 +184,39 @@ const Dimension& Schema::getDimension(std::string const& t) const schema::index_by_name::const_iterator it = name_index.find(t); - + std::ostringstream oss; + oss << "Dimension with name '" << t << "' not found, unable to Schema::getDimension"; + // FIXME: If there are two dimensions with the same name here, we're // scrwed if (it != name_index.end()) { return *it; } else { - - pdal::external::boost::uuids::string_generator gen; - + pdal::external::boost::uuids::uuid ps1; try { - pdal::external::boost::uuids::uuid ps1 = gen(t); - schema::index_by_uid::const_iterator it = m_index.get().find(ps1); - - if (it != m_index.get().end()) - { - return *it; - } + pdal::external::boost::uuids::string_generator gen; + ps1 = gen(t); } catch (std::runtime_error&) { // invalid string for uuid + throw dimension_not_found(oss.str()); + } + + schema::index_by_uid::const_iterator i = m_index.get().find(ps1); + + if (i != m_index.get().end()) + { + return *i; + } else + { + oss.str(""); + oss << "Dimension with name '" << t << "' not found, unable to Schema::getDimension"; + throw dimension_not_found(oss.str()); } - } - std::ostringstream oss; - oss << "Dimension with name '" << t << "' not found, unable to Schema::getDimension"; throw dimension_not_found(oss.str()); }