PointExtracter.js 1.1 KB

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