Polygon Contains Cartographic

I see that Rectangle has a “contains” method that will tell you if a cartographic location is inside the rectangle.

Does anyone have a suggestion on how to accomplish this with a Polygon?

There isn’t a built-in way to do this as far as I’m aware, but detecting if a point is inside a polygon is a common graphics operation (you’ll find a few different algorithms if you google that).

You could use a library like TurfJS and give it the coordinates of your polygons/points: https://turfjs.org/docs/#pointsWithinPolygon

What kind of application are you working on?

Thanks. I ended up finding turfjs after making this post.

I have found that turfjs doesn’t handle polygons that cross the antimeridian very well. (It works if you translate longitudes to 0-360, but not crossing from negative to positive.)

Handling the specific lat/lon boundary conditions is the main reason I was looking for a library.

This would be a nice feature to expand in cesium at some point.