I'm trying to calculate the intersection point between a segment and the exterior ring of a polygon. But I'm not sure how to do it correctly when dealing with geography types.
The segment is a line connecting two geographic locations and I specifically know in advance that the start-point coordinates are outside of the polygon and the finish-point coordinates intersect the polygon.
ST_Intersection
supports both geometry and geography and I already have the polygon as geography
Building the line as geography it's easy as:
LINESTRING(start-point, finish-point)'::geography
maybe I can even use ST_Makeline
and cast its result to geography?? (I'm not sure)
But what about the exterior ring of the polygon geography? I was advised to use ST_Boundary
however ST_Boundary
only accepts geometry and returns geometry. I am not sure if the output of
ST_Boundary(mypolygon::geometry)
is actually geographically correct? For example if the polygon has very large edges would they be segmentized (as great-circles) in the output of ST_Boundary? If not (as I suspect) then how can I obtain the correct geography boundary ?