extract static method
Extracts a subsequence of the input {@link Coordinate} array
from indices start
to
end
(inclusive).
The input indices are clamped to the array size;
If the end index is less than the start index,
the extracted array will be empty.
@param pts the input array @param start the index of the start of the subsequence to extract @param end the index of the end of the subsequence to extract @return a subsequence of the input array
Implementation
static List<Coordinate> extract(List<Coordinate> pts, int start, int end) {
start = MathUtils.clamp(start, 0, pts.length).toInt();
end = MathUtils.clamp(end, -1, pts.length).toInt();
int npts = end - start + 1;
if (end < 0) npts = 0;
if (start >= pts.length) npts = 0;
if (end < start) npts = 0;
List<Coordinate> extractPts = []; //..length = (npts);
if (npts == 0) return extractPts;
// int iPts = 0;
for (int i = start; i <= end; i++) {
extractPts.add(pts[i]);
// extractPts[iPts++] = pts[i];
}
return extractPts;
}