Polygon.withFactory constructor

Polygon.withFactory(
  1. LinearRing? shell,
  2. List<LinearRing>? holes,
  3. GeometryFactory factory
)

Constructs a Polygon with the given exterior boundary and interior boundaries.

@param shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created. @param holes the inner boundaries of the new Polygon , or null or empty LinearRings if the empty geometry is to be created.

Implementation

Polygon.withFactory(
    LinearRing? shell, List<LinearRing>? holes, GeometryFactory factory)
    : super(factory) {
  if (shell == null) {
    shell = getFactory().createLinearRingEmpty();
  }
  if (holes == null) {
    holes = <LinearRing>[];
  }
  if (Geometry.hasNullElements(holes)) {
    throw new ArgumentError("holes must not contain null elements");
  }
  if (shell.isEmpty() && Geometry.hasNonEmptyElements(holes)) {
    throw new ArgumentError("shell is empty but holes are not");
  }
  this.shell = shell;
  this.holes = holes;
}