PreparedPolygonContainsProperly.js 1.3 KB

123456789101112131415161718192021222324252627282930
  1. import hasInterface from '../../../../../hasInterface'
  2. import SegmentStringUtil from '../../noding/SegmentStringUtil'
  3. import Polygonal from '../Polygonal'
  4. import PreparedPolygonPredicate from './PreparedPolygonPredicate'
  5. export default class PreparedPolygonContainsProperly extends PreparedPolygonPredicate {
  6. constructor() {
  7. super()
  8. PreparedPolygonContainsProperly.constructor_.apply(this, arguments)
  9. }
  10. static constructor_() {
  11. const prepPoly = arguments[0]
  12. PreparedPolygonPredicate.constructor_.call(this, prepPoly)
  13. }
  14. static containsProperly(prep, geom) {
  15. const polyInt = new PreparedPolygonContainsProperly(prep)
  16. return polyInt.containsProperly(geom)
  17. }
  18. containsProperly(geom) {
  19. const isAllInPrepGeomAreaInterior = this.isAllTestComponentsInTargetInterior(geom)
  20. if (!isAllInPrepGeomAreaInterior) return false
  21. const lineSegStr = SegmentStringUtil.extractSegmentStrings(geom)
  22. const segsIntersect = this._prepPoly.getIntersectionFinder().intersects(lineSegStr)
  23. if (segsIntersect) return false
  24. if (hasInterface(geom, Polygonal)) {
  25. const isTargetGeomInTestArea = this.isAnyTargetComponentInAreaTest(geom, this._prepPoly.getRepresentativePoints())
  26. if (isTargetGeomInTestArea) return false
  27. }
  28. return true
  29. }
  30. }