Skip to content

Commit

Permalink
fix toGeoJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent van der Wal committed Mar 28, 2024
1 parent d3099ac commit 4279db9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/GPXParser.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions src/GPXParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ gpxParser.prototype.calculSlope = function(points, cumul) {
* @returns {} a GeoJSON formatted Object
*/
gpxParser.prototype.toGeoJSON = function () {
var GeoJSON = {
let GeoJSON = {
"type": "FeatureCollection",
"features": [],
"properties": {
Expand All @@ -394,9 +394,8 @@ gpxParser.prototype.toGeoJSON = function () {
},
};

for(idx in this.tracks) {
let track = this.tracks[idx];

for(let idx in this.tracks) {
const track = this.tracks[idx];
var feature = {
"type": "Feature",
"geometry": {
Expand All @@ -415,10 +414,10 @@ gpxParser.prototype.toGeoJSON = function () {
feature.properties.link = track.link;
feature.properties.type = track.type;

for(idx in track.points) {
let pt = track.points[idx];
for(let idx in track.points) {
const pt = track.points[idx];

var geoPt = [];
let geoPt = [];
geoPt.push(pt.lon);
geoPt.push(pt.lat);
geoPt.push(pt.ele);
Expand All @@ -429,8 +428,8 @@ gpxParser.prototype.toGeoJSON = function () {
GeoJSON.features.push(feature);
}

for(idx in this.routes) {
let track = this.routes[idx];
for(let idx in this.routes) {
const track = this.routes[idx];

var feature = {
"type": "Feature",
Expand All @@ -451,8 +450,8 @@ gpxParser.prototype.toGeoJSON = function () {
feature.properties.type = track.type;


for(idx in track.points) {
let pt = track.points[idx];
for(let idx in track.points) {
const pt = track.points[idx];

var geoPt = [];
geoPt.push(pt.lon);
Expand All @@ -465,8 +464,8 @@ gpxParser.prototype.toGeoJSON = function () {
GeoJSON.features.push(feature);
}

for(idx in this.waypoints) {
let pt = this.waypoints[idx];
for(let idx in this.waypoints) {
const pt = this.waypoints[idx];

var feature = {
"type": "Feature",
Expand Down

0 comments on commit 4279db9

Please sign in to comment.