May 3, 2013 at 1:37 am
Hi all,
I have an interface (google map) where i allow my users to define an area. Google map provides rectangle, line, circle and polygon to define a path or area. I have provided all the four options for my users to define the area. When my users use polygon or line, i get the relevant points and able to save the data as geography data type as well.
SET @g1 = geography::STGeomFromText('LINESTRING(Points that i get from google)', 4326);
SET @g1 = geography::STGeomFromText('POLYGON(points that i get from google)', 4326);
For Circular path define, all i get is one point and radius. Similarly for rectangle. i get the adjacent points alone. Is there a way to convert these points to Geography data type.
Thanks & Regards
Krishna
May 3, 2013 at 5:09 pm
Hi
For the circle you could create a buffer from the centrepoint for the radius:
SET @g1 = Geography::Point(Lat, Lon, SRID).STBuffer(radius)
For the rectangle you could try the following. I'm assuming that you are getting a lower left and upper right.
Be aware that this method may not give you entirely correct results as you are working with coordinates on a sphere
SET @g1 = Geography::STGeomFromWKB(
Geometry::STGeomFromText('LINESRING (Points that you get from google)',0).STEnvelope().STAsBinary()
,4326);
Unfortunately I can't test this for you at the moment
May 9, 2013 at 4:50 am
Hi,
Thanks.
Circular stuff worked but not the rectangle, but for now, i think we are ok with the circular working.
Thanks & Regards
Krishna
May 9, 2013 at 12:50 pm
You're welcome
If you post an example of the coordinates you get for a rectangle I can have a look at it for you
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply