解决方法@H_301_8@
地理是用于绘制地球上的点的类型.
如果您有一个表格存储Google Maps点,如下所示:
CREATE TABLE geo_locations (
location_id uniqueidentifier NOT NULL,position_point geography NOT NULL
);
那么您可以使用此存储过程填写其中的内容:
CREATE PROCEDURE proc_AddPoint
@latitude decimal(9,6),@longitude decimal(9,@altitude smallInt
AS
DECLARE @point geography = NULL;
BEGIN
SET NOCOUNT ON;
SET @point = geography::STPointFromText('POINT(' + CONVERT(varchar(15),@longitude) + ' ' +
CONVERT(varchar(15),@latitude) + ' ' +
CONVERT(varchar(10),@altitude) + ')',4326)
INSERT INTO geo_locations
(
location_id,position_point
)
VALUES
(
NEWID(),@point
);
END
SELECT
geo_locations.position_point.Lat AS latitude,geo_locations.position_point.Long AS longitude,geo_locations.position_point.Z AS altitude
FROM
geo_locations;
如果您有一个表格存储Google Maps点,如下所示:
CREATE TABLE geo_locations ( location_id uniqueidentifier NOT NULL,position_point geography NOT NULL );
那么您可以使用此存储过程填写其中的内容:
CREATE PROCEDURE proc_AddPoint @latitude decimal(9,6),@longitude decimal(9,@altitude smallInt AS DECLARE @point geography = NULL; BEGIN SET NOCOUNT ON; SET @point = geography::STPointFromText('POINT(' + CONVERT(varchar(15),@longitude) + ' ' + CONVERT(varchar(15),@latitude) + ' ' + CONVERT(varchar(10),@altitude) + ')',4326) INSERT INTO geo_locations ( location_id,position_point ) VALUES ( NEWID(),@point ); END
SELECT geo_locations.position_point.Lat AS latitude,geo_locations.position_point.Long AS longitude,geo_locations.position_point.Z AS altitude FROM geo_locations;