Re: [Viking-devel] Bug in track statistics code
Fix uploaded. -- Be Seeing You - Rob. If at first you don't succeed, then skydiving isn't for you. From: Kamil Ignacak Sent: 10 August 2016 17:57:24 To: viking-devel@lists.sourceforge.net Subject: [Viking-devel] Bug in track statistics code Hello, I think that I found a bug in track statistics code. Steps to reproduce the problem in viking built from freshly downloaded code: 1. open a gpx file with a single track that has some valid trackpoints; a TRW layer is created. 2. in the same layer draw a route. 3. in layers panel, mark the track as invisible, keep the route visible. 4. right-click the top layer, from menu select "Statistics". 5. toggle "Include Invisible Items" checkbox at the bottom of the dialog window. 6. observe values in "Average length" and "Max speed" category - when the checkbox is cleared, the two values are the same, with the same unit. I think that the problem can be traced to this piece of code in src/viktrwlayer_analisis.c, starting in line 314: default: //VIK_UNITS_SPEED_KILOMETRES_PER_HOUR: if ( ts.max_speed > 0 ) g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.2f km/h"), (double)VIK_MPS_TO_KPH(ts.max_speed) ); gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); When only visible items are included in statistics (i.e. only the route, but not the track), ts.max_speed is zero and tmp_buf is not updated properly, it still contains contents that has been set few lines earlier. Best regards, Kamil -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/ -- ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/
Re: [Viking-devel] Bug in track statistics code
On 10.08.2016 23:39, Robert Norris wrote: > > I'll try to sort this out when I've had less cider... > I'll just mention that there is similar code in src/viktrwlayer_propwin.cpp/void vik_trw_layer_propwin_run() that shows track statistics. Perhaps it could be somehow reused. -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/
Re: [Viking-devel] Bug in track statistics code
Yes thanks for noticing this - it does look a bit dodgy in the 'setting the maximum speed' output. I believe my idea in the switch statement is to fill the tmp_buf with the text of the value and units depending on the speed preference. Thus I don't know why any of it should be trying to use gtk_label_set_text() as that is done outside of the switch statement. The idea seems to be to use ts.max_speed if available, otherwise use length and duration and work out the max_speed if possible - for each of the speed unit variants. I'll try to sort this out when I've had less cider... -- Be Seeing You - Rob. If at first you don't succeed, then skydiving isn't for you. From: Kamil Ignacak Sent: 10 August 2016 17:57:24 To: viking-devel@lists.sourceforge.net Subject: [Viking-devel] Bug in track statistics code Hello, I think that I found a bug in track statistics code. Steps to reproduce the problem in viking built from freshly downloaded code: 1. open a gpx file with a single track that has some valid trackpoints; a TRW layer is created. 2. in the same layer draw a route. 3. in layers panel, mark the track as invisible, keep the route visible. 4. right-click the top layer, from menu select "Statistics". 5. toggle "Include Invisible Items" checkbox at the bottom of the dialog window. 6. observe values in "Average length" and "Max speed" category - when the checkbox is cleared, the two values are the same, with the same unit. I think that the problem can be traced to this piece of code in src/viktrwlayer_analisis.c, starting in line 314: default: //VIK_UNITS_SPEED_KILOMETRES_PER_HOUR: if ( ts.max_speed > 0 ) g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.2f km/h"), (double)VIK_MPS_TO_KPH(ts.max_speed) ); gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); When only visible items are included in statistics (i.e. only the route, but not the track), ts.max_speed is zero and tmp_buf is not updated properly, it still contains contents that has been set few lines earlier. Best regards, Kamil -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/ -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/
Re: [Viking-devel] Bug in track statistics code
On 10.08.2016 19:23, Robert Carter wrote: > Did you try something like? > > default: > tmp_buf = { 0 ); > //VIK_UNITS_SPEED_KILOMETRES_PER_HOUR: > if ( ts.max_speed > 0 ) > g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.2f km/h"), > (double)VIK_MPS_TO_KPH(ts.max_speed) ); > if (tmp_buf[0] != '\0') > gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); > I see what you are trying to do, but that's still not good, because now this code creates a GTK label - or not (there is "content[cnt++]" in the new 'if'). We would end up with N or N-1 GTK labels. What we want is something like this: default: //VIK_UNITS_SPEED_KILOMETRES_PER_HOUR: if ( ts.max_speed > 0 ) g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.2f km/h"), (double)VIK_MPS_TO_KPH(ts.max_speed) ); else g_snprintf ( tmp_buf, sizeof(tmp_buf), _("---")); gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); This is how it's done for other statistics items. The whole switch statement handling speed statistics item (for different speed units) should be updated along these lines. -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/
Re: [Viking-devel] Bug in track statistics code
Did you try something like? default: tmp_buf = { 0 ); //VIK_UNITS_SPEED_KILOMETRES_PER_HOUR: if ( ts.max_speed > 0 ) g_snprintf ( tmp_buf, sizeof(tmp_buf), _("%.2f km/h"), (double)VIK_MPS_TO_KPH(ts.max_speed) ); if (tmp_buf[0] != '\0') gtk_label_set_text ( GTK_LABEL(content[cnt++]), tmp_buf ); -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev ___ Viking-devel mailing list Viking-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viking-devel Viking home page: http://viking.sf.net/