where we use Geography and Geometry datatype in sql server?

Posted by Bageshkumarbagi under Sql Server on 11/7/2012 | Points: 10 | Views : 1696 | Status : [Member] | Replies : 3
hi
where we use Geography and Geometry datatype in sql server? Give some Realtime example where we use such type of datatype.
plz give some front code also.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied



Responses

Posted by: Rajesh081725 on: 11/8/2012 [Member] Bronze | Points: 25

Up
0
Down
geography is a new data type that supports long range distances measurements. If you use geography -- you don't need to learn much about planar coordinate systems. Geography is generally best if all you care about is measuring distances and lengths and you have data from all over the world. Geometry datatype is an older data type that has many functions supporting it and enjoys great support from third party tools.

Geography is the type that is intended for plotting points on the earth.

If you have a table that stores Google Maps points like this:

CREATE TABLE geo_locations (
location_id uniqueidentifier NOT NULL,
position_point geography NOT NULL
);then you could fill points in it with this stored procedure:

CREATE PROCEDURE proc_AddPoint
@latitude decimal(9,6),
@longitude decimal(9,6),
@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
);

ENDThen if you want to query for the latitude, longitude and altitude, simply use the following query format:

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;

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh081725 on: 11/8/2012 [Member] Bronze | Points: 25

Up
0
Down
hai bagi,
if its ok just click mark as answer

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ethanmillar on: 5/22/2015 [Member] Starter | Points: 25

Up
0
Down
Hi,

Please refer this https://www.rswebsols.com/tutorials/programming/geography-datatype-sql-asp-net-mvc-development.

Its about HOW TO USE GEOGRAPHY DATATYPE OF SQL IN ASP.NET MVC DEVELOPMENT.

This tutorial to let the developers know how to use Geography DataType of SQL to locate places within certain radius. You can read this post and learn finding Geocode of any address or zip code.


Ethan Millar is intense about coding and everything related to ASP.Net.

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response