GeometryGraphOperation.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import BoundaryNodeRule from '../algorithm/BoundaryNodeRule'
  2. import GeometryGraph from '../geomgraph/GeometryGraph'
  3. import RobustLineIntersector from '../algorithm/RobustLineIntersector'
  4. export default class GeometryGraphOperation {
  5. constructor() {
  6. GeometryGraphOperation.constructor_.apply(this, arguments)
  7. }
  8. static constructor_() {
  9. this._li = new RobustLineIntersector()
  10. this._resultPrecisionModel = null
  11. this._arg = null
  12. if (arguments.length === 1) {
  13. const g0 = arguments[0]
  14. this.setComputationPrecision(g0.getPrecisionModel())
  15. this._arg = new Array(1).fill(null)
  16. this._arg[0] = new GeometryGraph(0, g0)
  17. } else if (arguments.length === 2) {
  18. const g0 = arguments[0], g1 = arguments[1]
  19. GeometryGraphOperation.constructor_.call(this, g0, g1, BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE)
  20. } else if (arguments.length === 3) {
  21. const g0 = arguments[0], g1 = arguments[1], boundaryNodeRule = arguments[2]
  22. if (g0.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0) this.setComputationPrecision(g0.getPrecisionModel()); else this.setComputationPrecision(g1.getPrecisionModel())
  23. this._arg = new Array(2).fill(null)
  24. this._arg[0] = new GeometryGraph(0, g0, boundaryNodeRule)
  25. this._arg[1] = new GeometryGraph(1, g1, boundaryNodeRule)
  26. }
  27. }
  28. getArgGeometry(i) {
  29. return this._arg[i].getGeometry()
  30. }
  31. setComputationPrecision(pm) {
  32. this._resultPrecisionModel = pm
  33. this._li.setPrecisionModel(this._resultPrecisionModel)
  34. }
  35. }