Partially fixes #646. Values were incorrectly casted to int32_t and not uint32_t
This commit is contained in:
parent
9ab86ae2bf
commit
f5124de327
@ -129,13 +129,13 @@ _RawRestrictionContainer XMLParser::_ReadXMLRestriction() {
|
|||||||
xmlChar * type = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "type" );
|
xmlChar * type = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "type" );
|
||||||
|
|
||||||
if(xmlStrEqual(role, (const xmlChar *) "to") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
if(xmlStrEqual(role, (const xmlChar *) "to") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
||||||
restriction.toWay = atoi((const char*) ref);
|
restriction.toWay = stringToUint((const char*) ref);
|
||||||
}
|
}
|
||||||
if(xmlStrEqual(role, (const xmlChar *) "from") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
if(xmlStrEqual(role, (const xmlChar *) "from") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
||||||
restriction.fromWay = atoi((const char*) ref);
|
restriction.fromWay = stringToUint((const char*) ref);
|
||||||
}
|
}
|
||||||
if(xmlStrEqual(role, (const xmlChar *) "via") && xmlStrEqual(type, (const xmlChar *) "node")) {
|
if(xmlStrEqual(role, (const xmlChar *) "via") && xmlStrEqual(type, (const xmlChar *) "node")) {
|
||||||
restriction.restriction.viaNode = atoi((const char*) ref);
|
restriction.restriction.viaNode = stringToUint((const char*) ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL != type) {
|
if(NULL != type) {
|
||||||
@ -176,7 +176,7 @@ ExtractionWay XMLParser::_ReadXMLWay() {
|
|||||||
|
|
||||||
if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "way" ) == 1 ) {
|
if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "way" ) == 1 ) {
|
||||||
xmlChar* id = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
|
xmlChar* id = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
|
||||||
way.id = atoi((char*)id);
|
way.id = stringToUint((char*)id);
|
||||||
xmlFree(id);
|
xmlFree(id);
|
||||||
xmlFree( childName );
|
xmlFree( childName );
|
||||||
break;
|
break;
|
||||||
@ -202,7 +202,7 @@ ExtractionWay XMLParser::_ReadXMLWay() {
|
|||||||
} else if ( xmlStrEqual( childName, ( const xmlChar* ) "nd" ) == 1 ) {
|
} else if ( xmlStrEqual( childName, ( const xmlChar* ) "nd" ) == 1 ) {
|
||||||
xmlChar* ref = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "ref" );
|
xmlChar* ref = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "ref" );
|
||||||
if ( ref != NULL ) {
|
if ( ref != NULL ) {
|
||||||
way.path.push_back( atoi(( const char* ) ref ) );
|
way.path.push_back( stringToUint(( const char* ) ref ) );
|
||||||
xmlFree( ref );
|
xmlFree( ref );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ ImportNode XMLParser::_ReadXMLNode() {
|
|||||||
}
|
}
|
||||||
attribute = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
|
attribute = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
|
||||||
if ( attribute != NULL ) {
|
if ( attribute != NULL ) {
|
||||||
node.id = atoi(( const char* ) attribute );
|
node.id = stringToUint(( const char* ) attribute );
|
||||||
xmlFree( attribute );
|
xmlFree( attribute );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
open source routing machine
|
open source routing machine
|
||||||
Copyright (C) Dennis Luxen, others 2010
|
Copyright (C) Dennis Luxen, others 2010
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU AFFERO General Public License as published by
|
it under the terms of the GNU AFFERO General Public License as published by
|
||||||
the Free Software Foundation; either version 3 of the License, or
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
@ -21,17 +21,19 @@
|
|||||||
#ifndef XMLPARSER_H_
|
#ifndef XMLPARSER_H_
|
||||||
#define XMLPARSER_H_
|
#define XMLPARSER_H_
|
||||||
|
|
||||||
|
#include "BaseParser.h"
|
||||||
|
#include "../Util/StringUtil.h"
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#include <libxml/xmlreader.h>
|
#include <libxml/xmlreader.h>
|
||||||
|
|
||||||
#include "../typedefs.h"
|
|
||||||
#include "BaseParser.h"
|
|
||||||
|
|
||||||
class XMLParser : public BaseParser {
|
class XMLParser : public BaseParser {
|
||||||
public:
|
public:
|
||||||
XMLParser(const char* filename, ExtractorCallbacks* ec, ScriptingEnvironment& se);
|
XMLParser(const char* filename, ExtractorCallbacks* ec, ScriptingEnvironment& se);
|
||||||
bool ReadHeader();
|
bool ReadHeader();
|
||||||
bool Parse();
|
bool Parse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_RawRestrictionContainer _ReadXMLRestriction();
|
_RawRestrictionContainer _ReadXMLRestriction();
|
||||||
ExtractionWay _ReadXMLWay();
|
ExtractionWay _ReadXMLWay();
|
||||||
|
@ -62,23 +62,63 @@ static inline char* printInt( char* buffer, int value ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void intToString(const int value, std::string & output) {
|
static inline void intToString(const int value, std::string & output) {
|
||||||
// The largest 32-bit integer is 4294967295, that is 10 chars
|
|
||||||
// On the safe side, add 1 for sign, and 1 for trailing zero
|
|
||||||
output.clear();
|
output.clear();
|
||||||
std::back_insert_iterator<std::string> sink(output);
|
std::back_insert_iterator<std::string> sink(output);
|
||||||
boost::spirit::karma::generate(sink, boost::spirit::karma::int_, value);
|
boost::spirit::karma::generate(sink, boost::spirit::karma::int_, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void int64ToString(const int64_t value, std::string & output) {
|
||||||
|
output.clear();
|
||||||
|
std::back_insert_iterator<std::string> sink(output);
|
||||||
|
boost::spirit::karma::generate(sink, boost::spirit::karma::long_long, value);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int stringToInt(const std::string& input) {
|
static inline int stringToInt(const std::string& input) {
|
||||||
std::string::const_iterator realBeginOfNumber = input.begin();
|
std::string::const_iterator first_digit = input.begin();
|
||||||
//Delete any trailing white-spaces
|
//Delete any trailing white-spaces
|
||||||
while(realBeginOfNumber != input.end() && std::isspace(*realBeginOfNumber))
|
while(first_digit != input.end() && std::isspace(*first_digit)) {
|
||||||
++realBeginOfNumber;
|
++first_digit;
|
||||||
int value = 0; // 2
|
}
|
||||||
boost::spirit::qi::parse(realBeginOfNumber, input.end(), boost::spirit::int_, value); // 3
|
int value = 0;
|
||||||
|
boost::spirit::qi::parse(
|
||||||
|
first_digit,
|
||||||
|
input.end(),
|
||||||
|
boost::spirit::int_, value
|
||||||
|
);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned stringToUint(const std::string& input) {
|
||||||
|
std::string::const_iterator first_digit = input.begin();
|
||||||
|
//Delete any trailing white-spaces
|
||||||
|
while(first_digit != input.end() && std::isspace(*first_digit)) {
|
||||||
|
++first_digit;
|
||||||
|
}
|
||||||
|
int value = 0;
|
||||||
|
boost::spirit::qi::parse(
|
||||||
|
first_digit,
|
||||||
|
input.end(),
|
||||||
|
boost::spirit::uint_, value
|
||||||
|
);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t stringToInt64(const std::string& input) {
|
||||||
|
std::string::const_iterator first_digit = input.begin();
|
||||||
|
//Delete any trailing white-spaces
|
||||||
|
while(first_digit != input.end() && std::isspace(*first_digit)) {
|
||||||
|
++first_digit;
|
||||||
|
}
|
||||||
|
uint64_t value = 0;
|
||||||
|
boost::spirit::qi::parse(
|
||||||
|
first_digit,
|
||||||
|
input.end(),
|
||||||
|
boost::spirit::long_long, value
|
||||||
|
);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void doubleToString(const double value, std::string & output){
|
static inline void doubleToString(const double value, std::string & output){
|
||||||
output.clear();
|
output.clear();
|
||||||
std::back_insert_iterator<std::string> sink(output);
|
std::back_insert_iterator<std::string> sink(output);
|
||||||
|
Loading…
Reference in New Issue
Block a user