Bing Maps is giving me bounding coordinates as opposite points on a box that looks like this:
'34.763402330018245,-76.65003395080568,34.692861148846255,-76.86890220642091'
In my SQL Query, I using that data to draw the box as a polygon in the clockwise direction, but not getting any data. If I draw it counter-clockwise, I appear to get everything outside of the box.
SET @g = geography::STPolyFromText('POLYGON((
34.763402330018245 -76.65003395080568,
34.692861148846255 -76.65003395080568,
34.692861148846255 -76.86890220642091,
34.763402330018245 -76.86890220642091,
34.763402330018245 -76.65003395080568))', 4326);
In my Where, I have @g.STContains(geography::Point(p.Latitude, p.Longitude,4326 )) = 1
Can someone tell my what I am doing wrong?
I found the problem!
Because I am working with maps, I used the geography variable. Apparently, that is the wrong way to do it. You have to use the geometry variable instead.
My solution now looks like:
SET @g = geometry::STPolyFromText('POLYGON((
34.763402330018245 -76.65003395080568,
34.692861148846255 -76.65003395080568,
34.692861148846255 -76.86890220642091,
34.763402330018245 -76.86890220642091,
34.763402330018245 -76.65003395080568))', 4326);
And in the Where.....
@g.STContains(geometry::Point(p.Latitude, p.Longitude,4326 )) = 1