sibartlett / Geo

A geospatial library for .NET
https://www.nuget.org/packages/Geo/
GNU Lesser General Public License v3.0
176 stars 39 forks source link

Is there a way to sort coordinates CW or CCW? #54

Open rurounijones opened 2 years ago

rurounijones commented 2 years ago

First off, I love this library. Lightweight and has everything I have needed so far. Great stuff!

I am in a situation where I have a collection of Coordinate objects which should be able to form a the shell of a polygon. I want to convert them to a Polygon object after verifying this fact.

The only snag is that these Coordinate objects are not in any sort of sorted order (e.g. Anti-Clockwise positioning) which means not following the advice from the wiki and doing things like putting them into a CoordinateSequence and calling IsClosed will not work.

Is there anything built-in to the Geo library that will take a collection of Coordinate objects and sort them CW or CCW so that things like IsClosed will work? I have had a peruse of the code and didn't see anything but I might have missed it.

If not then I think I have a way to do it but wanted to check if there was anything built-in first to avoid re-inventing the wheel.