Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Journey Recording using GPS Tracking

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

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Journey Recording using GPS Tracking

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

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Journey Recording using GPS Tracking

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

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Journey Recording using GPS Tracking

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 .

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

This shows in JSHint: Image

Return to “Issues”