Ticket #611: navit_3490_ticket_611.patch

File navit_3490_ticket_611.patch, 5.3 KB (added by mvglasow (2), 11 years ago)

Patch to support logging ele (elevation), hdop and sat (satellites used) to GPX; tested on Windows CE. Patch includes some missing function documentation.

  • navit/attr.c

     
    662662        return 0;
    663663}
    664664
     665/**
     666 * Check if an enumeration of attribute types contains a specific attribute.
     667 *
     668 * @param types Pointer to the attr_type enumeration to be searched
     669 * @param type The attr_type to be searched for
     670 *
     671 * @return 1 if the attribute type was found, 0 if it was not found or if a null pointer was passed as types
     672 */
    665673int
    666674attr_types_contains(enum attr_type *types, enum attr_type type)
    667675{
     
    673681        return 0;
    674682}
    675683
     684/**
     685 * Check if an enumeration of attribute types contains a specific attribute.
     686 * It is different from attr_types_contains in that it returns a caller-defined value if the pointer to the enumeration is NULL.
     687 *
     688 * @param types Pointer to the attr_type enumeration to be searched
     689 * @param type The attr_type to be searched for
     690 * @param deflt The default value to return if types is NULL.
     691 *
     692 * @return 1 if the attribute type was found, 0 if it was not found, the value of the deflt argument if types is NULL.
     693 */
    676694int
    677695attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt)
    678696{
  • navit/vehicle.c

     
    171171/**
    172172 * Generic get function
    173173 *
    174  * @param this_ A vehicle
     174 * @param this_ Pointer to a vehicle structure
    175175 * @param type The attribute type to look for
    176  * @param attr A struct attr to store the attribute
     176 * @param attr Pointer to an attr structure to store the attribute
    177177 * @param iter A vehicle attr_iter
    178178 */
    179179int
     
    195195/**
    196196 * Generic set function
    197197 *
    198  * @param this_ A vehicle
    199  * @param attr
    200  * @param attrs
     198 * @param this_ Pointer to a vehicle structure
     199 * @param attr Pointer to an attr structure for the attribute to be set
     200 * @return nonzero on success, zero on failure
    201201 */
    202202int
    203203vehicle_set_attr(struct vehicle *this_, struct attr *attr)
     
    388388        }
    389389}
    390390
     391/**
     392 * Writes to an NMEA log.
     393 *
     394 * @param this_ Pointer to the vehicle structure of the data source
     395 * @param log Pointer to a log structure for the log file
     396 */
    391397static void
    392398vehicle_log_nmea(struct vehicle *this_, struct log *log)
    393399{
     
    432438        g_free(end);
    433439}
    434440
     441/**
     442 * Writes to a GPX log.
     443 *
     444 * @param this_ Pointer to the vehicle structure of the data source
     445 * @param log Pointer to a log structure for the log file
     446 */
    435447static void
    436448vehicle_log_gpx(struct vehicle *this_, struct log *log)
    437449{
     
    467479                g_free(this_->gpx_desc);
    468480                this_->gpx_desc = NULL;
    469481        }
     482        if (attr_types_contains_default(attr_types, attr_position_height,0) && this_->meth.position_attr_get(this_->priv, attr_position_height, &attr))
     483                logstr=g_strconcat_printf(logstr,"\t<ele>%.6f</ele>\n",*attr.u.numd);
     484        // <magvar> magnetic variation in degrees; we might use position_magnetic_direction and position_direction to figure it out
     485        // <geoidheight> Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message (field 11, which vehicle_wince.c ignores)
     486        // <name> GPS name (arbitrary)
     487        // <cmt> comment
     488        // <src> Source of data
     489        // <link> Link to additional information (URL)
     490        // <sym> Text of GPS symbol name
     491        // <type> Type (classification)
     492        // <fix> Type of GPS fix {'none'|'2d'|'3d'|'dgps'|'pps'}, leave out if unknown. Similar to position_fix_type but more detailed.
     493        if (attr_types_contains_default(attr_types, attr_position_sats_used,0) && this_->meth.position_attr_get(this_->priv, attr_position_sats_used, &attr))
     494                logstr=g_strconcat_printf(logstr,"\t<sat>%d</sat>\n",attr.u.num);
     495        if (attr_types_contains_default(attr_types, attr_position_hdop,0) && this_->meth.position_attr_get(this_->priv, attr_position_hdop, &attr))
     496                logstr=g_strconcat_printf(logstr,"\t<hdop>%.6f</hdop>\n",*attr.u.numd);
     497        // <vdop>, <pdop> Vertical and position dilution of precision, no corresponding attribute
    470498        if (attr_types_contains_default(attr_types, attr_position_direction,0) && this_->meth.position_attr_get(this_->priv, attr_position_direction, &attr))
    471499                logstr=g_strconcat_printf(logstr,"\t<course>%.1f</course>\n",*attr.u.numd);
    472500        if (attr_types_contains_default(attr_types, attr_position_speed, 0) && this_->meth.position_attr_get(this_->priv, attr_position_speed, &attr))
     
    488516        g_free(logstr);
    489517}
    490518
     519/**
     520 * Writes to a text log.
     521 *
     522 * @param this_ Pointer to the vehicle structure of the data source
     523 * @param log Pointer to a log structure for the log file
     524 */
    491525static void
    492526vehicle_log_textfile(struct vehicle *this_, struct log *log)
    493527{
     
    506540        log_write(log, logstr, strlen(logstr), 0);
    507541}
    508542
     543/**
     544 * Writes to a binary log.
     545 *
     546 * @param this_ Pointer to the vehicle structure of the data source
     547 * @param log Pointer to a log structure for the log file
     548 */
    509549static void
    510550vehicle_log_binfile(struct vehicle *this_, struct log *log)
    511551{
     
    560600        }
    561601}
    562602
     603/**
     604 * Register a new log to receive data.
     605 *
     606 * @param this_ Pointer to the vehicle structure of the data source
     607 * @param log Pointer to a log structure for the log file
     608 */
    563609static int
    564610vehicle_add_log(struct vehicle *this_, struct log *log)
    565611{