Format route points as waypoints
This commit is contained in:
parent
449a24e5ce
commit
7fc2f6bee5
8 changed files with 380 additions and 19 deletions
|
|
@ -69,6 +69,9 @@ BR.Export = L.Class.extend({
|
|||
|
||||
_formatTrack: function (format, name, includeWaypoints) {
|
||||
const track = BR.Export._concatTotalTrack(this.segments);
|
||||
if (includeWaypoints) {
|
||||
this._addRouteWaypoints(track);
|
||||
}
|
||||
//console.log('GeoJson: ', trackGeoJson);
|
||||
//console.log('GeoJson: ', JSON.stringify(trackGeoJson, null, 4));
|
||||
switch (format) {
|
||||
|
|
@ -85,6 +88,24 @@ BR.Export = L.Class.extend({
|
|||
console.error('Export format not implemented: ' + format);
|
||||
},
|
||||
|
||||
_addRouteWaypoints: function (track) {
|
||||
const routePoints = [];
|
||||
for (const [i, latLng] of this.latLngs.entries()) {
|
||||
let name = 'via' + i;
|
||||
let type = 'via';
|
||||
if (i === 0) {
|
||||
name = 'from';
|
||||
type = 'from';
|
||||
} else if (i === this.latLngs.length - 1) {
|
||||
name = 'to';
|
||||
type = 'to';
|
||||
}
|
||||
const properties = { name, type };
|
||||
routePoints.push(turf.point([latLng.lng, latLng.lat], properties));
|
||||
}
|
||||
track.features.push(...routePoints);
|
||||
},
|
||||
|
||||
_validationMessage: function () {
|
||||
var trackname = this.trackname;
|
||||
var replaceRegex = new RegExp('[^' + this.tracknameAllowedChars + ']', 'g');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue