View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 09:36 AM
Jerry Stuckle
 
Posts: n/a
Default Re: Best Field Type for Latitude & Longitude

lucanos@gmail.com wrote:
> Hi All,
>
> I am still trying to understand the field types available in MySQL, so
> I am hoping to be able to call upon the experience and knowledge of you
> guys to try and get my head around this.
>
> I am trying to figure out which field type to use when storing Latitude
> and Longitude values.
> The field type would need to be able to handle numbers between -180 and
> 180, out to about 8 decimal spaces (maybe more).
>
> I realise that this is a simple question, but I would appreciate any
> help you can give.
>
> Thanks
> Luke
>


Are you sure you need EIGHT decimal places? That's about 0.04 in. (.1
cm.). 4 decimal places (about 34 feet/11 meters) is generally close enough.

First you have to figure just how much precision you need. Then you
need to decide how you want to keep it. Personally, I keep mine in
number of seconds (accurate to about 100 feet/33 meters) as an integer
because it's faster to compare integers than floating point numbers. If
that isn't good enough, you could keep it in 1/10s of a second as an
integer.

Alternatively, you could use one of the floating point data types such
as FLOAT or DOUBLE.

You can get more information on the data types, their ranges, etc. at
http://dev.mysql.com/doc/refman/5.1/...-overview.html.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote