Ejemplo n.º 1
0
	static const char *
match_b_record(const char *p, struct tm *tm, route_head **track)
{
	waypoint *w = waypt_new();
	p = match_char(p, 'B');
	struct tm _tm = *tm;
	p = match_n_digits(p, 2, &_tm.tm_hour);
	p = match_n_digits(p, 2, &_tm.tm_min);
	p = match_n_digits(p, 2, &_tm.tm_sec);
	w->creation_time = mktime(&_tm);
	int lat = 0, lat_min = 0, lat_mmin = 0;
	p = match_n_digits(p, 2, &lat);
	p = match_n_digits(p, 2, &lat_min);
	p = match_n_digits(p, 3, &lat_mmin);
	w->latitude = lat + lat_min / 60.0 + lat_mmin / 60000.0;
	char lat_hemi = 0;
	p = match_one_of(p, "NS", &lat_hemi);
	if (lat_hemi == 'S')
		w->latitude = -w->latitude;
	int lon = 0, lon_min = 0, lon_mmin = 0;
	p = match_n_digits(p, 3, &lon);
	p = match_n_digits(p, 2, &lon_min);
	p = match_n_digits(p, 3, &lon_mmin);
	w->longitude = lon + lon_min / 60.0 + lon_mmin / 60000.0;
	char lon_hemi = 0;
	p = match_one_of(p, "EW", &lon_hemi);
	if (lon_hemi == 'W')
		w->longitude = -w->longitude;
	char av = 0;
	p = match_one_of(p, "AV", &av);
	switch (av) {
		case 'A':
			w->fix = fix_3d;
			break;
		case 'V':
			w->fix = fix_2d;
			break;
	}
	int alt = 0, ele = 0;
	p = match_n_digits(p, 5, &alt);
	w->altitude = alt;
	p = match_n_digits(p, 5, &ele);
	p = match_until_eol(p);
	if (!p)
		goto error;
	if (!*track) {
		*track = route_head_alloc();
		track_add_head(*track);
	}
	track_add_wpt(*track, w);
	return p;
error:
	waypt_del(w);
	return 0;
}
Ejemplo n.º 2
0
/*
 * Decide whether to keep or toss this point.
 */
static void
fix_process_wpt(const waypoint *wpt)
{
	int del = 0;
	int delh = 0;
	int delv = 0;
	
	waypoint *waypointp = (waypoint *) wpt;

	if ((hdopf >= 0.0) && (waypointp->hdop > hdopf))
		delh = 1;
	if ((vdopf >= 0.0) && (waypointp->vdop > vdopf))
		delv = 1;
	
	if (andopt)
		del = delh && delv;
	else
		del = delh || delv;
		
        if ((satpf >= 0) && (waypointp->sat < satpf))
		del = 1;

	if ((fixnoneopt) && (waypointp->fix == fix_none))
		del = 1;

	if ((fixunknownopt) && (waypointp->fix == fix_unknown))
		del = 1;

	if ((eleminopt) && (waypointp->altitude < eleminpf))
		del = 1;

	if ((elemaxopt) && (waypointp->altitude > elemaxpf))
		del = 1;

	if (del) {
		switch(what) {
			case wptdata:
				waypt_del(waypointp);
				break;
			case trkdata:
				track_del_wpt(head, waypointp);
				break;
			case rtedata:
				route_del_wpt(head, waypointp);
				break;
			default:
				return;
		}
		waypt_free(waypointp);
	}
}