use of eu.esdihumboldt.util.geometry.interpolation.ArcSegment in project hale by halestudio.
the class SplitInterpolation method interpolateToLineString.
private LineString interpolateToLineString(Arc arc) {
// arc segments to process
Deque<ArcSegment> toProcess = new LinkedList<>();
// start with full arc as segment
toProcess.addFirst(new ArcSplitSegment(arc, getMaxPositionalError()));
// list to collect atomic parts
List<ArcSegment> parts = new LinkedList<>();
// for every segment to process...
while (!toProcess.isEmpty()) {
ArcSegment segment = toProcess.pop();
if (segment.isAtomic()) {
// segment cannot be split
// -> use for result
parts.add(segment);
} else {
// otherwise split the segment in two and handle the parts
toProcess.addFirst(segment.getSecondPart());
toProcess.addFirst(segment.getFirstPart());
}
}
// combine the segments to a single LineString
List<Coordinate> coords = new ArrayList<>();
for (int i = 0; i < parts.size(); i++) {
ArcSegment part = parts.get(i);
if (i == 0) {
coords.add(part.getStartPoint());
}
Coordinate middle = part.getMiddlePoint();
if (middle != null) {
// should actually not occur
InterpolationUtil.addIfDifferent(coords, middle);
}
InterpolationUtil.addIfDifferent(coords, part.getEndPoint());
}
return createLineString(coords.toArray(new Coordinate[coords.size()]), arc);
}
use of eu.esdihumboldt.util.geometry.interpolation.ArcSegment in project hale by halestudio.
the class GridInterpolation method interpolateToLineString.
private LineString interpolateToLineString(Arc arc) {
// arc segments to process
Deque<ArcSegment> toProcess = new LinkedList<>();
// start with full arc as segment
toProcess.addFirst(new ArcGridSegment(arc, moveAllToGrid, gridSize));
// list to collect atomic parts
List<ArcSegment> parts = new LinkedList<>();
// for every segment to process...
while (!toProcess.isEmpty()) {
ArcSegment segment = toProcess.pop();
if (segment.isAtomic()) {
// segment cannot be split
// -> use for result
parts.add(segment);
} else {
// otherwise split the segment in two and handle the parts
toProcess.addFirst(segment.getSecondPart());
toProcess.addFirst(segment.getFirstPart());
}
}
// combine the segments to a single LineString
List<Coordinate> coords = new ArrayList<>();
for (int i = 0; i < parts.size(); i++) {
ArcSegment part = parts.get(i);
if (i == 0) {
coords.add(part.getStartPoint());
}
Coordinate middle = part.getMiddlePoint();
if (middle != null) {
// should actually not occur
InterpolationUtil.addIfDifferent(coords, middle);
}
InterpolationUtil.addIfDifferent(coords, part.getEndPoint());
}
return createLineString(coords.toArray(new Coordinate[coords.size()]), arc);
}
Aggregations