union method

MultiPoint union({
  1. MultiPoint? multi,
  2. Point? point,
})

Returns a MultiPoint that is the union of this MultiPoint and another MultiPoint. The resulting MultiPoint will have the same properties as this MultiPoint.

Example:

MultiPoint([Coordinate(1, 2), Coordinate(3, 4)]).union(MultiPoint([Coordinate(2, 3), Coordinate(4, 5)])); // MultiPoint([Coordinate(1, 2), Coordinate(3, 4), Coordinate(2, 3), Coordinate(4, 5)])

Implementation

MultiPoint union({MultiPoint? multi, Point? point}) {
  return MultiPoint([
    ...coordinates,
    ...(multi != null ? multi.coordinates : []),
    ...(point != null ? [point.coordinate] : []),
  ], properties: properties);
}