PreparedLineString.js 953 B

1234567891011121314151617181920212223
  1. import FastSegmentSetIntersectionFinder from '../../noding/FastSegmentSetIntersectionFinder'
  2. import SegmentStringUtil from '../../noding/SegmentStringUtil'
  3. import PreparedLineStringIntersects from './PreparedLineStringIntersects'
  4. import BasicPreparedGeometry from './BasicPreparedGeometry'
  5. export default class PreparedLineString extends BasicPreparedGeometry {
  6. constructor() {
  7. super()
  8. PreparedLineString.constructor_.apply(this, arguments)
  9. }
  10. static constructor_() {
  11. this._segIntFinder = null
  12. const line = arguments[0]
  13. BasicPreparedGeometry.constructor_.call(this, line)
  14. }
  15. getIntersectionFinder() {
  16. if (this._segIntFinder === null) this._segIntFinder = new FastSegmentSetIntersectionFinder(SegmentStringUtil.extractSegmentStrings(this.getGeometry()))
  17. return this._segIntFinder
  18. }
  19. intersects(g) {
  20. if (!this.envelopesIntersect(g)) return false
  21. return PreparedLineStringIntersects.intersects(this, g)
  22. }
  23. }