Implements way parsing through LUA scripting engine, implements issue #1
This commit is contained in:
@@ -31,6 +31,14 @@ public:
|
||||
virtual bool RegisterCallbacks(bool (*nodeCallbackPointer)(NodeT), bool (*restrictionCallbackPointer)(RestrictionT), bool (*wayCallbackPointer)(WayT)) = 0;
|
||||
virtual void RegisterLUAState(lua_State *myLuaState) = 0;
|
||||
virtual bool Parse() = 0;
|
||||
|
||||
void report_errors(lua_State *L, int status) {
|
||||
if ( status!=0 ) {
|
||||
std::cerr << "-- " << lua_tostring(L, -1) << std::endl;
|
||||
lua_pop(L, 1); // remove error message
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* BASEPARSER_H_ */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "ExtractionContainers.h"
|
||||
|
||||
void ExtractionContainers::PrepareData(const Settings & settings, const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM) {
|
||||
void ExtractionContainers::PrepareData(const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM) {
|
||||
try {
|
||||
unsigned usedNodeCounter = 0;
|
||||
unsigned usedEdgeCounter = 0;
|
||||
@@ -157,8 +157,6 @@ void ExtractionContainers::PrepareData(const Settings & settings, const std::str
|
||||
continue;
|
||||
}
|
||||
if(*usedNodeIDsIT == nodesIT->id) {
|
||||
if(!settings.obeyBollards && nodesIT->bollard)
|
||||
nodesIT->bollard = false;
|
||||
fout.write((char*)&(*nodesIT), sizeof(_Node));
|
||||
++usedNodeCounter;
|
||||
++usedNodeIDsIT;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
wayStartEndVector.clear();
|
||||
}
|
||||
|
||||
void PrepareData(const Settings & settings, const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM);
|
||||
void PrepareData( const std::string & outputFileName, const std::string restrictionsFileName, const unsigned amountOfRAM);
|
||||
|
||||
STXXLNodeIDVector usedNodeIDs;
|
||||
STXXLNodeVector allNodes;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
open source routing machine
|
||||
Copyright (C) Dennis Luxen, others 2010
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
or see http://www.gnu.org/licenses/agpl.txt.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef EXTRACTIONHELPERFUNCTIONS_H_
|
||||
#define EXTRACTIONHELPERFUNCTIONS_H_
|
||||
|
||||
#include <climits>
|
||||
|
||||
inline bool durationIsValid(const std::string &s) {
|
||||
boost::regex e ("((\\d|\\d\\d):)*(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl);
|
||||
|
||||
std::vector< std::string > result;
|
||||
boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ;
|
||||
bool matched = regex_match(s, e);
|
||||
return matched;
|
||||
}
|
||||
|
||||
inline unsigned parseDuration(const std::string &s) {
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
boost::regex e ("((\\d|\\d\\d):)*(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl);
|
||||
|
||||
std::vector< std::string > result;
|
||||
boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ;
|
||||
bool matched = regex_match(s, e);
|
||||
if(matched) {
|
||||
hours = (result.size()== 2) ? atoi(result[0].c_str()) : 0;
|
||||
minutes = (result.size()== 2) ? atoi(result[1].c_str()) : atoi(result[0].c_str());
|
||||
return 600*(hours*60+minutes);
|
||||
}
|
||||
return UINT_MAX;
|
||||
|
||||
}
|
||||
|
||||
inline int parseMaxspeed(std::string input) { //call-by-value on purpose.
|
||||
boost::algorithm::to_lower(input);
|
||||
int n = atoi(input.c_str());
|
||||
if (input.find("mph") != std::string::npos || input.find("mp/h") != std::string::npos) {
|
||||
n = (n*1609)/1000;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
#endif /* EXTRACTIONHELPERFUNCTIONS_H_ */
|
||||
@@ -40,40 +40,17 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
|
||||
#include "ExtractorCallbacks.h"
|
||||
|
||||
bool ExtractorCallbacks::checkForValidTiming(const std::string &s, DurationContainer & duration) {
|
||||
boost::regex e ("((\\d|\\d\\d):)*(\\d|\\d\\d)",boost::regex_constants::icase|boost::regex_constants::perl);
|
||||
|
||||
std::vector< std::string > result;
|
||||
boost::algorithm::split_regex( result, s, boost::regex( ":" ) ) ;
|
||||
bool matched = regex_match(s, e);
|
||||
if(matched) {
|
||||
duration.hours = (result.size()== 2) ? atoi(result[0].c_str()) : 0;
|
||||
duration.minutes = (result.size()== 2) ? atoi(result[1].c_str()) : atoi(result[0].c_str());
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
inline int ExtractorCallbacks::parseMaxspeed(std::string input) const { //call-by-value on purpose.
|
||||
boost::algorithm::to_lower(input);
|
||||
int n = atoi(input.c_str());
|
||||
if (input.find("mph") != std::string::npos || input.find("mp/h") != std::string::npos) {
|
||||
n = (n*1609)/1000;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
#include "ExtractionHelperFunctions.h"
|
||||
|
||||
ExtractorCallbacks::ExtractorCallbacks() {externalMemory = NULL; stringMap = NULL; }
|
||||
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers * ext, Settings set, StringMap * strMap) {
|
||||
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers * ext, StringMap * strMap) {
|
||||
externalMemory = ext;
|
||||
settings = set;
|
||||
stringMap = strMap;
|
||||
}
|
||||
|
||||
ExtractorCallbacks::~ExtractorCallbacks() {
|
||||
}
|
||||
|
||||
|
||||
/** warning: caller needs to take care of synchronization! */
|
||||
bool ExtractorCallbacks::nodeFunction(_Node &n) {
|
||||
externalMemory->allNodes.push_back(n);
|
||||
@@ -87,146 +64,9 @@ bool ExtractorCallbacks::restrictionFunction(_RawRestrictionContainer &r) {
|
||||
|
||||
/** warning: caller needs to take care of synchronization! */
|
||||
bool ExtractorCallbacks::wayFunction(_Way &w) {
|
||||
/*** Store name of way and split it into edge segments ***/
|
||||
|
||||
//Get the properties of the way.
|
||||
std::string highway( w.keyVals.Find("highway") );
|
||||
std::string name( w.keyVals.Find("name") );
|
||||
std::string ref( w.keyVals.Find("ref"));
|
||||
std::string junction( w.keyVals.Find("junction") );
|
||||
std::string route( w.keyVals.Find("route") );
|
||||
int maxspeed( parseMaxspeed(w.keyVals.Find("maxspeed")) );
|
||||
std::string man_made( w.keyVals.Find("man_made") );
|
||||
std::string barrier( w.keyVals.Find("barrier") );
|
||||
std::string oneway( w.keyVals.Find("oneway"));
|
||||
std::string cycleway( w.keyVals.Find("cycleway"));
|
||||
std::string duration ( w.keyVals.Find("duration"));
|
||||
std::string service (w.keyVals.Find("service"));
|
||||
std::string area(w.keyVals.Find("area"));
|
||||
|
||||
if("yes" == area && settings.ignoreAreas)
|
||||
return true;
|
||||
|
||||
//Save the name of the way if it has one, ref has precedence over name tag.
|
||||
if ( 0 < ref.length() )
|
||||
w.name = ref;
|
||||
else
|
||||
if ( 0 < name.length() )
|
||||
w.name = name;
|
||||
|
||||
if(junction == "roundabout") {
|
||||
w.roundabout = true;
|
||||
}
|
||||
|
||||
//Is the route tag listed as usable way in the profile?
|
||||
if(settings[route] > 0 || settings[man_made] > 0) {
|
||||
w.useful = true;
|
||||
DurationContainer dc;
|
||||
if(checkForValidTiming(duration, dc)){
|
||||
w.speed = (600*(dc.hours*60+dc.minutes))/std::max((unsigned)(w.path.size()-1),1u);
|
||||
w.isDurationSet = true;
|
||||
} else {
|
||||
w.speed = settings[route];
|
||||
}
|
||||
w.direction = _Way::bidirectional;
|
||||
if(0 < settings[route])
|
||||
highway = route;
|
||||
else if (0 < settings[man_made]) {
|
||||
highway = man_made;
|
||||
}
|
||||
}
|
||||
|
||||
//determine the access value
|
||||
std::string access;
|
||||
std::string onewayClass;
|
||||
std::string accessTag;
|
||||
BOOST_FOREACH(std::string & s, settings.accessTags) {
|
||||
access = std::string(w.keyVals.Find(s));
|
||||
if(0 < access.size()) {
|
||||
accessTag = s;
|
||||
onewayClass = std::string(w.keyVals.Find("oneway:"+access));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(0 < access.size()) {
|
||||
// handle ways with default access = no
|
||||
if(settings.accessForbiddenDefault.find(access) != settings.accessForbiddenDefault.end()) {
|
||||
access = std::string("no");
|
||||
}
|
||||
}
|
||||
|
||||
//Is the highway tag listed as usable way?
|
||||
if(0 < settings[highway] || "yes" == access || "designated" == access) {
|
||||
if(!w.isDurationSet) {
|
||||
if(0 < settings[highway]) {
|
||||
if(0 < maxspeed)
|
||||
if(settings.takeMinimumOfSpeeds)
|
||||
w.speed = std::min(settings[highway], maxspeed);
|
||||
else
|
||||
w.speed = maxspeed;
|
||||
else
|
||||
w.speed = settings[highway];
|
||||
} else {
|
||||
if(0 < maxspeed)
|
||||
if(settings.takeMinimumOfSpeeds)
|
||||
w.speed = std::min(settings.defaultSpeed, maxspeed);
|
||||
else w.speed = maxspeed;
|
||||
else
|
||||
w.speed = settings.defaultSpeed;
|
||||
highway = "default";
|
||||
}
|
||||
}
|
||||
w.useful = true;
|
||||
|
||||
//Okay, do we have access to that way?
|
||||
if(0 < access.size()) { //fastest way to check for non-empty string
|
||||
//If access is forbidden, we don't want to route there.
|
||||
if(settings.accessForbiddenKeys.find(access) != settings.accessForbiddenKeys.end()) {
|
||||
w.access = false;
|
||||
}
|
||||
if(settings.accessRestrictionKeys.find(access) != settings.accessRestrictionKeys.end()) {
|
||||
w.isAccessRestricted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(0 < service.size()) {
|
||||
if(settings.accessRestrictedService.find(service) != settings.accessRestrictedService.end()) {
|
||||
w.isAccessRestricted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("no" == access) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if( settings.obeyOneways ) {
|
||||
if( onewayClass == "yes" || onewayClass == "1" || onewayClass == "true" ) {
|
||||
w.direction = _Way::oneway;
|
||||
} else if( onewayClass == "no" || onewayClass == "0" || onewayClass == "false" ) {
|
||||
w.direction = _Way::bidirectional;
|
||||
} else if( onewayClass == "-1" ) {
|
||||
w.direction = _Way::opposite;
|
||||
} else if( oneway == "no" || oneway == "0" || oneway == "false" ) {
|
||||
w.direction = _Way::bidirectional;
|
||||
} else if( accessTag == "bicycle" && (cycleway == "opposite" || cycleway == "opposite_track" || cycleway == "opposite_lane") ) {
|
||||
w.direction = _Way::bidirectional;
|
||||
} else if( oneway == "-1") {
|
||||
w.direction = _Way::opposite;
|
||||
} else if( oneway == "yes" || oneway == "1" || oneway == "true" || junction == "roundabout" || highway == "motorway_link" || highway == "motorway" ) {
|
||||
w.direction = _Way::oneway;
|
||||
} else {
|
||||
w.direction = _Way::bidirectional;
|
||||
}
|
||||
} else {
|
||||
w.direction = _Way::bidirectional;
|
||||
}
|
||||
}
|
||||
|
||||
if ( w.useful && w.access && (1 < w.path.size()) ) { //Only true if the way is specified by the speed profile
|
||||
w.type = settings.GetHighwayTypeID(highway);
|
||||
if(0 > w.type) {
|
||||
ERR("Resolved highway " << highway << " to " << w.type);
|
||||
}
|
||||
if ( w.speed > 0 ) { //Only true if the way is specified by the speed profile
|
||||
|
||||
//Get the unique identifier for the street name
|
||||
const StringMap::const_iterator strit = stringMap->find(w.name);
|
||||
@@ -252,7 +92,7 @@ bool ExtractorCallbacks::wayFunction(_Way &w) {
|
||||
}
|
||||
|
||||
for(vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) {
|
||||
externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, highway == settings.excludeFromGrid || "pier" == highway, w.isDurationSet, w.isAccessRestricted));
|
||||
externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, w.isDurationSet, w.isAccessRestricted));
|
||||
externalMemory->usedNodeIDs.push_back(w.path[n]);
|
||||
}
|
||||
externalMemory->usedNodeIDs.push_back(w.path.back());
|
||||
@@ -262,7 +102,3 @@ bool ExtractorCallbacks::wayFunction(_Way &w) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,20 +33,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
class ExtractorCallbacks{
|
||||
private:
|
||||
Settings settings;
|
||||
StringMap * stringMap;
|
||||
ExtractionContainers * externalMemory;
|
||||
|
||||
struct DurationContainer {
|
||||
int hours;
|
||||
int minutes;
|
||||
};
|
||||
|
||||
bool checkForValidTiming(const std::string &s, DurationContainer & duration);
|
||||
inline int parseMaxspeed(std::string input) const;
|
||||
ExtractorCallbacks();
|
||||
public:
|
||||
explicit ExtractorCallbacks(ExtractionContainers * ext, Settings set, StringMap * strMap);
|
||||
explicit ExtractorCallbacks(ExtractionContainers * ext, StringMap * strMap);
|
||||
|
||||
~ExtractorCallbacks();
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
#include <climits>
|
||||
#include <string>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/regex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include "../DataStructures/Coordinate.h"
|
||||
#include "../DataStructures/HashTable.h"
|
||||
#include "../DataStructures/ImportNode.h"
|
||||
@@ -41,11 +46,12 @@ struct _Way {
|
||||
direction = _Way::notSure;
|
||||
speed = -1;
|
||||
type = -1;
|
||||
useful = false;
|
||||
// useful = false;
|
||||
access = true;
|
||||
roundabout = false;
|
||||
isDurationSet = false;
|
||||
isAccessRestricted = false;
|
||||
ignoreInGrid = false;
|
||||
}
|
||||
|
||||
enum {
|
||||
@@ -56,11 +62,12 @@ struct _Way {
|
||||
std::string name;
|
||||
double speed;
|
||||
short type;
|
||||
bool useful;
|
||||
// bool useful;
|
||||
bool access;
|
||||
bool roundabout;
|
||||
bool isDurationSet;
|
||||
bool isAccessRestricted;
|
||||
bool ignoreInGrid;
|
||||
std::vector< NodeID > path;
|
||||
HashTable<std::string, std::string> keyVals;
|
||||
};
|
||||
@@ -133,41 +140,6 @@ struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDSta
|
||||
}
|
||||
};
|
||||
|
||||
struct Settings {
|
||||
Settings() : obeyBollards(true), obeyOneways(true), useRestrictions(true), ignoreAreas(false), defaultSpeed(30), takeMinimumOfSpeeds(false), excludeFromGrid("ferry") {}
|
||||
StringToIntPairMap speedProfile;
|
||||
int operator[](const std::string & param) const {
|
||||
if(speedProfile.find(param) == speedProfile.end())
|
||||
return 0;
|
||||
else
|
||||
return speedProfile.at(param).first;
|
||||
}
|
||||
int GetHighwayTypeID(const std::string & param) const {
|
||||
if(param == excludeFromGrid) {
|
||||
return SHRT_MAX;
|
||||
}
|
||||
assert(param != "ferry");
|
||||
if(speedProfile.find(param) == speedProfile.end()) {
|
||||
ERR("There is a bug with highway \"" << param << "\"");
|
||||
return -1;
|
||||
} else {
|
||||
return speedProfile.at(param).second;
|
||||
}
|
||||
}
|
||||
bool obeyBollards;
|
||||
bool obeyOneways;
|
||||
bool useRestrictions;
|
||||
bool ignoreAreas;
|
||||
std::vector<std::string> accessTags;
|
||||
int defaultSpeed;
|
||||
bool takeMinimumOfSpeeds;
|
||||
std::string excludeFromGrid;
|
||||
boost::unordered_map<std::string, bool> accessRestrictedService;
|
||||
boost::unordered_map<std::string, bool> accessRestrictionKeys;
|
||||
boost::unordered_map<std::string, bool> accessForbiddenKeys;
|
||||
boost::unordered_map<std::string, bool> accessForbiddenDefault;
|
||||
};
|
||||
|
||||
struct Cmp : public std::binary_function<NodeID, NodeID, bool> {
|
||||
typedef NodeID value_type;
|
||||
bool operator () (const NodeID & a, const NodeID & b) const {
|
||||
|
||||
@@ -30,4 +30,6 @@ void LUA_print(T number) {
|
||||
std::cout << "[LUA] " << number << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* LUAUTIL_H_ */
|
||||
|
||||
+25
-14
@@ -234,6 +234,7 @@ private:
|
||||
denseTagIndex += 2;
|
||||
}
|
||||
|
||||
/** Pass the unpacked node to the LUA call back **/
|
||||
int ret = -1;
|
||||
try {
|
||||
ret = luabind::call_function<int>(
|
||||
@@ -249,23 +250,16 @@ private:
|
||||
report_errors(Ler, -1);
|
||||
}
|
||||
catch (...) {
|
||||
cerr<<"Unknown error!"<<endl;
|
||||
ERR("Unknown error occurred during PBF dense node parsing!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void report_errors(lua_State *L, int status)
|
||||
{
|
||||
if ( status!=0 ) {
|
||||
std::cerr << "-- " << lua_tostring(L, -1) << std::endl;
|
||||
lua_pop(L, 1); // remove error message
|
||||
}
|
||||
}
|
||||
|
||||
void parseNode(_ThreadData * threadData) {
|
||||
_Node n;
|
||||
if(!(*nodeCallback)(n))
|
||||
std::cerr << "[PBFParser] simple node not parsed" << std::endl;
|
||||
ERR("Parsing of simple nodes not supported. PBF should use dense nodes");
|
||||
// _Node n;
|
||||
// if(!(*nodeCallback)(n))
|
||||
// std::cerr << "[PBFParser] simple node not parsed" << std::endl;
|
||||
}
|
||||
|
||||
void parseRelation(_ThreadData * threadData) {
|
||||
@@ -360,8 +354,25 @@ private:
|
||||
w.keyVals.Add(key, val);
|
||||
}
|
||||
|
||||
if(!(*wayCallback)(w)) {
|
||||
std::cerr << "[PBFParser] way not parsed" << std::endl;
|
||||
/** Pass the unpacked way to the LUA call back **/
|
||||
int ret = -1;
|
||||
try {
|
||||
ret = luabind::call_function<int>(
|
||||
myLuaState,
|
||||
"way_function",
|
||||
boost::ref(w),
|
||||
w.path.size()
|
||||
);
|
||||
if(!(*wayCallback)(w)) {
|
||||
std::cerr << "[PBFParser] way not parsed" << std::endl;
|
||||
}
|
||||
} catch (const luabind::error &er) {
|
||||
cerr << er.what() << endl;
|
||||
lua_State* Ler=er.state();
|
||||
report_errors(Ler, -1);
|
||||
}
|
||||
catch (...) {
|
||||
cerr<<"Unknown error!"<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+39
-10
@@ -21,6 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#ifndef XMLPARSER_H_
|
||||
#define XMLPARSER_H_
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
#include <libxml/xmlreader.h>
|
||||
|
||||
#include "../typedefs.h"
|
||||
@@ -65,15 +66,49 @@ public:
|
||||
|
||||
if ( xmlStrEqual( currentName, ( const xmlChar* ) "node" ) == 1 ) {
|
||||
_Node n = _ReadXMLNode( );
|
||||
if(!(*nodeCallback)(n))
|
||||
std::cerr << "[XMLParser] node not parsed" << std::endl;
|
||||
/** Pass the unpacked node to the LUA call back **/
|
||||
int ret = -1;
|
||||
try {
|
||||
ret = luabind::call_function<int>(
|
||||
myLuaState,
|
||||
"node_function",
|
||||
boost::ref(n)
|
||||
);
|
||||
if(!(*nodeCallback)(n))
|
||||
std::cerr << "[XMLParser] dense node not parsed" << std::endl;
|
||||
} catch (const luabind::error &er) {
|
||||
cerr << er.what() << endl;
|
||||
lua_State* Ler=er.state();
|
||||
report_errors(Ler, -1);
|
||||
}
|
||||
catch (...) {
|
||||
ERR("Unknown error occurred during PBF dense node parsing!");
|
||||
}
|
||||
}
|
||||
|
||||
if ( xmlStrEqual( currentName, ( const xmlChar* ) "way" ) == 1 ) {
|
||||
string name;
|
||||
_Way way = _ReadXMLWay( );
|
||||
if(!(*wayCallback)(way)) {
|
||||
std::cerr << "[XMLParser] way not parsed" << std::endl;
|
||||
|
||||
/** Pass the unpacked way to the LUA call back **/
|
||||
int ret = -1;
|
||||
try {
|
||||
ret = luabind::call_function<int>(
|
||||
myLuaState,
|
||||
"way_function",
|
||||
boost::ref(way),
|
||||
way.path.size()
|
||||
);
|
||||
if(!(*wayCallback)(way)) {
|
||||
std::cerr << "[PBFParser] way not parsed" << std::endl;
|
||||
}
|
||||
} catch (const luabind::error &er) {
|
||||
cerr << er.what() << endl;
|
||||
lua_State* Ler=er.state();
|
||||
report_errors(Ler, -1);
|
||||
}
|
||||
catch (...) {
|
||||
cerr<<"Unknown error!"<<endl;
|
||||
}
|
||||
}
|
||||
if ( xmlStrEqual( currentName, ( const xmlChar* ) "relation" ) == 1 ) {
|
||||
@@ -157,12 +192,6 @@ private:
|
||||
|
||||
_Way _ReadXMLWay( ) {
|
||||
_Way way;
|
||||
way.direction = _Way::notSure;
|
||||
way.speed = -1;
|
||||
way.type = -1;
|
||||
way.useful = false;
|
||||
way.access = true;
|
||||
// cout << "new way" << endl;
|
||||
if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) {
|
||||
const int depth = xmlTextReaderDepth( inputReader );
|
||||
while ( xmlTextReaderRead( inputReader ) == 1 ) {
|
||||
|
||||
Reference in New Issue
Block a user