Page 18 of 21

Journey Recording using GPS Tracking

Posted: Fri Nov 01, 2013 6:00 pm
by Maryna Brodina

Hello! You have incorrect code on success geolocation service. It should be:
preAppery("errorLabel").hide();
invokeTimes++;
Appery("dataLabel").html('Latitude: ' + data.coords.latitude + '
' +
'Longitude: ' + data.coords.longitude + '
' +
'Altitude: ' + data.coords.altitude + '
' +
'Accuracy: ' + data.coords.accuracy + '
' +
'Timestamp: ' + data.timestamp + '
');
if(!paused) {
if(oldTime != 0) {
var dist = findDistance(oldLat, oldLng, data.coords.latitude, data.coords.longitude);
totalDist += dist;
totalTime += data.timestamp - oldTime;
}
oldTime = data.timestamp;
oldLat = data.coords.latitude;
oldLng = data.coords.longitude;
Appery("totalDistLabel").text("Distance: " + round(totalDist) + 'm');
Appery("totalTimeLabel").text("Time: " + mSecToTime(totalTime));
if (totalTime0) {
Appery("avrSpeedLabel").text("Average speed: " + round(totalDist/(totalTime/(1000*3600))) + " m/h");
} else {
Appery("avrSpeedLabel").text("Average speed: 0 m/h");
}

Code: Select all

 var coordsArray = []; 
 try { 
     coordsArray = JSON.parse(localStorage.getItem("coordsArray")); 
     if ({}.toString.call(coordsArray) !== "[object Array]") { 
     coordsArray = []; 
 } 
 }catch ( e ){ 
     coordsArray = []; 
 } 
 var speed = totalTime!=0 ? round(totalDist/(totalTime/(1000*3600))) : 0; 
 var timeStamp = new Date(data.timestamp).getTime(); 
 coordsArray.push({'time': timeStamp, 'lat': data.coords.latitude, 'lng': data.coords.longitude, 'alt': data.coords.altitude, 'speed': speed});        localStorage.setItem("coordsArray", JSON.stringify(coordsArray)); 

}
updateMarker(data.coords.latitude, data.coords.longitude);/pre
2) On results page Show event there are lines:
prevar alt =
JSON.parse(localStorage.getItem("alt"));
var startTime = alt[0].time;/pre
delete them


Journey Recording using GPS Tracking

Posted: Sat Nov 02, 2013 1:23 am
by Joe Paisley

I tested the app again, and pressed "view ride data" on "recordride" page, and it produced this in logcat:
Image Is there a reason you had me remove the
within the apostrophes? Also, the "altitude" label on the "recordride" page doesn't display any information. Is there a way to force the phone to not hibernate or sleep while recording a ride? As always, thank you very much.


Journey Recording using GPS Tracking

Posted: Mon Nov 04, 2013 2:51 pm
by Maryna Brodina

Hello! Sorry, still no news. Working on it.


Journey Recording using GPS Tracking

Posted: Tue Nov 05, 2013 4:54 pm
by Kateryna Grynko

Hi Joe,

1) [quote:]not hibernate or sleep[/quote]Please take a look at here:
http://chris-allen-lane.com/2012/11/p...
http://stackoverflow.com/questions/21...

2) On 'recordride' page, in service 'geolocation1' Success event there are errors in code. For example, you have the following codepreAppery("dataLabel").html('Latitude: ' + data.coords.latitude + ....../preand there is no component named 'dataLabel' on page. If you want to fill 'altitude' in a label named 'altitude' then add the following code on 'recordride' page 'geolocation1' service Success event:preAppery("altitude").text("Altitude: " + data.coords.altitude);/pre


Journey Recording using GPS Tracking

Posted: Wed Nov 06, 2013 4:09 am
by Joe Paisley

Thanks Katya! The label is working! So I'm not sure what unit it's returning the data in, or how to round it to the nearest whole number, without any decimals. Assuming the unit is feet, and I want to round it to the nearest whole number, how would I revise the following code in "geolocation1" success event?
code Appery("altitude").text("Altitude: " + data.coords.altitude + round + "ft");
/code

The "view ride results" click event doesn't take me to the "results" page. Instead, it produces this in logcat:
Image

For applying the chris-allen-lane.com link, do I need to add the text in the PhonegapActivity.java file in Eclipse to read code@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

Code: Select all

     // this is the specific line that prevents the screen from sleeping 
     getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 

     super.loadUrl("file:///android_asset/www/results.html");/code  

after
codepublic TiggziChromeClient(CordovaInterface ctx,CordovaWebView app){super(ctx,app);}
/code as is shown in this screen shot:Image Or can I just add:codegetWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}/code after code <super.onCreate(savedInstanceState);

