ConsistentAreaTester.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import RelateNodeGraph from '../relate/RelateNodeGraph'
  2. import RobustLineIntersector from '../../algorithm/RobustLineIntersector'
  3. export default class ConsistentAreaTester {
  4. constructor() {
  5. ConsistentAreaTester.constructor_.apply(this, arguments)
  6. }
  7. static constructor_() {
  8. this._li = new RobustLineIntersector()
  9. this._geomGraph = null
  10. this._nodeGraph = new RelateNodeGraph()
  11. this._invalidPoint = null
  12. const geomGraph = arguments[0]
  13. this._geomGraph = geomGraph
  14. }
  15. isNodeEdgeAreaLabelsConsistent() {
  16. for (let nodeIt = this._nodeGraph.getNodeIterator(); nodeIt.hasNext(); ) {
  17. const node = nodeIt.next()
  18. if (!node.getEdges().isAreaLabelsConsistent(this._geomGraph)) {
  19. this._invalidPoint = node.getCoordinate().copy()
  20. return false
  21. }
  22. }
  23. return true
  24. }
  25. getInvalidPoint() {
  26. return this._invalidPoint
  27. }
  28. hasDuplicateRings() {
  29. for (let nodeIt = this._nodeGraph.getNodeIterator(); nodeIt.hasNext(); ) {
  30. const node = nodeIt.next()
  31. for (let i = node.getEdges().iterator(); i.hasNext(); ) {
  32. const eeb = i.next()
  33. if (eeb.getEdgeEnds().size() > 1) {
  34. this._invalidPoint = eeb.getEdge().getCoordinate(0)
  35. return true
  36. }
  37. }
  38. }
  39. return false
  40. }
  41. isNodeConsistentArea() {
  42. const intersector = this._geomGraph.computeSelfNodes(this._li, true, true)
  43. if (intersector.hasProperIntersection()) {
  44. this._invalidPoint = intersector.getProperIntersectionPoint()
  45. return false
  46. }
  47. this._nodeGraph.build(this._geomGraph)
  48. return this.isNodeEdgeAreaLabelsConsistent()
  49. }
  50. }