PolygonExtracter.js 996 B

12345678910111213141516171819202122232425262728293031323334
  1. import Polygon from '../Polygon'
  2. import GeometryCollection from '../GeometryCollection'
  3. import ArrayList from '../../../../../java/util/ArrayList'
  4. import GeometryFilter from '../GeometryFilter'
  5. export default class PolygonExtracter {
  6. constructor() {
  7. PolygonExtracter.constructor_.apply(this, arguments)
  8. }
  9. static constructor_() {
  10. this._comps = null
  11. const comps = arguments[0]
  12. this._comps = comps
  13. }
  14. static getPolygons() {
  15. if (arguments.length === 1) {
  16. const geom = arguments[0]
  17. return PolygonExtracter.getPolygons(geom, new ArrayList())
  18. } else if (arguments.length === 2) {
  19. const geom = arguments[0], list = arguments[1]
  20. if (geom instanceof Polygon)
  21. list.add(geom)
  22. else if (geom instanceof GeometryCollection)
  23. geom.apply(new PolygonExtracter(list))
  24. return list
  25. }
  26. }
  27. filter(geom) {
  28. if (geom instanceof Polygon) this._comps.add(geom)
  29. }
  30. get interfaces_() {
  31. return [GeometryFilter]
  32. }
  33. }