Code: Select all

     getWindow()&#46;addFlags(WindowManager&#46;LayoutParams&#46;FLAG_KEEP_SCREEN_ON); 
 }/code as in this capture: [url=https://d2r1vs3d9006ap.cloudfront.net/s3_images/981582/Capture2.PNG?1383711904][img]https://d2r1vs3d9006ap.cloudfront.net/s3_images/981582/Capture2_inline.PNG?1383711904[/img] [/url] 

Is it necessary to modify this .java file after each export in "Eclipse Project Source." And does this mean that I would have to install the app via Eclipse instead of simply using the binary .apk file for my android mobile phone?


Journey Recording using GPS Tracking

Posted: Wed Nov 06, 2013 2:02 pm
by Maryna Brodina

Hello! 1) If you need round off altitude use preMath&#46;round(+data&#46;coords&#46;altitude)/pre2) You don't need export to Eclipse, you can change source code on Source tab in builder.


Journey Recording using GPS Tracking

Posted: Sat Nov 09, 2013 3:03 am
by Joe Paisley

Great news Maryna! The not hibernate/sleep change is working well. Yet now that I've attempted to modify the "altitude" label, I've probably changed it to something incorrect. The "view ride data" button won't navigate to results page, and the "average speed" label and "altitude" label aren't populating any values (this is only after I changed the "geolocation1" success code to the following below: code Appery("totalDistLabel")&#46;text("Distance: " + round(totalDist) + 'm');
Appery("totalTimeLabel")&#46;text("Time: " + mSecToTime(totalTime));
Appery("altitude")&#46;text&#46;round("Altitude: " + data&#46;coords&#46;altitude + "ft");
if (totalTime>0) {
Appery("avrSpeedLabel")&#46;text("Average speed: " + round(totalDist&#47;(totalTime&#47;(1000*3600))) + " m&#47;h");
} else {
Appery("avrSpeedLabel")&#46;text("Average speed: 0 m&#47;h");
}/code

When I click on the "view ride data" button on the "record ride" page, this shows in logcat:

Image

What have I managed to do incorrectly this time? We're very close! Thanks!


Journey Recording using GPS Tracking

Posted: Tue Nov 19, 2013 2:29 am
by Joe Paisley

Any thoughts or progress as to what may be causing the problem? The process is nearly complete!


Journey Recording using GPS Tracking

Posted: Tue Nov 19, 2013 6:40 am
by Maryna Brodina

Hello Joe! I'm sorry for delay, not yet... Hope to post an update soon.


Journey Recording using GPS Tracking

Posted: Tue Nov 19, 2013 8:31 am
by Maryna Brodina

Replace preAppery("altitude")&#46;text&#46;round("Altitude: " + data&#46;coords&#46;altitude + "ft");/pre with preAppery("altitude")&#46;text("Altitude: " + Math&#46;round(data&#46;coords&#46;altitude) + "ft");/pre and preAppery("avrSpeedLabel")&#46;text("Average speed: " + round(totalDist&#47;(totalTime&#47;(10003600))) + " m&#47;h");/pre with preAppery("avrSpeedLabel")&#46;text("Average speed: " + Math&#46;round(totalDist&#47;(totalTime&#47;(10003600))) + " m&#47;h");/pre