gps->io.address=NULL;
gps->io.type=type;
gps->io.conn=RCVR_OFF;
-gps->data.lat=64.20;
+gps->data.lat=60.20;
gps->data.lon=22.20;
gps_data_integerize(&gps->data);
return gps;
}
+static void
+gps_simulate_start(Gps *gps)
+{
+gps->data.lat=60.45;
+gps->data.lon=22.26;
+gps->io.conn=RCVR_FIXED;
+gps->data.fix=FIX_2D;
+gps_data_integerize(&gps->data);
+}
+
static gboolean
-gps_simulate(Gps *gps)
+gps_simulate_move(Gps *gps)
{
+static gdouble slat=0, slon=0;
g_assert(gps);
-gps->data.lat+=g_random_double_range(-0.0002,0.0002);
-gps->data.lon+=g_random_double_range(-0.0002,0.0002);
+if (g_random_double()<0.5) {
+ slat=g_random_double_range(-0.0003, 0.0003);
+ slon=g_random_double_range(-0.0003, 0.0003);
+}
+gps->data.lat+=slat;
+gps->data.lon+=slon;
BOUND(gps->data.lat, -80.0, 80.0);
BOUND(gps->data.lon, -80.0, 80.0);
-gps->data.speed=1+g_random_double_range(0.0,5.0);
-gps->data.heading+=g_random_double_range(-2.0,2.0);
+
+g_debug("Sim: %f %f\n", gps->data.lat, gps->data.lon);
+
+gps->data.speed=1+g_random_double_range(0.1, 10.0);
+gps->data.heading+=g_random_double_range(-4.0, 4.0);
+BOUND(gps->data.heading, 0, 359);
gps->data.time=time(NULL);
gps_data_integerize(&gps->data);
-track_add(gps, FALSE);
+track_add(&gps->data, FALSE);
gps->data.lheading=gps->data.heading;
map_refresh_mark();
-return TRUE;
+return gps->io.conn==RCVR_FIXED ? TRUE : FALSE;
}
/**
break;
case GPS_IO_SIMULATION:
/* Set a periodic cb to generate random movement */
- gps->data.lat=64.22;
- gps->data.lat=22.22;
- gps->io.conn=RCVR_FIXED;
- gps->data.fix=FIX_2D;
- gps_data_integerize(&gps->data);
- gps->io.input_sid=g_timeout_add(1000, (GSourceFunc)gps_simulate, gps);
+ gps_simulate_start(gps);
+ gps->io.input_sid=g_timeout_add(1000, (GSourceFunc)gps_simulate_move, gps);
return FALSE;
break;
default: