Add:code:Added configurable static_speed/static_distance attributes to
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 29 Jun 2010 08:16:05 +0000 (08:16 +0000)
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 29 Jun 2010 08:16:05 +0000 (08:16 +0000)
the vehicleprofiles. They're used for static position detection. For
ticket #17

git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3445 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/attr_def.h
navit/navit/navit_shipped.xml
navit/navit/track.c
navit/navit/vehicleprofile.c

index 3cec8e3..e4ff8b3 100644 (file)
@@ -150,6 +150,8 @@ ATTR(vehicle_dangerous_goods)
 ATTR(shmsize)
 ATTR(shmoffset)
 ATTR(speed_category)
+ATTR(static_speed)
+ATTR(static_distance)
 ATTR2(0x00027500,type_rel_abs_begin)
 /* These attributes are int that can either hold relative              *
  * or absolute values. A relative value is indicated by                *
index 722f3eb..4770b96 100644 (file)
@@ -113,7 +113,7 @@ Navigation</text></img>
                <!-- For the cumulative displacement filter to be enabled, set cdf_histsize="x" here, with x being an integer somewhere around 4 -->
                <tracking cdf_histsize="0"/>
 
-               <vehicleprofile name="car" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0">
+               <vehicleprofile name="car" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0" static_speed="5" static_distance="25">
                        <roadprofile item_types="street_0,street_1_city,living_street,street_service,track_gravelled,track_unpaved" speed="10" route_weight="10">
                                        <announcement level="0" distance_metric="25"/>
                                        <announcement level="1" distance_metric="100"/>
@@ -178,7 +178,7 @@ Navigation</text></img>
                        <roadprofile item_types="ferry" speed="40" route_weight="40"/>
                </vehicleprofile>
 
-               <vehicleprofile name="bike" flags="0x40000000" flags_forward_mask="0x40000000" flags_reverse_mask="0x40000000" maxspeed_handling="1" route_mode="0">
+               <vehicleprofile name="bike" flags="0x40000000" flags_forward_mask="0x40000000" flags_reverse_mask="0x40000000" maxspeed_handling="1" route_mode="0" static_speed="5" static_distance="25">
                        <roadprofile item_types="steps" speed="2" route_weight="5">
                                        <announcement level="0" distance_metric="25"/>
                                        <announcement level="1" distance_metric="100"/>
@@ -239,7 +239,7 @@ Navigation</text></img>
                        <roadprofile item_types="ferry" speed="40" route_weight="40"/>
                </vehicleprofile>
 
-               <vehicleprofile name="pedestrian" flags="0x80000000" flags_forward_mask="0x80000000" flags_reverse_mask="0x80000000" maxspeed_handling="1" route_mode="0">
+               <vehicleprofile name="pedestrian" flags="0x80000000" flags_forward_mask="0x80000000" flags_reverse_mask="0x80000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10">
                        <roadprofile item_types="footway,bridleway,path" speed="5" route_weight="5">
                                        <announcement level="0" distance_metric="25"/>
                                        <announcement level="1" distance_metric="100"/>
@@ -288,7 +288,7 @@ Navigation</text></img>
                        <roadprofile item_types="roundabout" speed="5" route_weight="5"/>
                        <roadprofile item_types="ferry" speed="40" route_weight="40"/>
                </vehicleprofile>
-               <vehicleprofile name="horse" flags="0x20000000" flags_forward_mask="0x20000000" flags_reverse_mask="0x20000000" maxspeed_handling="1" route_mode="0">
+               <vehicleprofile name="horse" flags="0x20000000" flags_forward_mask="0x20000000" flags_reverse_mask="0x20000000" maxspeed_handling="1" route_mode="0" static_speed="3" static_distance="10">
                        <roadprofile item_types="bridleway" speed="10" route_weight="10">
                                        <announcement level="0" distance_metric="25"/>
                                        <announcement level="1" distance_metric="100"/>
index 32d26ed..97319db 100644 (file)
@@ -613,7 +613,7 @@ tracking_update(struct tracking *tr, struct vehicle *v, struct vehicleprofile *v
        int i,value,min,time;
        struct coord lpnt;
        struct coord cin;
-       struct attr valid,speed_attr,direction_attr,coord_geo,lag,time_attr;
+       struct attr valid,speed_attr,direction_attr,coord_geo,lag,time_attr,static_speed,static_distance;
        double speed, direction;
        if (v)
                tr->vehicle=v;
@@ -635,12 +635,18 @@ tracking_update(struct tracking *tr, struct vehicle *v, struct vehicleprofile *v
                dbg(0,"failed to get position data\n");
                return;
        }
+       if (!vehicleprofile_get_attr(vehicleprofile,attr_static_speed,&static_speed,NULL) || !vehicleprofile_get_attr(vehicleprofile,attr_static_distance,&static_distance,NULL)) {
+               static_speed.u.num=3;
+               static_distance.u.num=10;
+               dbg(1,"Using defaults for static position detection\n");
+       }
+       dbg(0,"Static speed: %u, static distance: %u\n",static_speed.u.num, static_distance.u.num);
        time=iso8601_to_secs(time_attr.u.str);
        speed=*speed_attr.u.numd;
        direction=*direction_attr.u.numd;
        tr->valid=attr_position_valid_valid;
        transform_from_geo(pro, coord_geo.u.coord_geo, &tr->curr_in);
-       if ((speed < 3 && transform_distance(pro, &tr->last_in, &tr->curr_in) < 10 )) {
+       if ((speed < static_speed.u.num && transform_distance(pro, &tr->last_in, &tr->curr_in) < static_distance.u.num )) {
                dbg(1,"static speed %f coord 0x%x,0x%x vs 0x%x,0x%x\n",speed,tr->last_in.x,tr->last_in.y, tr->curr_in.x, tr->curr_in.y);
                tr->valid=attr_position_valid_static;
                tr->speed=0;
index a6970c5..c80a5de 100644 (file)
@@ -66,6 +66,12 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
        case attr_vehicle_width:
                this_->width=attr->u.num;
                break;
+       case attr_static_speed:
+               this_->static_speed=attr->u.num;
+               break;
+       case attr_static_distance:
+               this_->static_distance=attr->u.num;
+               break;
        default:
                break;
        }