1

I have a geojson for a line string that I am calculating using arc.js (great circle points between coordinates). For small distances its working fine but for long distances between one end of the map to the other its splitting at the edge of the map.

My sample geojson is { "type": "LineString", "coordinates": [[-145.6301009544453,-76.53312061015008],[-156.18585422466222,-74.14166274478148],[-163.86241788917405,-71.37485812086973],[-169.54713456209305,-68.37639324385746],[-173.87752049037576,-65.23034949960187],[-177.273869270287,-61.98650641410138],[179.98961213204112,-58.675342139275386],[177.7312181696892,-55.31624929901665],[175.827605448239,-51.92203417362932],[174.19284897373973,-48.50144540186793],[172.76556120479805,-45.0606440697877],[171.50083287170648,-41.604088572026],[170.36507685891823,-38.135085135324246],[169.3326506562472,-34.65614097995162],[168.38359172844963,-31.16919732581718],[167.50206460918528,-27.675787147025442],[166.67527277108272,-24.17714457986567],[165.8926798925103,-20.674282561250493],[165.14544057660237,-17.16804918317552],[164.42597479643274,-13.659169564999045],[163.7276418431304,-10.148277768048152],[163.04448326731617,-6.635941843727442],[162.37101313054507,-3.122684193543],[161.70203955523732,0.39100116218246084],[161.03250511911537,3.9046331725973302],[160.35733569923121,7.417729176171583],[159.67128827224414,10.929790217861825],[158.96878806699326,14.440285318173492],[158.24374432490498,17.948633633268713],[157.48933156878323,21.4541832062008],[156.69771931771774,24.95618460507045],[155.8597269211304,28.45375710037914],[154.96437045271094,31.94584402521341],[153.9982534633592,35.431152375039176],[152.94472958084322,38.908069173664686],[151.7827269087199,42.37454302017318],[150.48506229709145,45.827912396132085],[149.01597089206166,49.264650654064035],[147.32740270585123,52.67997716054833],[145.3533392009666,56.06724712127753],[143.0008639350007,59.416963791647476],[140.13582683329864,62.71512479823873],[136.55948015531268,65.94035550686907],[131.9705236419104,69.05877353832926],[125.90671079718385,72.01458026392568],[117.67362137038094,74.71301261396991],[106.3439443910232,76.99275806710631],[91.1526753047876,78.59970115426738],[72.7573555666439,79.22833102594636],[54.1715834468228,78.71394780130376]] }

It looks like:

enter image description here

Should it not continue in the same direction instead of switching to the other end of the map? How can I fix this

0

Is it displaying these lines you have trouble with? You could process a line's coordinates, detecting a change of hemisphere by a longitude sign and adding 360 to misplaced longitudes.
I've processed your sample line manually (here's the result: http://bl.ocks.org/d/c23d062aa37feae9a5a3e84ecc8ca301), you can write a script for this.

  • Needed to do some validation while adding 360 ie if the negative longitude are in decreasing order then only we should add 360. – BiJ Aug 8 '16 at 5:22
  • Yes, it seems you should find a segment where longitudes are descreasing down to -180 and the next point has a longitude of 180 or a bit less. – flire Aug 8 '16 at 15:44

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.