* @return LLPoint[]
*/
public LLPoint[] clipToScreen(CoordFloatString cfs, float north,
float south, float east, float west,
float dpplat, float dpplon) {
LLPoint pts[] = new LLPoint[cfs.maxIndex()];
int lpcount = 0, outcount = 0, elimscale = 0;
float cfslls[] = cfs.vals;
int cfstupsize = cfs.tsize;
for (int i = 0; i < pts.length; i++) {
float lllon = cfslls[cfstupsize * i];
float lllat = cfslls[cfstupsize * i + 1];
if ((lllat < south) || (lllat > north)
|| ((west < east) && ((lllon < west) || (lllon > east)))
|| ((west > east) && (lllon < west) && (lllon > east))) {
outcount++;
if (((lpcount > 1) && (outcount > 2))
|| ((lpcount == 1) && (outcount > 1))) {
pts[lpcount] = new LLPoint(lllat, lllon); //overwrite
// previous
continue;
}
} else {
outcount = 0;
}
if ((lpcount > 0)
&& (i != (pts.length - 1))
&& (java.lang.Math.abs(pts[lpcount - 1].lat - lllat) < dpplat)
&& (java.lang.Math.abs(pts[lpcount - 1].lon - lllon) < dpplon)) {
elimscale++;
continue;
}
pts[lpcount++] = new LLPoint(lllat, lllon);
}
//only 1 point in poly, and it was out of bounds...
if ((lpcount == 1) && (outcount > 0))
lpcount = 0;
if (lpcount != cfs.maxIndex()) {
LLPoint newpts[] = new LLPoint[lpcount];
System.arraycopy(pts, 0, newpts, 0, lpcount);
pts = newpts;
//System.out.println("Old(" + cfs.maxIndex() +
// ")-area(" + elimarea+")-scale(" + elimscale +
// ") = new(" + pts.length + ")");