Unix Technical Forum

Best Field Type for Latitude & Longitude

This is a discussion on Best Field Type for Latitude & Longitude within the MySQL forums, part of the Database Server Software category; --> Hi All, I am still trying to understand the field types available in MySQL, so I am hoping to ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:36 AM
lucanos@gmail.com
 
Posts: n/a
Default Best Field Type for Latitude & Longitude

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:36 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Best Field Type for Latitude & Longitude

On 16 Nov 2006 16:26:03 -0800, 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).


What are you recording? There's less than 400,000 feet in a degree of
longitude. 8 decimal points would put you down to about 1/8th of an
inch, and I'd laugh in your face if you told me you have a device in
your pocket that can measure that accurately to any point on the planet.

For most purposes, if you can get *four* decimal points, you're close
enough.

> I realise that this is a simple question, but I would appreciate any
> help you can give.


Maybe the spatial extentions might help you:

http://dev.mysql.com/doc/refman/5.0/...xtensions.html

--
79. If my doomsday device happens to come with a reverse switch, as soon as it
has been employed it will be melted down and made into limited-edition
commemorative coins.
--Peter Anspach's list of things to do as an Evil Overlord
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08: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
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 08:36 AM
Lucanos
 
Posts: n/a
Default Re: Best Field Type for Latitude & Longitude


Jerry Stuckle wrote:
> 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
> ==================


I simply threw the figure 8 out there after seeing that Google Earth
uses around 6, and trying to allow for more detail than I might be
wanting to use at the moment.

Thanks for the assistance guys.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:08 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com