private void traceContour( float[][] grid, int[] cell, double level, double west, double north, double cellSize, GeoSet levelGeoSet) { GeoPath geoPath = traceContour(grid, cell, level, west, north, cellSize); if (geoPath != null && geoPath.getPointsCount() > 1) { levelGeoSet.add(geoPath); } }
private GeoPath traceContour( float[][] grid, int[] cell, double level, double west, double north, double cellSize) { GeoPath geoPath = null; int[] current_cell = new int[] {cell[0], cell[1]}; double[] pt = new double[2]; pt[0] = west + cell[0] * cellSize; pt[1] = north + cell[1] * cellSize; int nbrPts = 0; final int cols = grid[0].length; final int rows = grid.length; // first trace contour in backward direction while (current_cell[0] >= 0 && current_cell[0] < cols - 1 && current_cell[1] >= 0 && current_cell[1] < rows - 1 && contourCell(false, grid, current_cell, level, west, north, cellSize, pt)) { if (nbrPts > 0) { geoPath.lineTo(pt[0], pt[1]); } else { geoPath = new GeoPath(); geoPath.moveTo(pt[0], pt[1]); } nbrPts++; } if (nbrPts > 1) { geoPath.invertDirection(); } // reset the flag for the starting cell flags[cell[1]][cell[0]] = false; current_cell[0] = cell[0]; current_cell[1] = cell[1]; // then trace contour in forward direction while (current_cell[0] >= 0 && current_cell[0] < cols - 1 && current_cell[1] >= 0 && current_cell[1] < rows - 1 && contourCell(true, grid, current_cell, level, west, north, cellSize, pt)) { if (nbrPts > 0) { geoPath.lineTo(pt[0], pt[1]); } else { geoPath = new GeoPath(); geoPath.moveTo(pt[0], pt[1]); } nbrPts++; } if (geoPath != null) { geoPath.setVectorSymbol(this.vectorSymbol); } return geoPath; }