Пример #1
0
  public GeoObject operate(GeoGrid geoGrid, double firstContourLevel, double lastContourLevel) {
    flags = new boolean[geoGrid.getRows()][geoGrid.getCols()];

    GeoSet geoSet = new GeoSet();

    final int nlevels = (int) ((lastContourLevel - firstContourLevel) / interval) + 1;
    if (treatDegreeJump) {
      GeoSet levelGeoSet = new GeoSet();
      this.contourLevel(geoGrid, 0.f, levelGeoSet);
      levelGeoSet.setName(Float.toString(0.f));
      geoSet.add(levelGeoSet);
    }

    for (int i = 0; i < nlevels; ++i) {
      final double contourLevel = firstContourLevel + i * interval;
      GeoSet levelGeoSet = new GeoSet();
      this.contourLevel(geoGrid, contourLevel, levelGeoSet);
      levelGeoSet.setName(Double.toString(contourLevel));
      geoSet.add(levelGeoSet);
    }
    return geoSet;
  }
Пример #2
0
  public GeoPath traceSingleContourAtPoint(GeoGrid geoGrid, double x, double y) {

    this.flags = new boolean[geoGrid.getRows()][geoGrid.getCols()];

    double cellSize = geoGrid.getCellSize();
    double west = geoGrid.getWest();
    double north = geoGrid.getNorth();
    double level = geoGrid.getBicubicInterpol(x, y);

    int[] cell = new int[] {(int) ((x - west) / cellSize), (int) ((north - y) / cellSize)};
    GeoPath geoPath = traceContour(geoGrid.getGrid(), cell, level, west, north, cellSize);
    return geoPath;
  }
Пример #3
0
  public void testTwoDataItemsAndWeights() {
    GeoGrid geoGrid = new GeoGrid(10);
    CoordImpl firstCoord = new CoordImpl(55, 55);
    CoordImpl secondCoord = new CoordImpl(56, 56);
    geoGrid.addGridInformation(new GridDataItem(2.0, 1.0, firstCoord));
    geoGrid.addGridInformation(new GridDataItem(10.0, 3.0, secondCoord));
    geoGrid.markDataCollectionPhaseAsFishished();

    assertEquals(8.0, geoGrid.getValue(firstCoord));
    assertEquals(8.0, geoGrid.getValue(secondCoord));
  }
Пример #4
0
  public void testSingleDataItem() {
    GeoGrid geoGrid = new GeoGrid(10);
    CoordImpl sampleCoord = new CoordImpl(55, 55);
    GridDataItem gridDataItem = new GridDataItem(5.0, 1.0, sampleCoord);
    geoGrid.addGridInformation(gridDataItem);
    geoGrid.markDataCollectionPhaseAsFishished();

    assertEquals(5.0, geoGrid.getValue(sampleCoord));
    assertEquals(5.0, geoGrid.getValue(new CoordImpl(50.0, 50.0)));
    assertEquals(5.0, geoGrid.getValue(new CoordImpl(100.0, 100.0)));
  }
Пример #5
0
  private void contourLevel(GeoGrid geoGrid, double level, GeoSet levelGeoSet) {

    final int nbrCellsX = geoGrid.getCols() - 1;
    final int nbrCellsY = geoGrid.getRows() - 1;
    float[][] grid = geoGrid.getGrid();
    double west = geoGrid.getWest();
    double north = geoGrid.getNorth();
    double cellSize = geoGrid.getCellSize();

    for (int i = 0; i < this.flags.length; i++) {
      java.util.Arrays.fill(this.flags[i], false);
    }

    for (int y = 0; y < nbrCellsY; y++) {
      boolean[] flag_row = flags[y];
      for (int x = 0; x < nbrCellsX; x++) {
        if (flag_row[x] == false) {
          traceContour(grid, new int[] {x, y}, level, west, north, cellSize, levelGeoSet);
        }
      }
    }
  }
Пример #6
0
 public GeoObject operate(GeoGrid geoGrid, double firstContourLevel) {
   float[] minMax = geoGrid.getMinMax();
   return operate(geoGrid, firstContourLevel, minMax[1]);
 }
Пример #7
0
 public GeoObject operate(GeoGrid geoGrid) {
   float[] minMax = geoGrid.getMinMax();
   final double firstContourLevel = Math.ceil(minMax[0] / interval) * interval;
   return operate(geoGrid, firstContourLevel);
 }