I am testing with the JTS (Java Topology Suite) library to see if I can manage to simplify a list of segments. The truth is I know very little about this library and I'm a programming novice, so I don't know if what I'm trying to achieve is possible.
What I want is, to transform a MULTILINESTRING list like the following one:
MULTILINESTRING ((0 0, 50 50), (50 50, 100 100, 150 50), (50 150, 100 100, 150 150), (20 20, 80 80), (40 160, 70 130), (110 110, 140 140))
Into this:
MULTILINESTRING ((40 160, 150 50), (0 0, 150 150))
In other words, what I want is to get a list with maximum segments, in terms of length. Is it possible to make that transformation, and if so, how?
Thank you very much.
It's not possible to get the answer you suggest purely with JTS methods. The closest you can get is to:
Geometry.union()
LineMerger
DouglasPeuckerSimplifier
using a small toleranceThat will give you:
MULTILINESTRING ((0 0, 100 100), (40 160, 100 100), (100 100, 150 150), (100 100, 150 50))