I have a problem with line division. I'm writing a program in JS/C++ generating KML files.

I was trying to divide a line using my own function (which is correct on cartesian space):

    var part1Lon = startLon+((-startLon + endLon)/3);
    var part1Lat = startLat +((-startLat + endLat)/3);

But when i visualized point [part1Lon, part1Lat] on Google Earth - and it's not on the line! (As I could have expected)

So, second attempt was to convert longitude and latitude to Mercator first, do calculations, and convert coordinates back to WGS. It produces similar result - point is not on the line.

What is correct algorithm or the correct projection for doing such operations?

  • GE plots the line as a great circle arc. Cartesian math on spherical (or spheroidal) coordinates will be wrong every time. Mercator is always wrong for distance (spectacularly so at high latitudes). Lots of answers here on how to do lat1,lon1,lat2,lon2->distance,bearing and lat1,lon1,distance,bearing->lat2,lon2 calculation. You just need to third (and two-thirds) the distance from F1 with F2.
    – Vince
    Mar 28, 2016 at 12:41
  • Are you writing pure JS or are you using any libraries? Mar 28, 2016 at 14:03

1 Answer 1


Thank for your comments!

I used library from movable-type website. I calculated distance and bearing (like Vince suggested), and then calculated destinationPoints using 1/3 and 2/3 of the distance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.