File tree Expand file tree Collapse file tree 4 files changed +1753
-0
lines changed
engine/total-downhill-time Expand file tree Collapse file tree 4 files changed +1753
-0
lines changed Original file line number Diff line number Diff line change
1
+ const convertGPX = require ( '../../core/convert-gpx-data' ) ;
2
+ const timeDifference = require ( '../../core/calculate-time-difference' ) ;
3
+ const filterDownhill = require ( '../../core/filter-downhill' ) ;
4
+
5
+ /**
6
+ * returns the total downhill time of the track
7
+ * @param {String } gpxContent - gpx document
8
+ * @returns {Number } time - elapsed time in seconds
9
+ */
10
+ const get = function ( gpxContent ) {
11
+ const points = convertGPX ( gpxContent ) ;
12
+
13
+ return filterDownhill ( points , timeDifference ) ;
14
+ } ;
15
+
16
+ module . exports = get ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " total-downhill-time" ,
3
+ "version" : " 0.0.1" ,
4
+ "description" : " " ,
5
+ "main" : " app.js" ,
6
+ "scripts" : {
7
+ "test" : " ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec spec"
8
+ },
9
+ "author" : " Maarten Groeneweg" ,
10
+ "license" : " ISC" ,
11
+ "devDependencies" : {
12
+ "istanbul" : " ^0.4.5" ,
13
+ "mocha" : " ^3.1.2"
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ const time = require ( './app.js' ) ;
2
+ const path = require ( 'path' ) ;
3
+ const fs = require ( 'fs' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ describe ( 'total downhill time' , ( ) => {
7
+ it ( 'should return a positive number' , ( ) => {
8
+ const filePath = path . join ( __dirname , '/test/data.gpx' ) ;
9
+ const gpx = fs . readFileSync ( filePath , 'utf8' ) ;
10
+ const result = time ( gpx ) ;
11
+
12
+ assert . notEqual ( result , null ) ;
13
+ } ) ;
14
+ } ) ;
You can’t perform that action at this time.
0 commit comments