@@ -335,87 +335,4 @@ public void ParseToJson() {
335335 } ;
336336 JsonParser . Parse ( tempList ) ;
337337 }
338- }
339-
340- public static class HelpMethods {
341-
342- // Copied from
343- // https://stackoverflow.com/questions/6366408/calculating-distance-between-two-latitude-and-longitude-geocoordinates
344-
345- public static float DistanceTo ( XmlTimeline . Coordinates wp1 , XmlTimeline . Coordinates wp2 , char unit = 'K' ) {
346- double rlat1 = Math . PI * wp1 . lat / 180 ;
347- double rlat2 = Math . PI * wp2 . lat / 180 ;
348- double theta = wp1 . lon - wp2 . lon ;
349- double rtheta = Math . PI * theta / 180 ;
350- double dist =
351- Math . Sin ( rlat1 ) * Math . Sin ( rlat2 ) + Math . Cos ( rlat1 ) *
352- Math . Cos ( rlat2 ) * Math . Cos ( rtheta ) ;
353- dist = Math . Acos ( dist ) ;
354- dist = dist * 180 / Math . PI ;
355- dist = dist * 60 * 1.1515 ;
356-
357- float distF = ( float ) dist ;
358-
359- switch ( unit ) {
360- case 'K' : //Kilometers -> default
361- return distF * 1.609344f ;
362- case 'N' : //Nautical Miles
363- return distF * 0.8684f ;
364- case 'M' : //Miles
365- return distF ;
366- }
367-
368- return distF ;
369- }
370-
371- public static DateTime ParseIso8601 ( string iso8601Time ) {
372- return DateTime . Parse ( iso8601Time , null , System . Globalization . DateTimeStyles . RoundtripKind ) ;
373- }
374-
375- public static XmlTimeline . Coordinates GetLatLon ( string line ) {
376- string lat = "" ;
377- string lon = "" ;
378- bool captureMode = false ;
379- string capture = "" ;
380- foreach ( char item in line ) {
381- if ( item == '"' ) {
382- captureMode = ! captureMode ;
383- if ( captureMode == false ) {
384- if ( lat == "" )
385- lat = capture ;
386- else
387- lon = capture ;
388- capture = "" ;
389- }
390- } else if ( captureMode ) {
391- capture += item ;
392- }
393- }
394- return new XmlTimeline . Coordinates ( lat , lon ) ;
395- }
396- public static string LeaveCenterFromString ( string text , string removeLeft , string removeRight ) {
397- string temp = text ;
398- temp = temp . Replace ( removeLeft , "" ) ;
399- temp = temp . Replace ( removeRight , "" ) ;
400- return temp ;
401- }
402-
403- public static string ConvertToIso1601 ( DateTime time ) {
404- string output = time . ToString ( Iso1601Format ) ;
405- return output . Replace ( ":" , "" ) ;
406- }
407- public static string Iso1601Format = "yyyyMMddTHHmmsszzz" ;
408-
409- public static JsonMoves . ActivityGroup ReturnGroup ( ActivityType type ) {
410- switch ( type ) {
411- case ActivityType . walking :
412- return JsonMoves . ActivityGroup . walking ;
413- case ActivityType . running :
414- return JsonMoves . ActivityGroup . running ;
415- case ActivityType . cycling :
416- return JsonMoves . ActivityGroup . cycling ;
417- default :
418- return JsonMoves . ActivityGroup . transport ;
419- }
420- }
421- }
338+ }
0 commit comments