GeoFenceGeoJsonPolygonBuilder(GeoFence) Method
Builds a GeoJSON representation of a polygon with a single outer boundary (fence).
This method is a simplified version that creates GeoJSON without any inner fences (holes).
Namespace: CoordinateSharpAssembly: CoordinateSharp (in CoordinateSharp.dll) Version: 3.1.1.1
XMLNS for XAML: Not mapped to an xmlns.
public static string GeoJsonPolygonBuilder(
GeoFence geoFence
)
- geoFence GeoFence
- The outer boundary of the polygon, which should be right-handed (counterclockwise).
StringReturns a string representing the GeoJSON format of the polygon with the specified outer boundary.
The example method ensures that the outer fence is right-handed (counterclockwise),
following GeoJSON conventions for outer boundaries.
// Create the outer fence (right-handed, closed polygon)
List<Coordinate> outerPoints = new List<Coordinate>()
{
new Coordinate(47.6062, -122.3321), // Seattle
new Coordinate(48.7519, -122.4787), // Bellingham
new Coordinate(47.2529, -122.4443), // Tacoma
new Coordinate(48.0419, -122.9025), // Port Townsend
new Coordinate(47.6062, -122.3321) // Closing the loop
};
GeoFence outerFence = new GeoFence(outerPoints);
//Points should be right hand ordered and polygon closed if not previously done so.
outerFence.OrderPoints_RightHanded();
outerFence.ClosePolygon();
// Build the GeoJSON string for the outer fence only
string geoJson = GeoFence.GeoJsonPolygonBuilder(outerFence);
Console.WriteLine(geoJson);