/** * Implementation of the transform method for a sequence of transformation. * It is important that input coordinate is a 3D coordinate because any of * the coordinate operation of the sequence may be a 3D coordinate of * {@link org.cts.op.CoordinateOperation}s. * * @param coord the 3D coord to transform * @return * @throws IllegalCoordinateException if <code>coord</code> is not * compatible with this <code>CoordinateOperation</code>. * @throws org.cts.op.CoordinateOperationException */ @Override public double[] transform(double[] coord) throws IllegalCoordinateException, CoordinateOperationException { for (CoordinateOperation op : sequence) { coord = op.transform(coord); } return coord; }
@Override public void filter(Coordinate coord) { try { if (Double.isNaN(coord.z)) { coord.z = 0; } double[] xyz = coordinateOperation .transform(new double[]{coord.x, coord.y, coord.z}); coord.x = xyz[0]; coord.y = xyz[1]; if (xyz.length > 2) { coord.z = xyz[2]; } else { coord.z = Double.NaN; } } catch (CoordinateOperationException |IllegalCoordinateException ex) { Logger.getLogger(ST_Transform.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public double[] transform(double[] coord) throws IllegalCoordinateException, CoordinateOperationException { boolean iter = false; int count = 0; for (int i = 0; i < realValueIndex.length; i++) { iter = iter || Math.abs(coord[realValueIndex[i]] - coord[calculatedValueIndex[i]]) > tolerance[i]; } while (iter) { coord = op.transform(coord); iter = false; for (int i = 0; i < realValueIndex.length; i++) { iter = iter || Math.abs(coord[realValueIndex[i]] - coord[calculatedValueIndex[i]]) > tolerance[i]; } if (++count > maxIterations ) throw new TooManyIterationsException(this, count); } return coord; }
@Override public void filter(Coordinate coord) { try { if (Double.isNaN(coord.z)) { coord.z = 0; } double[] xyz = coordinateOperation .transform(new double[]{coord.x, coord.y, coord.z}); coord.x = xyz[0]; coord.y = xyz[1]; if (xyz.length > 2) { coord.z = xyz[2]; } else { coord.z = Double.NaN; } } catch (IllegalCoordinateException ice) { throw new RuntimeException("Cannot transform the coordinate" + coord.toString(), ice); } }
@Override public void filter(Coordinate coord) { try { if (Double.isNaN(coord.z)) { coord.z = 0; } double[] xyz = coordinateOperation .transform(new double[]{coord.x, coord.y, coord.z}); coord.x = xyz[0]; coord.y = xyz[1]; if (xyz.length > 2) { coord.z = xyz[2]; } else { coord.z = Double.NaN; } } catch (IllegalCoordinateException ice) { throw new RuntimeException("Cannot transform the coordinate" + coord.toString(), ice); } }
@Override public void filter(Coordinate coord) { try { if (Double.isNaN(coord.z)) { coord.z = 0; } double[] xyz = coordinateOperation .transform(new double[]{coord.x, coord.y, coord.z}); coord.x = xyz[0]; coord.y = xyz[1]; if (xyz.length > 2) { coord.z = xyz[2]; } else { coord.z = Double.NaN; } } catch (IllegalCoordinateException ice) { throw new RuntimeException("Cannot transform the coordinate" + coord.toString(), ice); } }