I am using SQL 2008 Geography datatype for a project that deals with mapping out some areas. I need to check to make sure a smaller area is fully within the bounds of a larger area. With the Geometry datatype I could simply use .STWithin().
I would simply make the polygon’s geometry datatypes as well as geography, but I’m not sure if using a polygon that was mapped on geography coordinants will work as expected if used as a simple geometry type.
Is there any way to do something like .STWithin() on a geography datatype?
Well, this isn’t an approach as clean as using STWithin, but you could do it using “STDifference”. I’ve prepared a small example:
Basically there’s a large rectangle which serves as the container. There’s also two rectangles, “inside” and “outside”, where the first one is fully contained on the “container” and the second one only partially.
The idea is just to check if the STDifference between the child and the parent has any points (the trick is in the direction of the call).