February 3, 2009 at 2:16 pm
All the new geometry and geography functionality in sql server is great. Geography functions cover a number of obvious questions (e.g. given two objects return the distance).
I'm finding however, once I have a geography point the built-in functions don't let me review or manipulate the data much.
example:
DECLARE @lonlat as geography
set @lonlat = geography::STPointFromText('POINT (122.236418 45.754767)', 4326);
how can I return just the *latitude* of the coordinate without having parsing the WKT returned by STAsText()? Is there no equivalent STX() or STY() function (as with the geography type)?
On that note... sql server is also missing functionality to transform data. Example: no way to translate coordinate by set distance and bearing without writing spherical trigonometry (equations using Haversine functions, typically requires articulated latitude and longitude inputs)?
so, how can i get the latitude??
did i totally miss this??
February 10, 2009 at 8:14 am
To go with your code
DECLARE @lonlat as geography
set @lonlat = geography::STPointFromText('POINT (122.236418 45.754767)', 4326);
select @lonlat.Lat
should get it for you.
February 10, 2009 at 12:05 pm
ya know, i tried that --but must have botched the syntax/names, because it certinaly works.
select MyGeography.Lat from MyTable
select [MyGeography].Long from [MyTable]
thanks.
BTW, I did look around BOL, don't see the propery type (class?) information there.
Good reference?
February 10, 2009 at 1:33 pm
When I was first doing this a few weeks ago I was struggling finding it on BOL as well until I did a key word search on Latitude, which found it for me.
If you go into BOL and do an Index search for "Extended Methods on Geometry Instances", it (and many others) falls under that category.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply