UnionOp.js 663 B

12345678910111213141516171819202122
  1. import SnapIfNeededOverlayOp from '../overlay/snap/SnapIfNeededOverlayOp'
  2. import OverlayOp from '../overlay/OverlayOp'
  3. export default class UnionOp {
  4. get interfaces_() {
  5. return []
  6. }
  7. getClass() {
  8. return UnionOp
  9. }
  10. static union(g, other) {
  11. if (g.isEmpty() || other.isEmpty()) {
  12. if (g.isEmpty() && other.isEmpty()) return OverlayOp.createEmptyResult(OverlayOp.UNION, g, other, g.getFactory())
  13. if (g.isEmpty()) return other.copy()
  14. if (other.isEmpty()) return g.copy()
  15. }
  16. g.checkNotGeometryCollection(g)
  17. g.checkNotGeometryCollection(other)
  18. return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.UNION)
  19. }
  20. }