private void copy(Coordinate co, double[] ordinates, DimensionalFlag flag) { ordinates[flag.X] = co.x; ordinates[flag.Y] = co.y; if (flag.is3D()) ordinates[flag.Z] = co.z; if (flag.isMeasured()) { ordinates[flag.M] = (co instanceof DimensionalCoordinate) ? ((DimensionalCoordinate) co).m : Double.NaN; } }
private CoordinateSequence fromCoordinateArray(Coordinate[] coordinates, DimensionalFlag dim) { PointSequenceBuilder builder = PointSequenceBuilders.fixedSized(coordinates.length, dim); double[] ordinates = new double[dim.getCoordinateDimension()]; for (Coordinate co : coordinates) { copy(co, ordinates, dim); builder.add(ordinates); } return (CoordinateSequence) builder.toPointSequence(); }