Ejemplo n.º 1
0
static void
enum_waypt_cb(const waypoint *wpt)
{
    garmin_fs_p gmsd;
    int wpt_class;

    gmsd = GMSD_FIND(wpt);
    wpt_class = GMSD_GET(wpt_class, 0);
    if (wpt_class < 0x80)
    {
        int i;

        if (gtxt_flags.enum_waypoints)			/* enumerate only */
        {
            waypoints++;
            return;
        }
        for (i = 0; i < wpt_a_ct; i++) {		/* check for duplicates */
            waypoint *tmp = wpt_a[i];
            if (case_ignore_strcmp(tmp->shortname, wpt->shortname) == 0)
            {
                wpt_a[i] = (waypoint *)wpt;
                waypoints--;
                return;

            }
        }
        wpt_a[wpt_a_ct++] = (waypoint *)wpt;
    }

}
Ejemplo n.º 2
0
void
garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt)
{
    char *phone, *addr;
    garmin_fs_t *gmsd = GMSD_FIND(waypt);

    if (gmsd == NULL) return;

    /* Find out if there is at least one field set */
    addr = GMSD_GET(addr, "");
    if (! *addr) addr = GMSD_GET(city, "");
    if (! *addr) addr = GMSD_GET(country, "");
    if (! *addr) addr = GMSD_GET(postal_code, "");
    if (! *addr) addr = GMSD_GET(state, "");

    phone = GMSD_GET(phone_nr, "");

    if (*addr || *phone ||
            (gmsd->flags.category && gmsd->category) ||
            WAYPT_HAS(waypt, depth) ||
            WAYPT_HAS(waypt, proximity) ||
            WAYPT_HAS(waypt, temperature) ||
            gmsd->flags.display)
    {
        int space = 1;

        gbfprintf(ofd, "%*s<extensions>\n", space++ * 2, "");
        gbfprintf(ofd, "%*s<gpxx:WaypointExtension %s\">\n", space++ * 2, "", GARMIN_GPX_EXT_REFERENCE);
        if WAYPT_HAS(waypt, proximity)
            gbfprintf(ofd, "%*s<gpxx:Proximity>%.6f</gpxx:Proximity>\n", space * 2, "", waypt->proximity);
        if WAYPT_HAS(waypt, temperature)
            gbfprintf(ofd, "%*s<gpxx:Temperature>%.6f</gpxx:Temperature>\n", space * 2, "", waypt->temperature);
        if WAYPT_HAS(waypt, depth)
            gbfprintf(ofd, "%*s<gpxx:Depth>%.6f</gpxx:Depth>\n", space * 2, "", waypt->depth);
        if (gmsd->flags.display)
        {
            char *cx;
            switch(gmsd->display)
            {
            case gt_display_mode_symbol:
                cx = "SymbolOnly";
                break;
            case gt_display_mode_symbol_and_comment:
                cx = "SymbolAndDescription";
                break;
            default:
                cx = "SymbolAndName";
                break;
            }
            gbfprintf(ofd, "%*s<gpxx:DisplayMode>%s</gpxx:DisplayMode>\n", space * 2, "", cx);
        }
        if (gmsd->flags.category && gmsd->category)
        {
            int i;
            gbuint16 cx = gmsd->category;
            gbfprintf(ofd, "%*s<gpxx:Categories>\n", space++ * 2, "");
            for (i = 0; i < 16; i++)
            {
                if (cx & 1)
                    gbfprintf(ofd, "%*s<gpxx:Category>Category %d</gpxx:Category>\n", space*2, "", i+1);
                cx = cx >> 1;
            }
            gbfprintf(ofd, "%*s</gpxx:Categories>\n", --space * 2, "");
        }
Ejemplo n.º 3
0
static void
write_waypt(const waypoint *wpt)
{
    unsigned char wpt_class;
    garmin_fs_p gmsd;
    char *wpt_type;
    char *dspl_mode;
    const char *country;
    double x;
    int i, icon, dynamic;
    char *icon_descr;

    gmsd = GMSD_FIND(wpt);

    i = GMSD_GET(display, 0);
    if (i > GT_DISPLAY_MODE_MAX) i = 0;
    dspl_mode = gt_display_mode_names[i];

    wpt_class = GMSD_GET(wpt_class, 0);
    if (wpt_class <= gt_waypt_class_map_line)
        wpt_type = gt_waypt_class_names[wpt_class];
    else
        wpt_type = gt_waypt_class_names[0];

    gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? wpt->shortname : "");
    if (wpt_class <= gt_waypt_class_airport_ndb) {
        char *temp = wpt->notes;
        if (temp == NULL) {
            if (wpt->description && (strcmp(wpt->description, wpt->shortname) != 0))
                temp = wpt->description;
            else
                temp = "";
        }
        print_string("%s\t", temp);
    }
    else
        gbfprintf(fout, "\t");
    gbfprintf(fout, "%s\t", wpt_type);

    print_position(wpt);

    if IS_VALID_ALT(wpt->altitude)
        print_distance(wpt->altitude, 1, 0, 0);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, depth, unknown_alt);
    if (x != unknown_alt)
        print_distance(x, 1, 0, 1);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, proximity, unknown_alt);
    if (x != unknown_alt)
        print_distance(x, 0, 0, 0);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, temperature, -999);
    if (x != -999)
        print_temperature(x);
    gbfprintf(fout, "\t%s\t", dspl_mode);

    gbfprintf(fout, "Unknown\t"); 				/* Color is fixed: Unknown */

    icon = GMSD_GET(icon, -1);
    if (icon == -1) {
        icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
    }
    icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
    print_string("%s\t", icon_descr);
    if (dynamic) xfree(icon_descr);

    print_string("%s\t", GMSD_GET(facility, ""));
    print_string("%s\t", GMSD_GET(city, ""));
    print_string("%s\t", GMSD_GET(state, ""));
    country = gt_get_icao_country(GMSD_GET(cc, ""));
    print_string("%s\t", (country != NULL) ? country : "");
    print_date_and_time(wpt->creation_time, 0);
    print_string("%s\t", wpt->url ? wpt->url : "");
    print_categories(GMSD_GET(category, 0));

    gbfprintf(fout, "\r\n");
}