Professional Web Applications Themes

Best Field Type for Latitude & Longitude - MySQL

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...

  1. #1

    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

    lucanos@gmail.com Guest

  2. #2

    Default Re: Best Field Type for Latitude & Longitude

    On 16 Nov 2006 16:26:03 -0800, com wrote: 

    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.
     

    Maybe the spatial extentions might help you:

    http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.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
    Peter Guest

  3. #3

    Default Re: Best Field Type for Latitude & Longitude

    com wrote: 

    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/en/numeric-type-overview.html.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  4. #4

    Default Re: Best Field Type for Latitude & Longitude


    Jerry Stuckle wrote: 
    >
    > 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/en/numeric-type-overview.html.
    >
    > --
    > ==================
    > Remove the "x" from my email address
    > Jerry Stuckle
    > JDS Computer Training Corp.
    > net
    > ==================[/ref]

    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.

    Lucanos Guest

Similar Threads

  1. #39965 [NEW]: Latitude and longitude are backwards in date-sun-info
    By jim at federated dot com in forum PHP Bugs
    Replies: 2
    Last Post: April 13th, 08:34 AM
  2. alter field type
    By capik79 in forum Coldfusion Database Access
    Replies: 2
    Last Post: March 27th, 02:15 AM
  3. Problem with character palette and Tracking field: can't type zero after type is modified
    By Tim_Murray@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: May 11th, 04:21 PM
  4. Cast from type 'Field' to type 'String'
    By in forum ASP Database
    Replies: 2
    Last Post: November 11th, 03:18 PM
  5. latitude 640 resuming X
    By Jaroslaw Psikuta in forum Debian
    Replies: 0
    Last Post: July 20th, 09:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139