There are ways to store latitude and longitude as Point
in MySQL
database, but how can I store a tuple for (latitude
, longitude
, altitude
) in MySQL
database?
Asked
Active
Viewed 1,244 times
2

Sazzad Hissain Khan
- 37,929
- 33
- 189
- 256
1 Answers
4
Use a POINT for the latitude and longitude, and a DECIMAL for the altitude:
CREATE TABLE Mountain (
Location POINT NOT NULL, -- Latitude/longitude
Altitude DECIMAL(12, 2) -- Altitude or height in meters or feet or furlongs if you prefer
) ENGINE=InnoDB;
or, just use three decimals - one for latitude, one for longitude, one for altitude:
CREATE TABLE Mountain (
Latitude DECIMAL(10, 7),
Longitude DECIMAL(10, 7),
Altitude DECIMAL(11, 1)
) ENGINE=InnoDB;

Bob Jarvis - Слава Україні
- 48,992
- 9
- 77
- 110
-
7 is a bit of overkill. See http://mysql.rjweb.org/doc.php/latlng#representation_choices – Rick James Mar 23 '20 at 03:01
-
@RickJames: there's no kill like overkill. :-) If you store degrees-minutes-seconds you're down to 100 feet, so seconds-to-two-decimal-places gets you down to one-foot accuracy - so seven decimal places is 1/10 of a foot accuracy and I can't shoot much straighter'n that anyways! :-) – Bob Jarvis - Слава Україні Mar 24 '20 at 02:26