Forums > Jitter

Working with GPS coordinates in max

Jan 14 2011 | 12:06 pm

Hi

Bit stuck on something I thought was small but am now begining to think is very big (reading this http://cycling74.com/forums/topic.php?id=24639 has simply confused me). I’m download some GPS coordinates from a txt file online, storing in jit.textfile and then pulling out via jit.str.tosymbol. Nothing complex so far but my numbers get chopped after 6 decimal places. How do I get around this as obviously the end of the GPS coordinates are important for precision?

Garrett

``````
-- Pasted Max  Patch, click to expand. --

```
```
Jan 14 2011 | 4:42 pm

The main point to take from the thread you cited is this: floats in Max are 32-bit values.

32-bit floating point means a mantissa of effectively 24 bits, or about six digits accuracy. Period.

How to get around this? Well, if you need to work with numerical values, you don’t. If you don’t need arithmetic calculations, you can probably whip something up with jit.str.regexp that will convert the individual GPS coordinates into Max symbols.

It’s hard to say more without knowing what you’re trying to achieve.

Jan 14 2011 | 6:36 pm

Another thing to keep in mind here is that even if Max itself seems incapable of handling this stuff then you could always consider relying on an external program. Should be relatively easy to set something up in java for example (or javascript of course, I’m mentioning java first because I’m more fluent with it).

Jan 14 2011 | 7:39 pm

Hi Both

Thanks for clarifying that in max directly its just not possible and giving ways forward. I’m using the coordinates to move something in a 3d space so I’ll be mapped the GPS to that. I’m not working quite with -1.0 to 1.0 coordinate system it’s more like -100 to 100 but the suggestion in that other thread of multipling it up (it looks like I’ll need 100000 but I need to check the GPS spec to see how far after the decimal place is something like tens of metres) is possible.

so something like:

51.48642623333333 * 100000 = 5148642.623333333
everything left of 42 can be dumped

anyway javascript seems like a quick way forward so I’m going to attempt that. Can a js object take the number straight from the jit.textfile?

Garrett

Jan 15 2011 | 2:57 am

sprintf "%.10f"

might be useful. I had a tough time dealing with this in a project for astronomical positioning where more than 6 places was needed (storing them in [text] and/or [coll]). This took some experimenting to get to…

I think you’ll need to utilize [tosymbol] and [fromsymbol] somewhere. I can’t recall whether this approach actually worked in the end. Possibly it was just to format for another program like Excel, in which case it wouldn’t help (32-bit limit as mentioned…)

Aren’t there 64-bit externals for high precision available? Or maybe you can use a float64 matrix for storing and manipulation.

Viewing 5 posts - 1 through 5 (of 5 total)

Forums > Jitter