Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STintersects() to find the Intersection point

I have two sql server geometry-ies which I am using to check if they intersect. If they do I need the intersection point.

Currently I can get only Boolean output where if it intersects = 1 and if it does not intersect it will give =0 . Is there any way I can find the intersection of two shapes in geometry?


Update this question led to my next question concerning how can one check if a point (lat/long) exists in a region which has 4000 points (lat/long). Can one use stcontains or stintersects on geography?

sql - STContains on Geography column

like image 376
ace_mccloud Avatar asked Nov 30 '25 18:11

ace_mccloud


1 Answers

DECLARE @line1 GEOMETRY = geometry::STGeomFromText('LINESTRING(0 0, 1 1)', 0)
DECLARE @line2 GEOMETRY = geometry::STGeomFromText('LINESTRING(1 0, 0 1)', 0)

SELECT  @line1.STIntersection(@line2).ToString()
like image 124
Quassnoi Avatar answered Dec 03 '25 10:12

Quassnoi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!