0

In my data I have many occurrences of 2 lines that follow the same path, but in opposing directions. Applying LineMerger to this data results in the lines being joined together, but not merged into each other.

e.g. Given two lines with the same nodes

--->--->--->---

---<---<---<---

I want either:

--->--->--->---

or

---<---<---<---

But instead I get

--->--->--->--+
              |
---<---<---<--+

or

+-->--->--->---
|
+--<---<---<---

Is there a way to obtain my desired result in JTS?

0

Can you union the lines using Geometry.union ?

  • It's been a while, but I think I recall that union was a no-op, as the lines are not equivalent when reversed. – Synesso Apr 30 at 21:15
  • As long as the lines do have identical vertices (in opposite order) then Geometry.union will work. It will return a MultiLineString, which can then be merged to provide a single line. – dr_jts Apr 30 at 23:57
  • I see. I probably stopped exploring this option when I got the multilinestring. – Synesso May 1 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.