简体   繁体   English

如何在 MySQL 数据库中存储(纬度、经度、高度)元组?

[英]How to store (latitude, longitude, altitude) tuple in MySQL database?

办法来存储纬度和经度PointMySQL数据库,但我怎么能存储(元组latitudelongitudealtitude在) MySQL数据库?

Use a POINT for the latitude and longitude, and a DECIMAL for the altitude:使用 POINT 表示纬度和经度,使用 DECIMAL 表示高度:

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM