LocateFailureException.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. import LineSegment from '../../geom/LineSegment'
  2. import RuntimeException from '../../../../../java/lang/RuntimeException'
  3. export default class LocateFailureException extends RuntimeException {
  4. constructor() {
  5. super()
  6. LocateFailureException.constructor_.apply(this, arguments)
  7. }
  8. static constructor_() {
  9. this._seg = null
  10. if (arguments.length === 1) {
  11. if (typeof arguments[0] === 'string') {
  12. const msg = arguments[0]
  13. RuntimeException.constructor_.call(this, msg)
  14. } else if (arguments[0] instanceof LineSegment) {
  15. const seg = arguments[0]
  16. RuntimeException.constructor_.call(this, 'Locate failed to converge (at edge: ' + seg + '). Possible causes include invalid Subdivision topology or very close sites')
  17. this._seg = new LineSegment(seg)
  18. }
  19. } else if (arguments.length === 2) {
  20. const msg = arguments[0], seg = arguments[1]
  21. RuntimeException.constructor_.call(this, LocateFailureException.msgWithSpatial(msg, seg))
  22. this._seg = new LineSegment(seg)
  23. }
  24. }
  25. static msgWithSpatial(msg, seg) {
  26. if (seg !== null) return msg + ' [ ' + seg + ' ]'
  27. return msg
  28. }
  29. getSegment() {
  30. return this._seg
  31. }
  32. }