- output only get escaped when actually output. Better seperation of functionality
- refactor facade::GetEscapeName() into get_name_for_id() call that is implemented in subclasses - remove dead code - fix failing tests where names got double-escaped - fixes https://github.com/Project-OSRM/node-osrm/issues/83
This commit is contained in:
@@ -109,14 +109,7 @@ template <class EdgeDataT> class BaseDataFacade
|
||||
|
||||
virtual unsigned GetNameIndexFromEdgeID(const unsigned id) const = 0;
|
||||
|
||||
virtual void GetName(const unsigned name_id, std::string &result) const = 0;
|
||||
|
||||
std::string GetEscapedNameForNameID(const unsigned name_id) const
|
||||
{
|
||||
std::string temporary_string;
|
||||
GetName(name_id, temporary_string);
|
||||
return EscapeJSONString(temporary_string);
|
||||
}
|
||||
virtual std::string get_name_for_id(const unsigned name_id) const = 0;
|
||||
|
||||
virtual std::string GetTimestamp() const = 0;
|
||||
};
|
||||
|
||||
@@ -46,6 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <osrm/coordinate.hpp>
|
||||
#include <osrm/server_paths.hpp>
|
||||
|
||||
#include <limits>
|
||||
|
||||
template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacade<EdgeDataT>
|
||||
{
|
||||
|
||||
@@ -418,24 +420,25 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
unsigned GetNameIndexFromEdgeID(const unsigned id) const override final
|
||||
{
|
||||
return m_name_ID_list.at(id);
|
||||
};
|
||||
}
|
||||
|
||||
void GetName(const unsigned name_id, std::string &result) const override final
|
||||
std::string get_name_for_id(const unsigned name_id) const override final
|
||||
{
|
||||
if (UINT_MAX == name_id)
|
||||
if (std::numeric_limits<unsigned>::max() == name_id)
|
||||
{
|
||||
result = "";
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
auto range = m_name_table.GetRange(name_id);
|
||||
|
||||
result.clear();
|
||||
std::string result;
|
||||
result.reserve(range.size());
|
||||
if (range.begin() != range.end())
|
||||
{
|
||||
result.resize(range.back() - range.front() + 1);
|
||||
std::copy(m_names_char_list.begin() + range.front(),
|
||||
m_names_char_list.begin() + range.back() + 1, result.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const override final
|
||||
|
||||
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../../util/simple_logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<EdgeDataT>
|
||||
@@ -409,22 +410,23 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
return m_name_ID_list.at(id);
|
||||
};
|
||||
|
||||
void GetName(const unsigned name_id, std::string &result) const override final
|
||||
std::string get_name_for_id(const unsigned name_id) const override final
|
||||
{
|
||||
if (UINT_MAX == name_id)
|
||||
if (std::numeric_limits<unsigned>::max() == name_id)
|
||||
{
|
||||
result = "";
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
auto range = m_name_table->GetRange(name_id);
|
||||
|
||||
result.clear();
|
||||
std::string result;
|
||||
result.reserve(range.size());
|
||||
if (range.begin() != range.end())
|
||||
{
|
||||
result.resize(range.back() - range.front() + 1);
|
||||
std::copy(m_names_char_list.begin() + range.front(),
|
||||
m_names_char_list.begin() + range.back() + 1, result.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetTimestamp() const override final { return m_timestamp; }
|
||||
|
||||
Reference in New Issue
Block a user