Number accuracy - probably working too small
Posted: Wed Mar 19, 2014 3:30 pm
I have a question related to my “make a movie from GPS co-ordinates” in another thread. I think LiveCode is just not capable of handling such small numbers.
Here’s what I’m doing. I have a track of data from an iPhone app called RunKeeper. This gives you an XML file of your GPS data, tracking the Latitude and Longitude coordinates, as well as a time stamp. The aim is to work out how many seconds between the coordinates, multiply that by the target frames per second and then use that to “in-between” the centre of a Google map, take a screen shot, and stitch the images together to make a movie. The idea being that there should be a smooth transition from coordinate to coordinate.
The problem is that the coordinates for Latitude and Longnitude are very precise, so for example, you can have:
51.751399000 lat
0.443322000 long
at time code 12:44:08
and:
51.751378000
0.443148000
at time code 12:44:12
There is a 4 second interval between coordinates here, so the step value (for latitude) will be: (51.751399000 - 51.751378000) / (4*12) = 0.0000004375
(for a 12 fps movie)
This means that for each frame, the Latitude value has to change by 0.0000004375
LiveCode seems to not like such small numbers, and if I report these in a field, they will come back either as something like 0.0000004 or even 0.0000000
So, to try to work around this, I multiplied all the coordinates by 1000000, did the calculations and then fed the numbers back to the Google URL divided by 1000000 in the hope that, at some point, LiveCode’s rounding will at the very least “catch up”.
But it’s not to be. I think I am just working on numbers that are far, far too small. So either I have to think of another way of sending the coordinates to Google, or find another way of handling them in LiveCode so that the accuracy is preserved.
I’m building the Google URL using this code:
I expect I am barking up the wrong tree by multiplying and dividing like this - it was a theory that I hoped would work.
Any ideas to prod me in the right direction?
Here’s what I’m doing. I have a track of data from an iPhone app called RunKeeper. This gives you an XML file of your GPS data, tracking the Latitude and Longitude coordinates, as well as a time stamp. The aim is to work out how many seconds between the coordinates, multiply that by the target frames per second and then use that to “in-between” the centre of a Google map, take a screen shot, and stitch the images together to make a movie. The idea being that there should be a smooth transition from coordinate to coordinate.
The problem is that the coordinates for Latitude and Longnitude are very precise, so for example, you can have:
51.751399000 lat
0.443322000 long
at time code 12:44:08
and:
51.751378000
0.443148000
at time code 12:44:12
There is a 4 second interval between coordinates here, so the step value (for latitude) will be: (51.751399000 - 51.751378000) / (4*12) = 0.0000004375
(for a 12 fps movie)
This means that for each frame, the Latitude value has to change by 0.0000004375
LiveCode seems to not like such small numbers, and if I report these in a field, they will come back either as something like 0.0000004 or even 0.0000000
So, to try to work around this, I multiplied all the coordinates by 1000000, did the calculations and then fed the numbers back to the Google URL divided by 1000000 in the hope that, at some point, LiveCode’s rounding will at the very least “catch up”.
But it’s not to be. I think I am just working on numbers that are far, far too small. So either I have to think of another way of sending the coordinates to Google, or find another way of handling them in LiveCode so that the accuracy is preserved.
I’m building the Google URL using this code:
Code: Select all
put "http://maps.googleapis.com/maps/api/staticmap?" into tURL
put tURL & "center=" & myLat/ 1000000 & "," & myLong / 1000000 into tURL
put tURL & "&zoom=" & zoomLevel & "&maptype=" & satellite into tURL
put tURL & "&key=yourGoogleAPIKeyHere" into tURL
put tURL & "&size=640x480" into tURL
Any ideas to prod me in the right direction?