ConstraintEnforcementException.js 908 B

123456789101112131415161718192021222324252627
  1. import WKTWriter from '../io/WKTWriter'
  2. import Coordinate from '../geom/Coordinate'
  3. import RuntimeException from '../../../../java/lang/RuntimeException'
  4. export default class ConstraintEnforcementException extends RuntimeException {
  5. constructor() {
  6. super()
  7. ConstraintEnforcementException.constructor_.apply(this, arguments)
  8. }
  9. static constructor_() {
  10. this._pt = null
  11. if (arguments.length === 1) {
  12. const msg = arguments[0]
  13. RuntimeException.constructor_.call(this, msg)
  14. } else if (arguments.length === 2) {
  15. const msg = arguments[0], pt = arguments[1]
  16. RuntimeException.constructor_.call(this, ConstraintEnforcementException.msgWithCoord(msg, pt))
  17. this._pt = new Coordinate(pt)
  18. }
  19. }
  20. static msgWithCoord(msg, pt) {
  21. if (pt !== null) return msg + ' [ ' + WKTWriter.toPoint(pt) + ' ]'
  22. return msg
  23. }
  24. getCoordinate() {
  25. return this._pt
  26. }
  27. }