protected ArrayList<float[]> _forwardPoly(double[] rawllpts,int ltype,int nsegs,boolean isFilled){
  boolean DEBUG=Debug.debugging("proj");
  int len=rawllpts.length >>> 1;
  if (len < 2)   return new ArrayList<float[]>(0);
  if (isComplicatedLineType(ltype))   return doPolyDispatch(rawllpts,ltype,nsegs,isFilled);
  int invalid_count=0;
  boolean curr_invalid, prev_invalid=false;
  Point temp=new Point();
  AzimuthVar az_first=null, az_save=null, azVar=new AzimuthVar();
  ArrayList<AzimuthVar> sections=new ArrayList<AzimuthVar>(128);
  float[] x_, xs=new float[len];
  float[] y_, ys=new float[len];
  _forward(rawllpts[0],rawllpts[1],temp,azVar);
  xs[0]=temp.x;
  ys[0]=temp.y;
  prev_invalid=azVar.invalid_forward;
  if (prev_invalid) {
    ++invalid_count;
  }
 else {
    azVar.index=0;
    azVar.current_azimuth=(float)GreatCircle.sphericalAzimuth(centerY,centerX,rawllpts[0],rawllpts[1]);
    if (!isFilled) {
      sections.add(azVar);
    }
 else {
      az_first=azVar;
    }
    azVar=new AzimuthVar();
  }
  int i=0, j=0;
  for (i=1, j=2; i < len; i++, j+=2) {
    azVar.invalid_forward=false;
    _forward(rawllpts[j],rawllpts[j + 1],temp,azVar);
    curr_invalid=azVar.invalid_forward;
    xs[i]=temp.x;
    ys[i]=temp.y;
    if (!curr_invalid && prev_invalid) {
      azVar.index=i - 1;
      azVar.current_azimuth=(float)GreatCircle.sphericalAzimuth(centerY,centerX,rawllpts[j - 2],rawllpts[j - 1]);
      sections.add(azVar);
      azVar=new AzimuthVar();
    }
 else     if (curr_invalid) {
      if (!prev_invalid) {
        azVar.index=i;
        if (isFilled && (invalid_count == 0)) {
          az_save=azVar;
        }
 else {
          sections.add(azVar);
        }
        azVar=new AzimuthVar();
      }
      ++invalid_count;
    }
    prev_invalid=curr_invalid;
  }
  if (invalid_count == 0) {
    ArrayList<float[]> ret_val=new ArrayList<float[]>(2);
    ret_val.add(xs);
    ret_val.add(ys);
    return ret_val;
  }
  if (invalid_count == len) {
    return new ArrayList<float[]>(0);
  }
  if (!prev_invalid) {
    if (isFilled && (az_save != null)) {
      int l=az_save.index;
      x_=new float[len + l];
      y_=new float[len + l];
      System.arraycopy(xs,0,x_,0,len);
      System.arraycopy(ys,0,y_,0,len);
      System.arraycopy(xs,0,x_,len,l);
      System.arraycopy(ys,0,y_,len,l);
      az_save.index=len + l;
      sections.add(az_save);
      xs=x_;
      ys=y_;
    }
 else {
      if (DEBUG && isFilled && (az_save == null)) {
        Debug.output("AA, filled, no-wrap!");
      }
      azVar.index=i;
      j=rawllpts.length;
      azVar.current_azimuth=(float)GreatCircle.sphericalAzimuth(centerY,centerX,rawllpts[j - 2],rawllpts[j - 1]);
      sections.add(azVar);
    }
  }
 else   if (az_save != null) {
    if (DEBUG)     Debug.output("DD, filled!");
    sections.add(az_first);
    sections.add(az_save);
  }
  int size=sections.size();
  ArrayList<float[]> ret_val=new ArrayList<float[]>(size);
  if (isFilled && (len > 2)) {
    generateFilledPoly(xs,ys,sections,ret_val);
    return ret_val;
  }
  for (j=0; j < size; j+=2) {
    AzimuthVar az1=(AzimuthVar)sections.get(j);
    AzimuthVar az2=(AzimuthVar)sections.get(j + 1);
    int off1=az1.index;
    int off2=az2.index;
    int l=off2 - off1;
    x_=new float[l];
    y_=new float[l];
    System.arraycopy(xs,off1,x_,0,l);
    System.arraycopy(ys,off1,y_,0,l);
    ret_val.add(x_);
    ret_val.add(y_);
  }
  return ret_val;
}

