/// <summary> /// Creates a GeoJson Polygon object. /// </summary> /// <typeparam name="TCoordinates">The type of the coordinates.</typeparam> /// <param name="positions">The positions.</param> /// <returns>A GeoJson Polygon object.</returns> public static GeoJsonPolygon <TCoordinates> Polygon <TCoordinates>(params TCoordinates[] positions) where TCoordinates : GeoJsonCoordinates { var exterior = new GeoJsonLinearRingCoordinates <TCoordinates>(positions); var coordinates = new GeoJsonPolygonCoordinates <TCoordinates>(exterior); return(new GeoJsonPolygon <TCoordinates>(coordinates)); }
/// <summary> /// Initializes a new instance of the <see cref="GeoJsonPolygonCoordinates{TCoordinates}"/> class. /// </summary> /// <param name="exterior">The exterior.</param> /// <param name="holes">The holes.</param> public GeoJsonPolygonCoordinates(GeoJsonLinearRingCoordinates <TCoordinates> exterior, IEnumerable <GeoJsonLinearRingCoordinates <TCoordinates> > holes) { if (exterior == null) { throw new ArgumentNullException("exterior"); } if (holes == null) { throw new ArgumentNullException("holes"); } var holesArray = holes.ToArray(); if (holesArray.Contains(null)) { throw new ArgumentException("One of the holes is null.", "holes"); } _exterior = exterior; _holes = new ReadOnlyCollection <GeoJsonLinearRingCoordinates <TCoordinates> >(holesArray); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="GeoJsonPolygonCoordinates{TCoordinates}"/> class. /// </summary> /// <param name="exterior">The exterior.</param> public GeoJsonPolygonCoordinates(GeoJsonLinearRingCoordinates <TCoordinates> exterior) : this(exterior, new GeoJsonLinearRingCoordinates <TCoordinates> [0]) { }
/// <summary> /// Creates the coordinates of a GeoJson Polygon object. /// </summary> /// <typeparam name="TCoordinates">The type of the coordinates.</typeparam> /// <param name="exterior">The exterior.</param> /// <param name="holes">The holes.</param> /// <returns>The coordinates of a GeoJson Polygon object.</returns> public static GeoJsonPolygonCoordinates <TCoordinates> PolygonCoordinates <TCoordinates>(GeoJsonLinearRingCoordinates <TCoordinates> exterior, params GeoJsonLinearRingCoordinates <TCoordinates>[] holes) where TCoordinates : GeoJsonCoordinates { return(new GeoJsonPolygonCoordinates <TCoordinates>(exterior, holes)); }