I need some function which make the same as ST_MakeEnvelope from PostGIS to use on a SqlServer DB. I need to get only some points from a geometry column to make my application run faster.
1 Answer
I solved the problem using the following code
DECLARE @g geometry; SET @g = geometry::STGeomFromText('POLYGON ((-43.93606328159918 -19.78099695243067, -43.93606328159918 -19.781697344263762,-43.93457465559592 -19.781697344263762, -43.93457465559592 -19.78099695243067, -43.93606328159918 -19.78099695243067))', 0);
SELECT [geometry] FROM [db].[TABLE] WHERE @g.STOverlaps([geometry]) = 1;
the points of the polygon I got using calculateExtent from openlayers following this rule
xmin ymax, xmin ymin, xmax ymin, xmax ymax, xmin ymax
I hope this help someone in the future