diff --git a/package.json b/package.json index 8de6815..3688e72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rfparty", - "version": "0.1.3", + "version": "0.1.4", "description": "", "source": "src/index.html", "scripts": { @@ -16,7 +16,7 @@ "json5": "^2.2.0", "jsonpath-plus": "^6.0.1", "last-eventemitter": "^1.1.1", - "leaflet": "^1.7.1", + "leaflet": "1.7.1", "lokijs": "^1.5.12", "moment": "^2.17.1", "moment-timezone": "^0.5.11", @@ -27,7 +27,11 @@ "author": "", "license": "Apache-2.0", "devDependencies": { + "buffer": "^6.0.3", + "events": "^3.3.0", "http-server": "^14.1.0", - "parcel": "^2.2.1" + "parcel": "^2.2.1", + "process": "^0.11.10", + "stream-browserify": "^3.0.0" } } diff --git a/src/main-window.js b/src/main-window.js index 2496b6d..d5635f8 100644 --- a/src/main-window.js +++ b/src/main-window.js @@ -211,8 +211,7 @@ export class MainWindow { window.loadingState.completeStep('read '+file.name) - - resolve(window.rfparty.addGpx(json, file.name)) + window.rfparty.addGpx.bind(window.rfparty)(json, file.name).then(resolve).catch(reject) } reader.onabort = reject @@ -225,7 +224,7 @@ export class MainWindow { } - const fileContent = await Promise.all(fileLoaders) + await Promise.all(fileLoaders) @@ -336,4 +335,4 @@ export class MainWindow { return suggestions } -} \ No newline at end of file +} diff --git a/src/rfparty.js b/src/rfparty.js index db73b44..b68bf52 100644 --- a/src/rfparty.js +++ b/src/rfparty.js @@ -75,7 +75,7 @@ export class RFParty extends EventEmitter { constructor(divId) { super() - this.showAllTracks = false + this.showAllTracks = true this.showAwayTracks = false this.detailsViewer = null @@ -128,12 +128,24 @@ export class RFParty extends EventEmitter { this.lastQuery = null this.scanDb = null - //this.gpx = {} + this.gpx = {} this.gpxLines = {} + this.gpxLayer = Leaflet.layerGroup() + + } async start() { console.log('starting') + + if(this.showAllTracks){ + + for(let name in this.gpxLines){ + this.gpxLayer.addLayer(this.gpxLines[name]) + } + + this.gpxLayer.addTo(this.map) + } this.emit('search-start') let searchStartTime = new moment() @@ -660,7 +672,7 @@ export class RFParty extends EventEmitter { getTrackPointByTime(timestamp) { let bestDeltaMs = null let bestPoint = null - let track = this.getTrackByTime(timestamp - 60000, timestamp + 6000) + let track = this.getTrackByTime(timestamp - 1200000, timestamp + 6000) for (let point of track) { let deltaMs = Math.abs(moment(point.timestamp).diff(track.timestamp)) @@ -671,6 +683,7 @@ export class RFParty extends EventEmitter { } } + return bestPoint } @@ -986,11 +999,18 @@ export class RFParty extends EventEmitter { //this.gpx[name]=obj - const trackPoints = JSONPath({ json: obj, path: '$..trkpt' })[0] + const trackPoints = JSONPath({ json: obj, path: '$..trkpt', flatten: true }) + + if(!trackPoints){ + window.loadingState.startStep('index '+name, 1) + window.loadingState.completeStep('index '+name) + console.log('added gpx', name, 'with', undefined, 'points') + return + } window.loadingState.startStep('index '+name, trackPoints.length) - const latlngs = [] + let latlngs = [] let count = 0 for (let point of trackPoints) { @@ -1032,12 +1052,17 @@ export class RFParty extends EventEmitter { //console.log('loaded gpx', name) if(this.showAllTracks){ - /*this.gpxLines[name] =*/ Leaflet.polyline(latlngs, { color: 'white', opacity: 0.4, weight: '2' }).addTo(this.map) + this.gpxLines[name] = Leaflet.polyline(latlngs, { color: 'red', opacity: 0.4, weight: '2' }) + + //this.gpxLines[name].addLayer(this.gpxLayer) + //this.gpxLayer.addLayer(this.gpxLines[name]) } window.loadingState.completeStep('index '+name) - //console.log('added gpx', name, 'with', trackPoints.length, 'points') + console.log('added gpx', name, 'with', trackPoints.length, 'points') + //console.log('latlong', latlngs) + //console.log('tracks', trackPoints) } static get Version() { @@ -1117,4 +1142,4 @@ export class RFParty extends EventEmitter { return names } -} \ No newline at end of file +}