private static Edge createTree(double polyLats[],double polyLons[]){
  Edge edges[]=new Edge[polyLats.length - 1];
  for (int i=1; i < polyLats.length; i++) {
    double lat1=polyLats[i - 1];
    double lon1=polyLons[i - 1];
    double lat2=polyLats[i];
    double lon2=polyLons[i];
    edges[i - 1]=new Edge(lat1,lon1,lat2,lon2,Math.min(lat1,lat2),Math.max(lat1,lat2));
  }
  Arrays.sort(edges,null);
  return createTree(edges,0,edges.length - 1);
}

private static Edge createTree ( double polyLats [ ] , double polyLons [ ] ) { Edge edges [ ] = new Edge [ polyLats . length - 1 ] ; for ( int i = 1 ; i < polyLats . length ; i ++ ) { double lat1 = polyLats [ i - 1 ] ; double lon1 = polyLons [ i - 1 ] ; double lat2 = polyLats [ i ] ; double lon2 = polyLons [ i ] ; edges [ i - 1 ] = new Edge ( lat1 , lon1 , lat2 , lon2 , Math . min ( lat1 , lat2 ) , Math . max ( lat1 , lat2 ) ) ; } Arrays . sort ( edges , null ) ; return createTree ( edges , 0 , edges . length - 1 ) ; }
creates an edge interval tree from a set of polygon vertices .
