Page 16 of 21

Journey Recording using GPS Tracking

Posted: Tue Oct 01, 2013 6:27 am
by Joe Paisley

So you're saying I need to add javascript to the geolocation success service event that looks something like this:code coordsArray.push({'alt': timeStamp, 'lat': data.coords.latitude, 'lng': data.coords.longitude, 'alt': alt}); localStorage.setItem(coordsArray", JSON.stringify(coordsArray));/code
And something under code Appery('dataLabel")/code line to include
code 'Altitude: ' + data&#46;coords&#46;altitude+ '<br>' +/code
for the label on the "record ride" page to show a value. Then add
code for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000, coordsArray&#46;alt]);
}/code
after code for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000, coordsArray&#46;speed]);
}/code
so that plot2 will show the altitude data with the following code under var plot1 code var plot2 = $&#46;jqplot('plot2', [points], {
series: [{
showMarker: false
}],
axes: {
xaxis: {
label: 'Journey Time (minutes)',
labelRender: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis: {
label: 'Altitude (feet)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});/code?


Journey Recording using GPS Tracking

Posted: Tue Oct 01, 2013 5:28 pm
by Maryna Brodina

Hello! Sorry for delay, looks like it should be something like this:
precoordsArray&#46;push({'time': timeStamp, 'lat': data&#46;coords&#46;latitude, 'lng': data&#46;coords&#46;longitude, 'alt': data&#46;coords&#46;altitude, 'speed': speed});/pre


Journey Recording using GPS Tracking

Posted: Thu Oct 03, 2013 4:23 am
by Joe Paisley

The second graph still shows average speed over time, and not altitude change. I'm not sure what's happening, but my javascript on "record ride" page show event is: codeAppery("pause")&#46;hide();
Appery("start")&#46;hide();

try {
var coordsArray;
try {
coordsArray = JSON&#46;parse(localStorage&#46;getItem("coordsArray"));
if ({}&#46;toString&#46;call(coordsArray) !== "[object Array]") {
return;
}
}catch ( e ){
return;
}
var startTime = coordsArray[0]&#46;time;
var points = [];
for (var i=0; i<coordsArray&#46;length; i++){
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;speed]);
}
var plot = $&#46;jqplot('plot2', [points], {
series:[{showMarker:false}],
axes:{
xaxis:{
label:'Journey Time (minutes)',
labelRender: $&#46;jqplot&#46;CanvasAxisLabelRenderer},
yaxis:{
label:'Altitude (feet)',
labelRenderer: $jqplot&#46;CanvasAxisLabelRenderer}
}
})

var plot = $&#46;jqplot('plot1', [points], {
series:[{showMarker:false}],
axes:{
xaxis:{
label:'Journey Time (minutes)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis:{
label:'Speed (m&#47;h)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});
} catch ( e ){
}
/code
And the "results: page show event javascript looks like this: code
var coordsArray = JSON&#46;parse(localStorage&#46;getItem("coordsArray"));
var startTime = coordsArray[0]&#46;time;
var points = [];
for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000, coordsArray&#46;speed]);
}
var plot1 = $&#46;jqplot('plot1', [points], {
series: [{
showMarker: false
}],
axes: {
xaxis: {
label: 'Journey time (sec)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis: {
label: 'Speed (m&#47;h)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});
var plot2 = $&#46;jqplot('plot2', [points], {
series: [{
showMarker: false
}],
axes: {
xaxis: {
label: 'Journey Time (minutes)',
labelRender: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis: {
label: 'Altitude (feet)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});
/codeAny ideas?
Thanks so much!


Journey Recording using GPS Tracking

Posted: Thu Oct 03, 2013 3:13 pm
by Maryna Brodina

Hello! There is no code
prepoints = [];
for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000, coordsArray&#46;alt]);
}/pre
before this line
prevar plot2 = $&#46;jqplot('plot2', [points], {/pre


Journey Recording using GPS Tracking

Posted: Mon Oct 07, 2013 4:28 am
by Joe Paisley

Hi Marina!

I'm not sure what's going on. I don't see an error in logcat when I navigate to the "results page" after recording a ride. I have two graphs that show speed (m/h) on the y axis of the first graph (ie "plot1") and journey time(sec) Which should be in minutes. The second graph shows Altitude (feet) and journey time (sec) which should be in minutes. Also the second graph (ie plot 2) shows identical data panel "plot 1". When recording, the values are greatly exaggerated and inaccurate. What should I do?


Journey Recording using GPS Tracking

Posted: Mon Oct 07, 2013 8:11 am
by Maryna Brodina

Hello!
1) On result page Show event should be the following code:
prevar coordsArray = JSON&#46;parse(localStorage&#46;getItem("coordsArray"));
var startTime = coordsArray[0]&#46;time;
var points = [];
for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;speed]);
}
var plot1 = $&#46;jqplot('plot1', [points], {
series: [{
showMarker: false
}],
axes: {
xaxis: {
label: 'Journey time (minutes)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis: {
label: 'Speed (m&#47;h)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});
points = [];
for (var i = 0; i < coordsArray&#46;length; i++) {
points&#46;push([(coordsArray&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;alt]);
}
var plot2 = $&#46;jqplot('plot2', [points], {
series: [{
showMarker: false
}],
axes: {
xaxis: {
label: 'Journey Time (minutes)',
labelRender: $&#46;jqplot&#46;CanvasAxisLabelRenderer
},
yaxis: {
label: 'Altitude (feet)',
labelRenderer: $&#46;jqplot&#46;CanvasAxisLabelRenderer
}
}
});/pre
2) Are you sure you save Altitude in coordsArray in feet, not in meters?
3) [quote:] When recording, the values are greatly exaggerated and inaccurate[/quote] data could be inaccurate while there is no connection with satellite (it takes a few minutes usually) then data should be pretty accurate


Journey Recording using GPS Tracking

Posted: Tue Oct 08, 2013 5:34 am
by Joe Paisley

Now I get this in logcat after clicking "view ride data" button.
Image What could be wrong?


Journey Recording using GPS Tracking

Posted: Tue Oct 08, 2013 11:50 am
by Maryna Brodina

Hello! In code we posted there is a line prepoints&#46;push([(coordsArray{i}&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;alt]);/pre, but in your code there is
prepoints&#46;push([(coordsArray&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;alt]);/pre
You have {i} instead .


Journey Recording using GPS Tracking

Posted: Wed Oct 09, 2013 3:16 am
by Joe Paisley

Thanks Marina! But now I can't navigate to the "results" page when I click the "view ride data button." I couldn't catch any errors in logcat. What could be happening?


Journey Recording using GPS Tracking

Posted: Wed Oct 09, 2013 2:15 pm
by Joe Paisley

This shows in JSHint: Image