protected ArrayList < float [ ] > _forwardPoly ( double [ ] rawllpts , int ltype , int nsegs , boolean isFilled ) { boolean DEBUG = Debug . debugging ( "proj" ) ; int len = rawllpts . length > > > 1 ; if ( len < 2 ) return new ArrayList < float [ ] > ( 0 ) ; if ( isComplicatedLineType ( ltype ) ) return doPolyDispatch ( rawllpts , ltype , nsegs , isFilled ) ; int invalid_count = 0 ; boolean curr_invalid , prev_invalid = false ; Point temp = new Point ( ) ; AzimuthVar az_first = null , az_save = null , azVar = new AzimuthVar ( ) ; ArrayList < AzimuthVar > sections = new ArrayList < AzimuthVar > ( 128 ) ; float [ ] x_ , xs = new float [ len ] ; float [ ] y_ , ys = new float [ len ] ; _forward ( rawllpts [ 0 ] , rawllpts [ 1 ] , temp , azVar ) ; xs [ 0 ] = temp . x ; ys [ 0 ] = temp . y ; prev_invalid = azVar . invalid_forward ; if ( prev_invalid ) { ++ invalid_count ; } else { azVar . index = 0 ; azVar . current_azimuth = ( float ) GreatCircle . sphericalAzimuth ( centerY , centerX , rawllpts [ 0 ] , rawllpts [ 1 ] ) ; if ( ! isFilled ) { sections . add ( azVar ) ; } else { az_first = azVar ; } azVar = new AzimuthVar ( ) ; } int i = 0 , j = 0 ; for ( i = 1 , j = 2 ; i < len ; i ++ , j += 2 ) { azVar . invalid_forward = false ; _forward ( rawllpts [ j ] , rawllpts [ j + 1 ] , temp , azVar ) ; curr_invalid = azVar . invalid_forward ; xs [ i ] = temp . x ; ys [ i ] = temp . y ; if ( ! curr_invalid && prev_invalid ) { azVar . index = i - 1 ; azVar . current_azimuth = ( float ) GreatCircle . sphericalAzimuth ( centerY , centerX , rawllpts [ j - 2 ] , rawllpts [ j - 1 ] ) ; sections . add ( azVar ) ; azVar = new AzimuthVar ( ) ; } else if ( curr_invalid ) { if ( ! prev_invalid ) { azVar . index = i ; if ( isFilled && ( invalid_count == 0 ) ) { az_save = azVar ; } else { sections . add ( azVar ) ; } azVar = new AzimuthVar ( ) ; } ++ invalid_count ; } prev_invalid = curr_invalid ; } if ( invalid_count == 0 ) { ArrayList < float [ ] > ret_val = new ArrayList < float [ ] > ( 2 ) ; ret_val . add ( xs ) ; ret_val . add ( ys ) ; return ret_val ; } if ( invalid_count == len ) { return new ArrayList < float [ ] > ( 0 ) ; } if ( ! prev_invalid ) { if ( isFilled && ( az_save != null ) ) { int l = az_save . index ; x_ = new float [ len + l ] ; y_ = new float [ len + l ] ; System . arraycopy ( xs , 0 , x_ , 0 , len ) ; System . arraycopy ( ys , 0 , y_ , 0 , len ) ; System . arraycopy ( xs , 0 , x_ , len , l ) ; System . arraycopy ( ys , 0 , y_ , len , l ) ; az_save . index = len + l ; sections . add ( az_save ) ; xs = x_ ; ys = y_ ; } else { if ( DEBUG && isFilled && ( az_save == null ) ) { Debug . output ( "AA, filled, no-wrap!" ) ; } azVar . index = i ; j = rawllpts . length ; azVar . current_azimuth = ( float ) GreatCircle . sphericalAzimuth ( centerY , centerX , rawllpts [ j - 2 ] , rawllpts [ j - 1 ] ) ; sections . add ( azVar ) ; } } else if ( az_save != null ) { if ( DEBUG ) Debug . output ( "DD, filled!" ) ; sections . add ( az_first ) ; sections . add ( az_save ) ; } int size = sections . size ( ) ; ArrayList < float [ ] > ret_val = new ArrayList < float [ ] > ( size ) ; if ( isFilled && ( len > 2 ) ) { generateFilledPoly ( xs , ys , sections , ret_val ) ; return ret_val ; } for ( j = 0 ; j < size ; j += 2 ) { AzimuthVar az1 = ( AzimuthVar ) sections . get ( j ) ; AzimuthVar az2 = ( AzimuthVar ) sections . get ( j + 1 ) ; int off1 = az1 . index ; int off2 = az2 . index ; int l = off2 - off1 ; x_ = new float [ l ] ; y_ = new float [ l ] ; System . arraycopy ( xs , off1 , x_ , 0 , l ) ; System . arraycopy ( ys , off1 , y_ , 0 , l ) ; ret_val . add ( x_ ) ; ret_val . add ( y_ ) ; } return ret_val ; }
forward project a lat / lon poly . this is a complex method . please read the in - code documentation for an explanation of the algorithm .
