Monday, 29 May 2017

Find cross-points in two routes

i have a problem.

I need to find cross-points of two routes

Routes i have as array look like [[lat, lng], [lat, lng], ...]

And that's how i'm currently searching thoose points via for loops:

parsed.forEach(function(entry){
    userParsed.forEach(function(userEntry){
      var distance = geolib.getDistanceSimple(
          {latitude: entry[0], longitude: entry[1]},
          {latitude: userEntry[0], longitude: userEntry[1]}
      );
      if (distance < 100) {
        console.log(distance + "meters");
      }
    });
});

But if in arrays thousands of points, it can take a while, and even crash the nodejs

Hope someone know a way to proceed so big amounts of data :)

Thx in advance!



via dennes544

No comments:

Post a Comment