Tracks & waypoints creation timestamp
This commit is contained in:
@@ -75,8 +75,9 @@ gpxParser.prototype.parse = function (gpxstring) {
|
|||||||
pt.desc = keepThis.getElementValue(wpt, "desc");
|
pt.desc = keepThis.getElementValue(wpt, "desc");
|
||||||
pt.sym = keepThis.getElementValue(wpt, "sym");
|
pt.sym = keepThis.getElementValue(wpt, "sym");
|
||||||
|
|
||||||
let time = keepThis.getElementValue(wpt, "time");
|
//let time = keepThis.getElementValue(wpt, "time");
|
||||||
pt.time = time == null ? null : new Date(time);
|
//pt.time = time == null ? null : new Date(time);
|
||||||
|
pt.time = (keepThis.getElementValue(wpt, "time") || keepThis.metadata.time) || null;;
|
||||||
|
|
||||||
keepThis.waypoints.push(pt);
|
keepThis.waypoints.push(pt);
|
||||||
}
|
}
|
||||||
@@ -113,8 +114,9 @@ gpxParser.prototype.parse = function (gpxstring) {
|
|||||||
pt.lon = parseFloat(rtept.getAttribute("lon"));
|
pt.lon = parseFloat(rtept.getAttribute("lon"));
|
||||||
pt.ele = parseFloat(keepThis.getElementValue(rtept, "ele")) || null;
|
pt.ele = parseFloat(keepThis.getElementValue(rtept, "ele")) || null;
|
||||||
|
|
||||||
let time = keepThis.getElementValue(rtept, "time");
|
//let time = keepThis.getElementValue(rtept, "time");
|
||||||
pt.time = time == null ? null : new Date(time);
|
//pt.time = time == null ? null : new Date(time);
|
||||||
|
pt.time = (keepThis.getElementValue(rtept, "time") || keepThis.metadata.time) || null;
|
||||||
|
|
||||||
routepoints.push(pt);
|
routepoints.push(pt);
|
||||||
}
|
}
|
||||||
@@ -138,6 +140,7 @@ gpxParser.prototype.parse = function (gpxstring) {
|
|||||||
track.src = keepThis.getElementValue(trk, "src");
|
track.src = keepThis.getElementValue(trk, "src");
|
||||||
track.number = keepThis.getElementValue(trk, "number");
|
track.number = keepThis.getElementValue(trk, "number");
|
||||||
track.color = keepThis.getElementValue(trk, "DisplayColor");
|
track.color = keepThis.getElementValue(trk, "DisplayColor");
|
||||||
|
track.time = keepThis.metadata.time;
|
||||||
|
|
||||||
let type = keepThis.queryDirectSelector(trk, "type");
|
let type = keepThis.queryDirectSelector(trk, "type");
|
||||||
track.type = type != null ? type.innerHTML : null;
|
track.type = type != null ? type.innerHTML : null;
|
||||||
@@ -160,8 +163,9 @@ gpxParser.prototype.parse = function (gpxstring) {
|
|||||||
pt.lon = parseFloat(trkpt.getAttribute("lon"));
|
pt.lon = parseFloat(trkpt.getAttribute("lon"));
|
||||||
pt.ele = parseFloat(keepThis.getElementValue(trkpt, "ele")) || null;
|
pt.ele = parseFloat(keepThis.getElementValue(trkpt, "ele")) || null;
|
||||||
|
|
||||||
let time = keepThis.getElementValue(trkpt, "time");
|
//let time = keepThis.getElementValue(trkpt, "time");
|
||||||
pt.time = time == null ? null : new Date(time);
|
//pt.time = time == null ? null : new Date(time);
|
||||||
|
pt.time = (keepThis.getElementValue(trkpt, "time") || keepThis.metadata.time) || null;
|
||||||
|
|
||||||
trackpoints.push(pt);
|
trackpoints.push(pt);
|
||||||
}
|
}
|
||||||
@@ -583,12 +587,16 @@ class Gaia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Build & Upload Track File
|
//Build & Upload Track File
|
||||||
uploadTrack() {
|
uploadTrack(iIndex, bSecondTry) {
|
||||||
this.feedback('info', 'Uploading tracks...');
|
iIndex = iIndex || 0;
|
||||||
|
bSecondTry = bSecondTry || false;
|
||||||
|
|
||||||
//Convert to geojson
|
if(iIndex == 0) this.feedback('info', 'Uploading tracks...');
|
||||||
let iPostedTracks = 0;
|
|
||||||
$.each(this.aoTracks, (iIndex, aoTrack) => {
|
if(iIndex < this.aoTracks.length) {
|
||||||
|
let aoTrack = this.aoTracks[i];
|
||||||
|
|
||||||
|
this.feedback('info', 'Uploading track "'+aoTrack.name+'"');
|
||||||
|
|
||||||
//Set color
|
//Set color
|
||||||
let sColor = '#4ABD32';
|
let sColor = '#4ABD32';
|
||||||
@@ -604,13 +612,13 @@ class Gaia {
|
|||||||
aoCoords.push([pt.lon, pt.lat, pt.ele, 0]);
|
aoCoords.push([pt.lon, pt.lat, pt.ele, 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Upload
|
//Convert to geojson
|
||||||
let sPostedData = JSON.stringify({
|
let sPostedData = JSON.stringify({
|
||||||
type: 'feature',
|
type: 'feature',
|
||||||
properties: {
|
properties: {
|
||||||
color: sColor,
|
color: sColor,
|
||||||
title: aoTrack.name,
|
title: aoTrack.name,
|
||||||
time_created: '2020-12-27T11:34:03.537Z',
|
time_created: aoTrack.time,
|
||||||
routing_mode: null,
|
routing_mode: null,
|
||||||
notes: aoTrack.desc,
|
notes: aoTrack.desc,
|
||||||
//distance: 168405.62350073704,
|
//distance: 168405.62350073704,
|
||||||
@@ -633,7 +641,6 @@ class Gaia {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.feedback('info', 'Uploading track "'+aoTrack.name+'"');
|
|
||||||
$.post({
|
$.post({
|
||||||
url: Gaia.API+'/track/',
|
url: Gaia.API+'/track/',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@@ -650,42 +657,18 @@ class Gaia {
|
|||||||
data: this.postedData,
|
data: this.postedData,
|
||||||
trackName: this.trackName
|
trackName: this.trackName
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
iPostedTracks++;
|
|
||||||
self.feedback('info', 'Track "'+this.trackName+'" uploaded');
|
self.feedback('info', 'Track "'+this.trackName+'" uploaded');
|
||||||
if(iPostedTracks == self.aoTracks.length) {
|
self.uploadTrack(++iIndex);
|
||||||
self.feedback('info', 'All tracks uploaded');
|
|
||||||
self.uploadWayPoints();
|
|
||||||
}
|
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
self.feedback('error', 'Track "'+this.trackName+'" failed to upload');
|
self.feedback('error', 'Track "'+this.trackName+'" failed to upload. Retrying...');
|
||||||
|
self.uploadTrack(iIndex, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
/* Legacy lethod: through form submit
|
self.feedback('info', 'All tracks uploaded');
|
||||||
|
self.uploadWayPoints();
|
||||||
//Build track file
|
}
|
||||||
this.feedback('info', 'Building consolidated track');
|
|
||||||
var oGPX = new gpxParser();
|
|
||||||
oGPX.tracks = this.aoTracks;
|
|
||||||
var sTrack = oGPX.getGPX(this.sFolderName);
|
|
||||||
|
|
||||||
//Send consolidated Tracks as one file
|
|
||||||
var oForm = new FormData();
|
|
||||||
oForm.append('name', this.sFolderName);
|
|
||||||
oForm.append('files', new Blob([sTrack]), 'Consolidated.gpx');
|
|
||||||
|
|
||||||
this.feedback('info', 'Uploading consolidated track');
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.URL+'/upload/',
|
|
||||||
type: 'POST',
|
|
||||||
data: oForm,
|
|
||||||
enctype: 'multipart/form-data',
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
cache: false
|
|
||||||
}).done(() => {this.checkNotif();});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -709,50 +692,6 @@ class Gaia {
|
|||||||
else setTimeout((() => {this.checkNotif();}), 1000);
|
else setTimeout((() => {this.checkNotif();}), 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convert QMapshack Track Colors into Gaia Colors
|
|
||||||
setTracksColor() {
|
|
||||||
this.feedback('info', 'Track Color - Matching Gaia track IDs with GPX tracks');
|
|
||||||
var iCount = 0;
|
|
||||||
|
|
||||||
$.get(Gaia.API+'/folder/'+this.sFolderId+'/').done((asFolder) => {
|
|
||||||
var self = this;
|
|
||||||
for(var iGaiaIndex in asFolder.properties.tracks) {
|
|
||||||
for(var iGpxIndex in this.aoTracks) {
|
|
||||||
if(asFolder.properties.tracks[iGaiaIndex].title == this.aoTracks[iGpxIndex].name) {
|
|
||||||
this.aoTracks[iGpxIndex].id = asFolder.properties.tracks[iGaiaIndex].id;
|
|
||||||
this.feedback('info', 'Track Color - Track "'+this.aoTracks[iGpxIndex].name+'" found a match ('+(++iCount)+'/'+this.aoTracks.length+')');
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/track/'+this.aoTracks[iGpxIndex].id+'/',
|
|
||||||
color: this.aoTracks[iGpxIndex].color
|
|
||||||
}).done(function(asGaiaTrackDisplay) {
|
|
||||||
var asGaiaTrack = asGaiaTrackDisplay.features[0];
|
|
||||||
delete asGaiaTrack.id;
|
|
||||||
delete asGaiaTrack.style;
|
|
||||||
|
|
||||||
//Set color
|
|
||||||
var sColor = '#ff0000';
|
|
||||||
switch(this.color) {
|
|
||||||
case 'DarkBlue': sColor = '#2D3FC7'; break;
|
|
||||||
case 'Magenta': sColor = '#B60DC3'; break;
|
|
||||||
}
|
|
||||||
asGaiaTrack.properties.color = sColor;
|
|
||||||
asGaiaTrack.properties.hexcolor = sColor;
|
|
||||||
|
|
||||||
self.feedback('info', 'Track Color - Setting track color "'+sColor+'" ('+this.color+') to "'+asGaiaTrack.properties.title+'"');
|
|
||||||
$.ajax({
|
|
||||||
url: Gaia.API+'/track/'+asGaiaTrack.properties.id+'/',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify(asGaiaTrack)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uploadWayPoints(iIndex, bSecondTry) {
|
uploadWayPoints(iIndex, bSecondTry) {
|
||||||
@@ -776,7 +715,7 @@ class Gaia {
|
|||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
title: sWaypointName,
|
title: sWaypointName,
|
||||||
time_created: "2020-06-07T14:01:03.944Z",
|
time_created: this.aoWaypoints[iIndex].time,
|
||||||
icon: Gaia.getIconName(this.aoWaypoints[iIndex].sym),
|
icon: Gaia.getIconName(this.aoWaypoints[iIndex].sym),
|
||||||
isValid: true,
|
isValid: true,
|
||||||
isLatestImport: true,
|
isLatestImport: true,
|
||||||
@@ -889,7 +828,7 @@ class Gaia {
|
|||||||
console.log('Loading GaiaGps Uploader...');
|
console.log('Loading GaiaGps Uploader...');
|
||||||
|
|
||||||
//To be adjusted regularly
|
//To be adjusted regularly
|
||||||
$FileInput = $('input[type=file]')
|
$FileInput = $('input[type=file]');
|
||||||
$FileButton = $('a[href="https://help.gaiagps.com/hc/en-us/articles/360052763513"]').parent().find('button');
|
$FileButton = $('a[href="https://help.gaiagps.com/hc/en-us/articles/360052763513"]').parent().find('button');
|
||||||
|
|
||||||
let oGaia = new Gaia($FileInput, $FileButton);
|
let oGaia = new Gaia($FileInput, $FileButton);
|
||||||
|
|||||||
Reference in New Issue
Block a user