GeometryLocation.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import WKTWriter from '../../io/WKTWriter'
  2. export default class GeometryLocation {
  3. constructor() {
  4. GeometryLocation.constructor_.apply(this, arguments)
  5. }
  6. static constructor_() {
  7. this._component = null
  8. this._segIndex = null
  9. this._pt = null
  10. if (arguments.length === 2) {
  11. const component = arguments[0], pt = arguments[1]
  12. GeometryLocation.constructor_.call(this, component, GeometryLocation.INSIDE_AREA, pt)
  13. } else if (arguments.length === 3) {
  14. const component = arguments[0], segIndex = arguments[1], pt = arguments[2]
  15. this._component = component
  16. this._segIndex = segIndex
  17. this._pt = pt
  18. }
  19. }
  20. getSegmentIndex() {
  21. return this._segIndex
  22. }
  23. getCoordinate() {
  24. return this._pt
  25. }
  26. isInsideArea() {
  27. return this._segIndex === GeometryLocation.INSIDE_AREA
  28. }
  29. toString() {
  30. return this._component.getGeometryType() + '[' + this._segIndex + ']' + '-' + WKTWriter.toPoint(this._pt)
  31. }
  32. getGeometryComponent() {
  33. return this._component
  34. }
  35. }
  36. GeometryLocation.INSIDE_AREA = -1