Idiomatic way to find intersection between a circular shape and a polygon in s2geometry? #231
-
I was trying to represent a circular shape on a 2D map with s2cap, sample code
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Well, it appears you're using the go version, but the principle is the same. If you just have one polygon and one point, then |
Beta Was this translation helpful? Give feedback.
-
@jmr, thanks a lot for the quick responses. |
Beta Was this translation helpful? Give feedback.
-
It works for my current use case and closing this ticket! |
Beta Was this translation helpful? Give feedback.
-
@jmr, Can you please help me with another doubt here, what would be the best s2geometry native shape representing a geojson shape like "linestring/multilinestring" ? thanks, |
Beta Was this translation helpful? Give feedback.
-
An |
Beta Was this translation helpful? Give feedback.
Well, it appears you're using the go version, but the principle is the same.
If you just have one polygon and one point, then
S2Point projected = polygon.Project(cap_center);
and test the distance betweenprojected
andcap_center
. If you have multiple polygons and want to test if any are within the distance, then the idiomatic way is probably with anS2ShapeIndex
, but that's more complicated.