EnhancedPrecisionOp.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import CommonBitsOp from './CommonBitsOp'
  2. import RuntimeException from '../../../../java/lang/RuntimeException'
  3. export default class EnhancedPrecisionOp {
  4. static union(geom0, geom1) {
  5. let originalEx = null
  6. try {
  7. const result = geom0.union(geom1)
  8. return result
  9. } catch (ex) {
  10. if (ex instanceof RuntimeException)
  11. originalEx = ex
  12. else throw ex
  13. } finally {}
  14. try {
  15. const cbo = new CommonBitsOp(true)
  16. const resultEP = cbo.union(geom0, geom1)
  17. if (!resultEP.isValid()) throw originalEx
  18. return resultEP
  19. } catch (ex2) {
  20. if (ex2 instanceof RuntimeException)
  21. throw originalEx
  22. else throw ex2
  23. } finally {}
  24. }
  25. static intersection(geom0, geom1) {
  26. let originalEx = null
  27. try {
  28. const result = geom0.intersection(geom1)
  29. return result
  30. } catch (ex) {
  31. if (ex instanceof RuntimeException)
  32. originalEx = ex
  33. else throw ex
  34. } finally {}
  35. try {
  36. const cbo = new CommonBitsOp(true)
  37. const resultEP = cbo.intersection(geom0, geom1)
  38. if (!resultEP.isValid()) throw originalEx
  39. return resultEP
  40. } catch (ex2) {
  41. if (ex2 instanceof RuntimeException)
  42. throw originalEx
  43. else throw ex2
  44. } finally {}
  45. }
  46. static buffer(geom, distance) {
  47. let originalEx = null
  48. try {
  49. const result = geom.buffer(distance)
  50. return result
  51. } catch (ex) {
  52. if (ex instanceof RuntimeException)
  53. originalEx = ex
  54. else throw ex
  55. } finally {}
  56. try {
  57. const cbo = new CommonBitsOp(true)
  58. const resultEP = cbo.buffer(geom, distance)
  59. if (!resultEP.isValid()) throw originalEx
  60. return resultEP
  61. } catch (ex2) {
  62. if (ex2 instanceof RuntimeException)
  63. throw originalEx
  64. else throw ex2
  65. } finally {}
  66. }
  67. static symDifference(geom0, geom1) {
  68. let originalEx = null
  69. try {
  70. const result = geom0.symDifference(geom1)
  71. return result
  72. } catch (ex) {
  73. if (ex instanceof RuntimeException)
  74. originalEx = ex
  75. else throw ex
  76. } finally {}
  77. try {
  78. const cbo = new CommonBitsOp(true)
  79. const resultEP = cbo.symDifference(geom0, geom1)
  80. if (!resultEP.isValid()) throw originalEx
  81. return resultEP
  82. } catch (ex2) {
  83. if (ex2 instanceof RuntimeException)
  84. throw originalEx
  85. else throw ex2
  86. } finally {}
  87. }
  88. static difference(geom0, geom1) {
  89. let originalEx = null
  90. try {
  91. const result = geom0.difference(geom1)
  92. return result
  93. } catch (ex) {
  94. if (ex instanceof RuntimeException)
  95. originalEx = ex
  96. else throw ex
  97. } finally {}
  98. try {
  99. const cbo = new CommonBitsOp(true)
  100. const resultEP = cbo.difference(geom0, geom1)
  101. if (!resultEP.isValid()) throw originalEx
  102. return resultEP
  103. } catch (ex2) {
  104. if (ex2 instanceof RuntimeException)
  105. throw originalEx
  106. else throw ex2
  107. } finally {}
  108. }
  109. }