public double[][] latLonToProj(double[][] from, double[][] to,
                                 int latIndex, int lonIndex) {
    int cnt = from[0].length;
    double[] toX = to[INDEX_X];
    double[] toY = to[INDEX_Y];
    double[] fromLat = from[latIndex];
    double[] fromLon = from[lonIndex];
    double lat, lon;
    for (int i = 0; i < cnt; i++) {
      lat = fromLat[i];
      lon = centerLon + Math.IEEEremainder(fromLon[i] - centerLon, 360.0);
      toX[i] = lon;
      toY[i] = lat;
    }
    return to;
  }
public double[][] latLonToProj(double[][] from, double[][] to,
                                 int latIndex, int lonIndex) {
    int cnt = from[0].length;
    double[] toX = to[INDEX_X];
    double[] toY = to[INDEX_Y];
    double[] fromLat = from[latIndex];
    double[] fromLon = from[lonIndex];
    double lat, lon;
    for (int i = 0; i < cnt; i++) {
      lat = fromLat[i];
      lon = centerLon + Math.IEEEremainder(fromLon[i] - centerLon, 360.0);
      toX[i] = lon;
      toY[i] = lat;
    }
    return to;
  }
public double [ ] [ ] latLonToProj ( double [ ] [ ] from , double [ ] [ ] to , int latIndex , int lonIndex ) { int cnt = from [ 0 ] . length ; double [ ] toX = to [ INDEX_X ] ; double [ ] toY = to [ INDEX_Y ] ; double [ ] fromLat = from [ latIndex ] ; double [ ] fromLon = from [ lonIndex ] ; double lat , lon ; for ( int i = 0 ; i < cnt ; i ++ ) { lat = fromLat [ i ] ; lon = centerLon + Math . IEEEremainder ( fromLon [ i ] - centerLon , 360.0 ) ; toX [ i ] = lon ; toY [ i ] = lat ; } 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 .