Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
How to extract trkpt object information from GPX Parser.js in Node.js

First of all I am Japanese. I am posting this using a translation, so if there is anything wrong with the grammar, please feel free to ask me questions. I am looking to create a system that reads GPX files in Node.js and reads and displays the highest altitude, arrival and departure times, etc. from the GPX files.

app.get('/test_gpx' , (req, res) => {
  const file = fs.createWriteStream("file.gpx");
  http.get("filepath", response => {
  response.pipe(file);
  const fs = require("fs");

  const stream = fs.createReadStream("./file.gpx", {
                    encoding: "utf8",         
                    highWaterMark: 1024       
                });

  let count = 0;    
  let total = 0;
  let chunk;
  global.variable_chunk;

  stream.on("readable", () => {
    while ( ( chunk = stream.read()) !== null ) {
      count++;
      total +=  chunk.length;
      global.variable_chunk = global.variable_chunk + chunk;
    }
  });
  stream.on("end", () => {
    
    console.log(`The data was obtained in ${count} installments.`);
    console.log(`Total ${total} bytes acquired.`);
    var gpx = new gpxParser();
    console.log(global.variable_chunk); 
    gpx.parse(global.variable_chunk); 
    var track = gpx;
    console.log(track)
  });
});
});

Lines 2 through 27 are the process of reading GPX files with fs and storing them in variables. npm uses GPX Parser.js. I don't know how to extract the information of the trkpt object because there is not much information in official tutorials etc. If anyone knows anything about this, I would appreciate it if you could enlighten me.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!