How am I supposed to get Track Stats to work? I'm added the CCK Track Stat field, and referenced it to my uploaded GPX file, and tried configuring it to use the presets of time, distance, etc. But I'm not getting these stats out of it, I seem to get a "0".

I'm a little confused why the stat field shows up on the form when creating a node, shouldn't it behave like the Track Map or Track Graph fields?

Any tips on how to properly use this field?

Comments

raintonr’s picture

Component: Miscellaneous » Documentation
Assigned: Unassigned » raintonr

Track Stat is shown on the form so people can override any automatic values. Yes, that sounds a bit odd and perhaps there should be no manual override option.

If you have correctly configured the 'Reference field name' and used a 'Preset Statistic' then it should work.

Do you get a graph or map plot to work for your GPX (thus proving it's stat that's the the problem)?

wcleong’s picture

I think I've figured out the problem. I was trying to use the time preset, but there's a bug with the code. The preset references a "time" argument, but time doesn't exist, though there is a "seconds" argument. So in the stat module, I had to change the time preset from:

  /* Time related */
  'time' => array(
    'label' => 'Time',
    'op' => 'end',
    'args' => array('time')),

To this:

  /* Time related */
  'time' => array(
    'label' => 'Time',
    'op' => 'end',
    'args' => array('seconds')),

Also, I didn't realize that there was a manual override, and that I had to resubmit a blank stat field if I wanted it to update the statistic, that's why I didn't think it worked for the other presets. I haven't had the chance to check all of the presets, but by changing the "time" to "seconds" I got the time preset to work.

Btw, I think the manual override is a nice thing to have, It allows me to enter a value in for the mode even if I don't happen to have GPS information. Though perhaps it would be nice to keep track which nodes were using an override, so that if someone were to change the type of statistic for a particular field they wouldn't have to go through each node and manually clear and submit the each node.

wcleong’s picture

Component: Documentation » Code
Category: support » bug

I've changed the category to bug report, now that I've had more time to investigate. My last comment applied to the time statistic, but I've found another bug that will affect this field. The module seems to require that the Track field comes before any Track Stat field; the order of the fields matter. It looks like in this chunk of code:

  case 'presave':
    /*
     * Calculate stat if no input was given and that is possible.
     */
    $field_name = $field['reference_field_name'];
    $fset = $node->$field_name;

the $fset variable gets set only if the Track field has already been processed. If the Stats field comes before the Track field, this variable is not set. I'm not that familiar with the drupal system to know the best solution to this problem.

Hope I'm not causing too much trouble for you with all of my posts, I can only imagine how difficult it can be to maintain a module!

wcleong’s picture

ok, another update to this bug:

It looks like only the first Track Stat field doesn't get populated. All subsequent Track Stat fields get the data ok. I'm not sure what is different about the first one.

raintonr’s picture

Thanks for your help... yeah, that's a bit odd. Will try and replicate and find a fix.

raintonr’s picture

Title: Having trouble using Track Stat » Track Stat must come after data field.

Seems that a couple of people have reported this and the stat field must come after the data field it references for calculation.

smscotten’s picture

Sorry to hijack this thread back to the original bug report, but is there any chance of getting wcleong's fix from #2 rolled into the module? That was proposed a year ago and it's an easy fix, sort of a glaring omission.

Is it different for different data types? This fix only works (for me) with CRS. It doesn't help with GPX. Of course, KML doesn't have coordinate time data.