Kazu46Machi / earth-api-samples

Automatically exported from code.google.com/p/earth-api-samples
0 stars 0 forks source link

Driving Simulator Bug - For Roman #101

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
simulator.js - Line 272 - while ....

You should consider the duration of the segments as you pass them. You just
consider the duration of the first segment as you pass the other ones.

Please notify me about the result directly. I am new to this code thing!

Original issue reported on code.google.com by nae...@gmail.com on 25 Nov 2008 at 4:00

GoogleCodeExporter commented 8 years ago
Ah, sorry for responding so late. Nice catch :) I'll fix that in the next 
commit.

Original comment by api.roman.public@gmail.com on 16 Dec 2008 at 12:27

GoogleCodeExporter commented 8 years ago
Also note that the exit condition needs to be >= rather than >

There are various issues:
 - possibility of exiting the loop with a segmentDuration of zero
 - getHeading(loc,locFacing) will fail, because loc and locFacing are the same point.

this should do the trick:

  while (this.pathIndex_ < this.path.length - 1 &&
         this.segmentTime_ >= (segmentDuration = 
this.path[this.pathIndex_].duration))

Original comment by mark...@gmail.com on 18 Dec 2008 at 7:39

GoogleCodeExporter commented 8 years ago
Sorry, these things are coming back to me one at a time :-)

The totalDistance computation is also wrong. I think you can fix that by moving 
the 
"if (segmentDuration) { this.segmentDistance_ ..." lines after the while loop 
(and 
you can drop "this.segmentDistance_ = 0" from inside the while loop.

Also, you can improve the stability of the drive_ and moveToPointDriving_ 
methods by 
passing in the start of the segment, the current location, and the end of the 
segment 
(rather than just current location and end of segment).

Then use start of segment, and end of segment to compute the heading (rather 
than 
current location, and end of segment). This can be significant when the current 
location is very close to the end of the segment.

Original comment by mark...@gmail.com on 18 Dec 2008 at 8:00