EdgeIntersection.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Coordinate from '../geom/Coordinate'
  2. import Comparable from '../../../../java/lang/Comparable'
  3. export default class EdgeIntersection {
  4. constructor() {
  5. EdgeIntersection.constructor_.apply(this, arguments)
  6. }
  7. static constructor_() {
  8. this.coord = null
  9. this.segmentIndex = null
  10. this.dist = null
  11. const coord = arguments[0], segmentIndex = arguments[1], dist = arguments[2]
  12. this.coord = new Coordinate(coord)
  13. this.segmentIndex = segmentIndex
  14. this.dist = dist
  15. }
  16. getSegmentIndex() {
  17. return this.segmentIndex
  18. }
  19. getCoordinate() {
  20. return this.coord
  21. }
  22. print(out) {
  23. out.print(this.coord)
  24. out.print(' seg # = ' + this.segmentIndex)
  25. out.println(' dist = ' + this.dist)
  26. }
  27. compareTo(obj) {
  28. const other = obj
  29. return this.compare(other.segmentIndex, other.dist)
  30. }
  31. isEndPoint(maxSegmentIndex) {
  32. if (this.segmentIndex === 0 && this.dist === 0.0) return true
  33. if (this.segmentIndex === maxSegmentIndex) return true
  34. return false
  35. }
  36. toString() {
  37. return this.coord + ' seg # = ' + this.segmentIndex + ' dist = ' + this.dist
  38. }
  39. getDistance() {
  40. return this.dist
  41. }
  42. compare(segmentIndex, dist) {
  43. if (this.segmentIndex < segmentIndex) return -1
  44. if (this.segmentIndex > segmentIndex) return 1
  45. if (this.dist < dist) return -1
  46. if (this.dist > dist) return 1
  47. return 0
  48. }
  49. get interfaces_() {
  50. return [Comparable]
  51. }
  52. }