forked from organicmaps/organicmaps
Added support for negative node ids to borders generator
This is needed for manually edited osm files
This commit is contained in:
parent
1ea67cca63
commit
dcaacda0b5
3 changed files with 15 additions and 6 deletions
|
@ -53,6 +53,14 @@ bool to_uint64(char const * s, uint64_t & i)
|
|||
return !ss.fail();
|
||||
}
|
||||
|
||||
bool to_int64(char const * s, int64_t & i)
|
||||
{
|
||||
istringstream ss;
|
||||
ss.str(s);
|
||||
ss >> i;
|
||||
return !ss.fail();
|
||||
}
|
||||
|
||||
bool to_double(char const * s, double & d)
|
||||
{
|
||||
char * stop;
|
||||
|
|
|
@ -55,12 +55,14 @@ namespace utils
|
|||
|
||||
bool to_int(char const * s, int & i);
|
||||
bool to_uint64(char const * s, uint64_t & i);
|
||||
bool to_int64(char const * s, int64_t & i);
|
||||
bool to_double(char const * s, double & d);
|
||||
|
||||
string to_string(size_t i);
|
||||
|
||||
inline bool to_int(string const & s, int & i) { return to_int(s.c_str(), i); }
|
||||
inline bool to_uint64(string const & s, uint64_t & i) { return to_uint64(s.c_str(), i); }
|
||||
inline bool to_int64(string const & s, int64_t & i) { return to_int64(s.c_str(), i); }
|
||||
inline bool to_double(string const & s, double & d) { return to_double(s.c_str(), d); }
|
||||
|
||||
void make_lower_case(string & s);
|
||||
|
|
|
@ -202,9 +202,8 @@ namespace osm
|
|||
string const & elem = m_xmlTags.back();
|
||||
if (attr == "id" && (elem == "node" || elem == "way" || elem == "relation"))
|
||||
{
|
||||
uint64_t numVal;
|
||||
CHECK(utils::to_uint64(value, numVal), ());
|
||||
m_id = static_cast<int64_t>(numVal);
|
||||
CHECK(utils::to_int64(value, m_id), ());
|
||||
CHECK_NOT_EQUAL(m_id, 0, ("id == 0 is invalid"));
|
||||
}
|
||||
else if (attr == "lat" && elem == "node")
|
||||
{
|
||||
|
@ -216,10 +215,10 @@ namespace osm
|
|||
}
|
||||
else if (attr == "ref")
|
||||
{
|
||||
uint64_t numVal;
|
||||
CHECK(utils::to_uint64(value, numVal), ());
|
||||
int64_t numVal;
|
||||
CHECK(utils::to_int64(value, numVal), ());
|
||||
if (elem == "nd")
|
||||
m_ref = static_cast<int64_t>(numVal);
|
||||
m_ref = numVal;
|
||||
else if (elem == "member")
|
||||
m_member.m_ref = numVal;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue