Esempio n. 1
0
 /** Transforms a single coordinate point. */
 @Override
 public DirectPosition transform(final DirectPosition ptSrc, DirectPosition ptDst)
     throws MismatchedDimensionException, TransformException {
   final int srcDim = source.getDimension();
   final int tgtDim = target.getDimension();
   if (ptSrc.getDimension() != srcDim) {
     throw new MismatchedDimensionException();
   }
   double[] ordinates = new double[Math.max(srcDim, tgtDim)];
   for (int i = 0; i < srcDim; i++) {
     ordinates[i] = ptSrc.getOrdinate(i);
   }
   source.pj.transform(target.pj, ordinates.length, ordinates, 0, 1);
   if (ptDst != null) {
     if (ptDst.getDimension() != tgtDim) {
       throw new MismatchedDimensionException();
     }
     for (int i = 0; i < tgtDim; i++) {
       ptDst.setOrdinate(i, ordinates[i]);
     }
   } else {
     if (ordinates.length != tgtDim) {
       ordinates = Arrays.copyOf(ordinates, tgtDim);
     }
     ptDst = new SimpleDirectPosition(ordinates);
   }
   return ptDst;
 }