roy naufal
roy naufal

Reputation: 389

Postgres/PostGIS find if line intersects circle?

I am having trouble figuring this out, I have 2 points A & B, I need to draw a straight line, and then see if this line intersects with circle C

What is the best way to do this? (I am new to Postgres so details would be super appreciated), steps to do:

Upvotes: 1

Views: 173

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246013

You can use ST_MakeLine to create a line from two points and ST_Intersects to see if it intersects with the circle.

But it is probably easier to use the <-> distance operator to see if the distance of the line from the center is less than the radius.

Upvotes: 3

Related Questions