CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.98k stars 3.5k forks source link

czml interpolation error (in CesiumViewer) when crossing between 180 and -180 degrees longitude. #636

Closed tadufre closed 11 years ago

tadufre commented 11 years ago

CZML paths with cartographicDegree coordinates that cross between 180 and -180 degrees longitude result in incorrect paths. (image from CesiumViewer in Sandcastle)

issue

CZML:

[ { "id":"/Application/STK/Scenario/simple/Satellite/PRN25", "availability":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "billboard":{ "eyeOffset":{ "cartesian":[ 0.0,0.0,0.0 ] }, "horizontalOrigin":"CENTER", "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADGSURBVDhPnVPbDcMgDGQ0RmGUjsIojNIR+p8Piq+5xvGDSo2EEgH3yNku5Y9nrucnLLt07ssrJsHJ59Bdko1aB1Z0DkRrDxy2Wm6XNLj1MWU5F1R+jjJ7cyRQJli+bwRf28drCgFJxI2yCwIHZqKWRICRk20VSALV5WZ0T8KgQyJdBVHXJAh3hcygwxBNifALQsIctLoLkTW2JASLcmpbg1kqC8waDA1EAt0ktKuVVUbXOJA56rBU1U7Trv9D1Wgctw2SzO8bB7GiztrZSh0AAAAASUVORK5CYII=", "pixelOffset":{ "cartesian2":[ 0.0,0.0 ] }, "scale":1.5, "show":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "boolean":true } ], "verticalOrigin":"CENTER" }, "label":{ "fillColor":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "rgba":[ 0,255,0,255 ] } ], "font":"10pt Lucida Console", "horizontalOrigin":"LEFT", "outlineColor":{ "rgba":[ 0,0,0,255 ] }, "pixelOffset":{ "cartesian2":[ 12.0,0.0 ] }, "scale":1.0, "show":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "boolean":true } ], "style":"FILL", "text":"GPS BIIF-1 (PRN 25)", "verticalOrigin":"CENTER" }, "path":{ "color":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "rgba":[ 0,255,0,255 ] } ], "outlineWidth":0.0, "width":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "number":1.0 } ], "show":[ { "interval":"2012-03-15T10:00:00Z/2012-03-16T10:00:00Z", "boolean":true } ], "leadTime":86400}, "position":{ "interpolationAlgorithm":"LINEAR", "interpolationDegree":1, "referenceFrame":"FIXED", "epoch":"2012-03-15T10:00:00Z", "cartographicDegrees":[0.0,39.625718,-25.349832,20205702.733887 , 300.0,40.159418,-27.275162,20205933.125911 , 600.0,40.755643,-29.176869,20206147.188553 , 900.0,41.421119,-31.052084,20206341.267312 , 1200.0,42.163014,-32.897647,20206511.657079 , 1500.0,42.988939,-34.710068,20206654.634339 , 1800.0,43.906944,-36.485486,20206766.490290 , 2100.0,44.925480,-38.219629,20206843.563895 , 2400.0,46.053334,-39.907769,20206882.275228 , 2700.0,47.299521,-41.544685,20206879.158363 , 3000.0,48.673115,-43.124619,20206830.893887 , 3300.0,50.183014,-44.641249,20206734.340551 , 3600.0,51.837616,-46.087672,20206586.566020 , 3900.0,53.644397,-47.456407,20206384.876164 , 4200.0,55.609381,-48.739423,20206126.843135 , 4500.0,57.736509,-49.928213,20205810.331322 , 4800.0,60.026918,-51.013905,20205433.521859 , 5100.0,62.478179,-51.987436,20204994.934372 , 5400.0,65.083562,-52.839785,20204493.447138 , 5700.0,67.831434,-53.562269,20203928.313944 , 6000.0,70.704900,-54.146880,20203299.178834 , 6300.0,73.681812,-54.586660,20202606.088214 , 6600.0,76.735252,-54.876063,20201849.499180 , 6900.0,79.834495,-55.011279,20201030.286200 , 7200.0,82.946436,-54.990469,20200149.743215 , 7500.0,86.037287,-54.813881,20199209.584323 , 7800.0,89.074388,-54.483839,20198211.939537 , 8100.0,92.027854,-54.004587,20197159.349387 , 8400.0,94.871894,-53.382032,20196054.754511 , 8700.0,97.585654,-52.623409,20194901.483505 , 9000.0,100.153577,-51.736908,20193703.237942 , 9300.0,102.565308,-50.731311,20192464.072932 , 9600.0,104.815263,-49.615662,20191188.377322 , 9900.0,106.901982,-48.398981,20189880.848684 , 10200.0,108.827379,-47.090056,20188546.468545 , 10500.0,110.595984,-45.697278,20187190.472591 , 10800.0,112.214246,-44.228540,20185818.321635 , 11100.0,113.689918,-42.691180,20184435.668025 , 11400.0,115.031565,-41.091954,20183048.322243 , 11700.0,116.248157,-39.437043,20181662.218134 , 12000.0,117.348778,-37.732070,20180283.375142 , 12300.0,118.342400,-35.982138,20178917.862462 , 12600.0,119.237741,-34.191861,20177571.759625 , 12900.0,120.043161,-32.365413,20176251.119708 , 13200.0,120.766605,-30.506566,20174961.929583 , 13500.0,121.415580,-28.618736,20173710.073260 , 13800.0,121.997148,-26.705018,20172501.293108 , 14100.0,122.517933,-24.768223,20171341.153626 , 14400.0,122.984147,-22.810917,20170235.006171 , 14700.0,123.401613,-20.835446,20169187.953500 , 15000.0,123.775799,-18.843964,20168204.818130 , 15300.0,124.111849,-16.838462,20167290.110227 , 15600.0,124.414617,-14.820791,20166447.999707 , 15900.0,124.688706,-12.792676,20165682.288565 , 16200.0,124.938497,-10.755742,20164996.387551 , 16500.0,125.168181,-8.711529,20164393.293833 , 16800.0,125.381798,-6.661507,20163875.572567 , 17100.0,125.583259,-4.607090,20163445.341195 , 17400.0,125.776384,-2.549651,20163104.256190 , 17700.0,125.964927,-0.490538,20162853.503860 , 18000.0,126.152606,1.568920,20162693.793549 , 18300.0,126.343133,3.627394,20162625.354727 , 18600.0,126.540244,5.683548,20162647.936930 , 18900.0,126.747723,7.736020,20162760.813222 , 19200.0,126.969436,9.783418,20162962.786830 , 19500.0,127.209362,11.824298,20163252.201023 , 19800.0,127.471617,13.857153,20163626.951905 , 20100.0,127.760492,15.880399,20164084.504694 , 20400.0,128.080485,17.892358,20164621.912200 , 20700.0,128.436330,19.891237,20165235.836942 , 21000.0,128.833037,21.875113,20165922.574785 , 21300.0,129.275921,23.841908,20166678.082211 , 21600.0,129.770641,25.789364,20167498.004395 , 21900.0,130.323229,27.715019,20168377.706676 , 22200.0,130.940120,29.616178,20169312.306822 , 22500.0,131.628179,31.489877,20170296.708640 , 22800.0,132.394712,33.332849,20171325.638140 , 23100.0,133.247472,35.141488,20172393.678717 , 23400.0,134.194644,36.911807,20173495.309189 , 23700.0,135.244800,38.639394,20174624.940018 , 24000.0,136.406825,40.319371,20175776.951992 , 24300.0,137.689789,41.946353,20176945.732380 , 24600.0,139.102766,43.514411,20178125.712962 , 24900.0,140.654570,45.017047,20179311.405833 , 25200.0,142.353409,46.447178,20180497.438231 , 25500.0,144.206428,47.797150,20181678.587742 , 25800.0,146.219147,49.058776,20182849.813662 , 26100.0,148.394804,50.223420,20184006.289193 , 26400.0,150.733612,51.282126,20185143.429200 , 26700.0,153.231995,52.225809,20186256.918331 , 27000.0,155.881875,53.045507,20187342.734361 , 27300.0,158.670125,53.732693,20188397.171321 , 27600.0,161.578302,54.279622,20189416.858472 , 27900.0,164.582783,54.679713,20190398.776574 , 28200.0,167.655388,54.927901,20191340.272628 , 28500.0,170.764487,55.020940,20192239.069650 , 28800.0,173.876528,54.957610,20193093.275484 , 29100.0,176.957796,54.738794,20193901.386590 , 29400.0,179.976209,54.367424,20194662.290619 , 29700.0,-177.097114,53.848292,20195375.264154 , 30000.0,-174.286651,53.187765,20196039.969008 , 30300.0,-171.611775,52.393432,20196656.444478 , 30600.0,-169.086537,51.473731,20197225.096823 , 30900.0,-166.719864,50.437588,20197746.686723 , 31200.0,-164.516075,49.294099,20198222.312896 , 31500.0,-162.475566,48.052267,20198653.394347 , 31800.0,-160.595576,46.720805,20199041.649189 , 32100.0,-158.870934,45.307990,20199389.072235 , 32400.0,-157.294740,43.821576,20199697.909725 , 32700.0,-155.858939,42.268747,20199970.633022 , 33000.0,-154.554797,40.656102,20200209.910246 , 33300.0,-153.373270,38.989665,20200418.576669 , 33600.0,-152.305273,37.274909,20200599.604313 , 33900.0,-151.341883,35.516791,20200756.070285 , 34200.0,-150.474471,33.719793,20200891.124945 , 34500.0,-149.694786,31.887967,20201007.959404 , 34800.0,-148.995003,30.024970,20201109.773278 , 35100.0,-148.367743,28.134117,20201199.742377 , 35400.0,-147.806070,26.218409,20201280.987093 , 35700.0,-147.303485,24.280573,20201356.541350 , 36000.0,-146.853893,22.323097,20201429.322553 , 36300.0,-146.451581,20.348257,20201502.102836 , 36600.0,-146.091187,18.358146,20201577.481595 , 36900.0,-145.767659,16.354697,20201657.859839 , 37200.0,-145.476229,14.339706,20201745.416236 , 37500.0,-145.212372,12.314854,20201842.085377 , 37800.0,-144.971778,10.281722,20201949.538084 , 38100.0,-144.750315,8.241810,20202069.164270 , 38400.0,-144.544000,6.196551,20202202.058209 , 38700.0,-144.348969,4.147326,20202349.006393 , 39000.0,-144.161442,2.095479,20202510.478323 , 39300.0,-143.977702,0.042329,20202686.619807 , 39600.0,-143.794057,-2.010820,20202877.249458 , 39900.0,-143.606818,-4.062662,20203081.857710 , 40200.0,-143.412270,-6.111880,20203299.609139 , 40500.0,-143.206637,-8.157134,20203529.347235 , 40800.0,-142.986061,-10.197044,20203769.602458 , 41100.0,-142.746566,-12.230181,20204018.602790 , 41400.0,-142.484033,-14.255049,20204274.286992 , 41700.0,-142.194161,-16.270075,20204534.320808 , 42000.0,-141.872440,-18.273585,20204796.115153 , 42300.0,-141.514119,-20.263791,20205056.847207 , 42600.0,-141.114165,-22.238769,20205313.483150 , 42900.0,-140.667235,-24.196438,20205562.803462 , 43200.0,-140.167640,-26.134534,20205801.429506 , 43500.0,-139.609313,-28.050586,20206025.852241 , 43800.0,-138.985780,-29.941883,20206232.461985 , 44100.0,-138.290139,-31.805440,20206417.579384 , 44400.0,-137.515041,-33.637970,20206577.487573 , 44700.0,-136.652695,-35.435835,20206708.464635 , 45000.0,-135.694882,-37.195014,20206806.816843 , 45300.0,-134.633006,-38.911054,20206868.911776 , 45600.0,-133.458169,-40.579033,20206891.211567 , 45900.0,-132.161310,-42.193513,20206870.305642 , 46200.0,-130.733394,-43.748513,20206802.942934 , 46500.0,-129.165682,-45.237475,20206686.063159 , 46800.0,-127.450094,-46.653260,20206516.827081 , 47100.0,-125.579673,-47.988157,20206292.645215 , 47400.0,-123.549162,-49.233933,20206011.205239 , 47700.0,-121.355667,-50.381914,20205670.497164 , 48000.0,-118.999410,-51.423126,20205268.837023 , 48300.0,-116.484482,-52.348494,20204804.887660 , 48600.0,-113.819543,-53.149095,20204277.677922 , 48900.0,-111.018339,-53.816475,20203686.618436 , 49200.0,-108.099924,-54.343011,20203031.515246 , 49500.0,-105.088471,-54.722274,20202312.580775 , 49800.0,-102.012586,-54.949390,20201530.440916 , 50100.0,-98.904152,-55.021326,20200686.140522 , 50400.0,-95.796767,-54.937084,20199781.144217 , 50700.0,-92.723973,-54.697767,20198817.335853 , 51000.0,-89.717485,-54.306502,20197797.012975 , 51300.0,-86.805660,-53.768246,20196722.880185 , 51600.0,-84.012355,-53.089488,20195598.037485 , 51900.0,-81.356288,-52.277896,20194425.966916 , 52200.0,-78.850871,-51.341944,20193210.516409 , 52500.0,-76.504451,-50.290556,20191955.879202 , 52800.0,-74.320853,-49.132796,20190666.572980 , 53100.0,-72.300073,-47.877615,20189347.413829 , 53400.0,-70.439045,-46.533652,20188003.490548 , 53700.0,-68.732381,-45.109108,20186640.133966 , 54000.0,-67.173035,-43.611653,20185262.887143 , 54300.0,-65.752869,-42.048391,20183877.471083 , 54600.0,-64.463113,-40.425843,20182489.750742 , 54900.0,-63.294720,-38.749960,20181105.699765 , 55200.0,-62.238629,-37.026148,20179731.362340 , 55500.0,-61.285956,-35.259308,20178372.817064 , 55800.0,-60.428121,-33.453868,20177036.137377 , 56100.0,-59.656927,-31.613836,20175727.354701 , 56400.0,-58.964604,-29.742833,20174452.418767 , 56700.0,-58.343827,-27.844140,20173217.161115 , 57000.0,-57.787715,-25.920734,20172027.256619 , 57300.0,-57.289813,-23.975321,20170888.187646 , 57600.0,-56.844072,-22.010374,20169805.209282 , 57900.0,-56.444815,-20.028158,20168783.314504 , 58200.0,-56.086713,-18.030759,20167827.203223 , 58500.0,-55.764741,-16.020107,20166941.251006 , 58800.0,-55.474152,-13.998000,20166129.482038 , 59100.0,-55.210438,-11.966121,20165395.542464 , 59400.0,-54.969299,-9.926058,20164742.678073 , 59700.0,-54.746608,-7.879320,20164173.713120 , 60000.0,-54.538382,-5.827353,20163691.033048 , 60300.0,-54.340751,-3.771553,20163296.570008 , 60600.0,-54.149925,-1.713282,20162991.790900 , 60900.0,-53.962167,0.346122,20162777.689439 , 61200.0,-53.773766,2.405332,20162654.780714 , 61500.0,-53.581004,4.463017,20162623.099569 , 61800.0,-53.380128,6.517833,20162682.201922 , 62100.0,-53.167325,8.568406,20162831.169507 , 62400.0,-52.938686,10.613324,20163068.617848 , 62700.0,-52.690182,12.651121,20163392.707404 , 63000.0,-52.417627,14.680259,20163801.157587 , 63300.0,-52.116652,16.699119,20164291.264265 , 63600.0,-51.782667,18.705978,20164859.919337 , 63900.0,-51.410829,20.698993,20165503.633957 , 64200.0,-50.996009,22.676181,20166218.563134 , 64500.0,-50.532755,24.635393,20167000.533953 , 64800.0,-50.015263,26.574292,20167845.074448 , 65100.0,-49.437339,28.490325,20168747.445836 , 65400.0,-48.792375,30.380691,20169702.675407 , 65700.0,-48.073331,32.242308,20170705.590662 , 66000.0,-47.272716,34.071778,20171750.855918 , 66300.0,-46.382600,35.865342,20172833.007792 , 66600.0,-45.394633,37.618847,20173946.493460 , 66900.0,-44.300106,39.327696,20175085.706952 , 67200.0,-43.090041,40.986811,20176245.027821 , 67500.0,-41.755339,42.590589,20177418.857160 , 67800.0,-40.286996,44.132873,20178601.655386 , 68100.0,-38.676396,45.606927,20179787.977685 , 68400.0,-36.915706,47.005435,20180972.508374 , 68700.0,-34.998364,48.320518,20182150.095544 , 69000.0,-32.919695,49.543796,20183315.781762 , 69300.0,-30.677597,50.666482,20184464.835504 , 69600.0,-28.273305,51.679542,20185592.778076 , 69900.0,-25.712146,52.573908,20186695.410809 , 70200.0,-23.004195,53.340755,20187768.837422 , 70500.0,-20.164728,53.971829,20188809.486082 , 70800.0,-17.214334,54.459813,20189814.127273 , 71100.0,-14.178590,54.798700,20190779.888916 , 71400.0,-11.087237,54.984135,20191704.269897 , 71700.0,-7.972885,55.013675,20192585.148643 , 72000.0,-4.869373,54.886953,20193420.790674 , 72300.0,-1.809958,54.605699,20194209.851154 , 72600.0,1.174407,54.173629,20194951.376208 , 72900.0,4.056513,53.596215,20195644.799440 , 73200.0,6.813899,52.880365,20196289.936996 , 73500.0,9.429356,52.034056,20196886.978641 , 73800.0,11.890958,51.065966,20197436.476091 , 74100.0,14.191725,49.985126,20197939.329359 , 74400.0,16.329021,48.800623,20198396.769336 , 74700.0,18.303825,47.521361,20198810.339049 , 75000.0,20.119964,46.155890,20199181.871580 , 75300.0,21.783387,44.712283,20199513.466814 , 75600.0,23.301528,43.198066,20199807.465424 , 75900.0,24.682767,41.620185,20200066.421898 , 76200.0,25.936003,39.985003,20200293.075609 , 76500.0,27.070325,38.298318,20200490.320748 , 76800.0,28.094771,36.565386,20200661.175543 , 77100.0,29.018158,34.790969,20200808.750336 , 77400.0,29.848969,32.979367,20200936.215589 , 77700.0,30.595285,31.134467,20201046.769335 , 78000.0,31.264753,29.259783,20201143.604977 , 78300.0,31.864568,27.358497,20201229.879146 , 78600.0,32.401488,25.433494,20201308.680345 , 78900.0,32.881846,23.487402,20201382.998265 , 79200.0,33.311574,21.522618,20201455.694202 , 79500.0,33.696241,19.541340,20201529.472856 , 79800.0,34.041080,17.545595,20201606.855516 , 80100.0,34.351021,15.537257,20201690.155144 , 80400.0,34.630730,13.518073,20201781.453229 , 80700.0,34.884641,11.489681,20201882.578939 , 81000.0,35.116988,9.453627,20201995.090374 , 81300.0,35.331838,7.411382,20202120.258443 , 81600.0,35.533123,5.364356,20202259.053178 , 81900.0,35.724668,3.313916,20202412.132701 , 82200.0,35.910224,1.261391,20202579.835145 , 82500.0,36.093496,-0.791906,20202762.173108 , 82800.0,36.278170,-2.844673,20202958.831327 , 83100.0,36.467942,-4.895599,20203169.166870 , 83400.0,36.666550,-6.943360,20203392.212636 , 83700.0,36.877797,-8.986602,20203626.683292 , 84000.0,37.105587,-11.023925,20203870.984470 , 84300.0,37.353951,-13.053877,20204123.224440 , 84600.0,37.627076,-15.074932,20204381.228437 , 84900.0,37.929346,-17.085476,20204642.555895 , 85200.0,38.265363,-19.083792,20204904.519614 , 85500.0,38.639990,-21.068040,20205164.207763 , 85800.0,39.058382,-23.036235,20205418.507456 , 86100.0,39.526016,-24.986225,20205664.130824 , 86400.0,40.048733,-26.915663,20205897.642280 ] } } ]

mramato commented 11 years ago

Thanks for the issue and example. I was able to reproduce this easily and I know exactly what the problem is; we're currently performing interpolation in LLA, which is bad.

There are 3 ways to fix this.

  1. Convert Cartographic to Cartesian3 on load.
  2. Convert Cartographic to Cartesian3 perform the interpolation using Cartesian3s and then convert back to Cartographic.
  3. Add custom interpolation code for Cartographics which detect when we are crossing the 180 degree mark and works around it.

I think 1 is probably the best route to take, we almost always use Cartesians anyway, and doing the conversion on load will improve performance when using Cartographics.

mramato commented 11 years ago

@tadufre This is fixed in the above pull request and will be in master shortly. It will also be in b16 release on May 1st.