Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turn restrictions on/off in lua profiles #580

Closed
wants to merge 5 commits into from

Conversation

emiltin
Copy link
Contributor

@emiltin emiltin commented Feb 5, 2013

implements a simple way to turn restrictions on/off in the lua profile, by setting a global:

use_turn_restrictions   = true       -- false to disable turn restrictions

this is useful in foot and bike profiles, when you don't want to restrict any turns.

based on earlier pull request from @lonvia: #479

implements it in the pbfparser only. should the xmlparser be supported too?

ERR(lua_tostring(scriptingEnvironment.getLuaStateForThreadID(0),-1)<< " occured in scripting block");
}
use_turn_restrictions = lua_toboolean(scriptingEnvironment.getLuaStateForThreadID(0), -1);
INFO("Use turn restrictions:" << use_turn_restrictions);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe delete this INFO

@emiltin
Copy link
Contributor Author

emiltin commented Feb 6, 2013

example of turn restrictions causing an odd route for bikes: http://www.ibikecph.dk/#!/x58er.7hk3f/x589s.7higf

@emiltin
Copy link
Contributor Author

emiltin commented Feb 7, 2013

maybe the bike profile still needs to respect some restrictions, like no_entry?
would it be better to pass each restriction to lua and let it decide?

@emiltin
Copy link
Contributor Author

emiltin commented Feb 7, 2013

defining a lua_restriction_function() could be optional, like the lua_turn_penalty() is handled in the turn penalties branch.

@@ -20,7 +20,7 @@

#include "PBFParser.h"

PBFParser::PBFParser(const char * fileName) : externalMemory(NULL){
PBFParser::PBFParser(const char * fileName) : externalMemory(NULL), use_turn_restrictions(true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be handled in the XML parser as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought xml was deprecated. btw none of the cuke tests use it.

@emiltin
Copy link
Contributor Author

emiltin commented Feb 10, 2013

added support for xml.

note: it lead to various refactoring of the parsers, including moving duplicated code to the base. an added benefit of proper xml support is that we can avoid the osmosis roundtrip to pbf, which makes cuke tests about 2x faster (each time the osm data needs to be reprocessed).

the commit doesn't change cuke test from pbf to xml yet, but i tried it, and it works fine.

#include "ScriptingEnvironment.h"

template<class ExternalMemoryT, typename NodeT, typename RestrictionT, typename WayT>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reason for making this a template class? it's never instantiated with different types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No apparent reason. At least none that survived the test of time.


if(!parser->Init())

if(!parser->ReadHeader())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use curly braces

@emiltin
Copy link
Contributor Author

emiltin commented Feb 12, 2013

but also other suggested code cleanuup, like adding curly brackets to oneline ifs.

@DennisOSRM
Copy link
Collaborator

The code gives a number of warnings when compiling, but I'll fix that when merging manually.

@DennisOSRM
Copy link
Collaborator

Merged manually.

@DennisOSRM DennisOSRM closed this Feb 22, 2013
@emiltin
Copy link
Contributor Author

emiltin commented Feb 23, 2013

thanks for merging.
for others using the foot or bicycle profile, note that turn restrictions are now turned off using the flag:

use_turn_restrictions = false

if you want to activate them, simply remove the line, or set the flag to true.

@emiltin
Copy link
Contributor Author

emiltin commented Feb 23, 2013

does the wiki document the master branch or the develop branch? i'm wondering if i should document the flag yet?

@DennisOSRM
Copy link
Collaborator

Go on and add it. It is about time to make the next merge into master.

Am 23.02.2013 um 08:14 schrieb Emil Tin notifications@github.com:

does the wiki document the master branch or the develop branch? i'm wondering if i should document the flag yet?


Reply to this email directly or view it on GitHub.

@emiltin
Copy link
Contributor Author

emiltin commented Feb 23, 2013

in fact the lua profiles are not documented yet anywhere, right?

@emiltin emiltin deleted the restrictions_switch branch August 8, 2014 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants