cdm/src/main/java/ucar/unidata/geoloc/ProjectionImpl.java
public float[][] latLonToProj(float[][] from, float[][] to, int latIndex,
                                int lonIndex) {
    //      ucar.unidata.util.Misc.printStack ("latLonToProj-" + this + " size=" + from[0].length, 4, null);

    if ((from == null) || (from.length != 2)) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "null array argument or wrong dimension (from)");
    }
    if ((to == null) || (to.length != 2)) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "null array argument or wrong dimension (to)");
    }

    if (from[0].length != to[0].length) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "from array not same length as to array");
    }

    ProjectionPointImpl ppi = new ProjectionPointImpl();
    LatLonPointImpl llpi = new LatLonPointImpl();

    for (int i = 0; i < from[0].length; i++) {
      llpi.setLatitude(from[latIndex][i]);
      llpi.setLongitude(from[lonIndex][i]);
      latLonToProj(llpi, ppi);
      to[0][i] = (float) ppi.getX();
      to[1][i] = (float) ppi.getY();
    }

    return to;
  }
public float[][] latLonToProj(float[][] from, float[][] to, int latIndex,
                                int lonIndex) {
    //      ucar.unidata.util.Misc.printStack ("latLonToProj-" + this + " size=" + from[0].length, 4, null);

    if ((from == null) || (from.length != 2)) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "null array argument or wrong dimension (from)");
    }
    if ((to == null) || (to.length != 2)) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "null array argument or wrong dimension (to)");
    }

    if (from[0].length != to[0].length) {
      throw new IllegalArgumentException("ProjectionImpl.latLonToProj:"
              + "from array not same length as to array");
    }

    ProjectionPointImpl ppi = new ProjectionPointImpl();
    LatLonPointImpl llpi = new LatLonPointImpl();

    for (int i = 0; i < from[0].length; i++) {
      llpi.setLatitude(from[latIndex][i]);
      llpi.setLongitude(from[lonIndex][i]);
      latLonToProj(llpi, ppi);
      to[0][i] = (float) ppi.getX();
      to[1][i] = (float) ppi.getY();
    }

    return to;
  }
public float [ ] [ ] latLonToProj ( float [ ] [ ] from , float [ ] [ ] to , int latIndex , int lonIndex ) { //      ucar.unidata.util.Misc.printStack ("latLonToProj-" + this + " size=" + from[0].length, 4, null);
 if ( ( from == null ) || ( from . length != 2 ) ) { throw new IllegalArgumentException ( "ProjectionImpl.latLonToProj:" + "null array argument or wrong dimension (from)" ) ; } if ( ( to == null ) || ( to . length != 2 ) ) { throw new IllegalArgumentException ( "ProjectionImpl.latLonToProj:" + "null array argument or wrong dimension (to)" ) ; } if ( from [ 0 ] . length != to [ 0 ] . length ) { throw new IllegalArgumentException ( "ProjectionImpl.latLonToProj:" + "from array not same length as to array" ) ; } ProjectionPointImpl ppi = new ProjectionPointImpl ( ) ; LatLonPointImpl llpi = new LatLonPointImpl ( ) ; for ( int i = 0 ; i < from [ 0 ] . length ; i ++ ) { llpi . setLatitude ( from [ latIndex ] [ i ] ) ; llpi . setLongitude ( from [ lonIndex ] [ i ] ) ; latLonToProj ( llpi , ppi ) ; to [ 0 ] [ i ] = ( float ) ppi . getX ( ) ; to [ 1 ] [ i ] = ( float ) ppi . getY ( ) ; } return to ; }
Convert lat/lon coordinates to projection coordinates.

@param from     array of lat/lon coordinates: from[2][n], where
(from[latIndex][i], from[lonIndex][i]) is the (lat,lon)
coordinate of the ith point
@param to       resulting array of projection coordinates: to[2][n]
where (to[0][i], to[1][i]) is the (x,y) coordinate of
the ith point
@param latIndex index of lat coordinate; must be 0 or 1
@param lonIndex index of lon coordinate; must be 0 or 1
@return the "to" array
Convert lat / lon coordinates to projection coordinates .