aerostitch / testnavit

0 stars 0 forks source link

Make number of warnings for route_guard configurable #222

Open aerostitch opened 10 years ago

aerostitch commented 10 years ago

Issue migrated from trac ticket # 1204

component: core | priority: minor

2014-04-18 11:39:37: openid@bokomoko.de created the issue


route_guard is decribed here:

http://wiki.navit-project.org/index.php/OSD#route_guard

When somebody deviates from the planed route and misses the warning, he will not notice. A fix would be to make the number of warnings configurable through navit.xml

Add a num_warnings field to route_guard (and make it configurable through navit.xml) and modify in osm_core.c

            if ( this->warned == 0 && this->min_dist < min_dist && min_dist < this->max_dist) {
                    navit_say(nav, _("Return to route!"));
                    this->warned = 1;
            } else if( min_dist < this->min_dist ) {
                    this->warned = 0;
            }

to

            if ( this->warned < num_warnings && this->min_dist < min_dist && min_dist < this->max_dist) {
                    navit_say(nav, _("Return to route!"));
                    this->warned++;
            } else if( min_dist < this->min_dist ) {
                    this->warned = 0;
            }

I apologize that I could not provide a full patch file, but I never added an option to navit.xml.

Thanks, Rainer

aerostitch commented 10 years ago

2014-04-19 08:03:07: tryagain commented


Hi!

To add an option to navit.xml, at first you'll need an attribute. Look at attr_def.h and see if there exists already any suitable one, not used by route_guard osd. If there's no such an attribute, add new one to that file, keeping in mind that your attribute should be placed at the end of the section, right before ATTR2() style definition starting next section. For example, to create a simple int attribute, place it before ATTR2(0x00027500,type_rel_abs_begin) line.

Then, to easily work with attribute, you'll have to add a new member to the struct route_guard (that's what your variable num_warnings should be).

You should initialize num_warnings member in osd_route_guard_new function using attribute value supplied in navit.xml. Use attr_search for that like it's done for other attributes, don't forget to include some default value.

tryagain

p.s. Please don't forget to document your change after it's merged into svn ;)