예제 #1
0
  public ConsoleHelper(String mapsetPath, String remotedbUrl, PrintStream out, PrintStream err) {
    p_remotedbUrl = remotedbUrl;
    File mapsetFile = new File(mapsetPath);
    p_mapsetPath = mapsetFile.getAbsolutePath();
    p_locationPath = mapsetFile.getParent();
    p_mapsetName = mapsetFile.getName();

    if (out == null) {
      p_out = System.out;
    } else {
      p_out = out;
    }
    if (err == null) {
      p_err = System.err;
    } else {
      p_err = err;
    }
    String windPath = p_mapsetPath + File.separator + JGrassConstants.WIND;
    try {
      p_activeRegion = new JGrassRegion(windPath);
    } catch (IOException e) {
      e.printStackTrace();
    }
    north = p_activeRegion.getNorth();
    south = p_activeRegion.getSouth();
    east = p_activeRegion.getEast();
    west = p_activeRegion.getWest();
    weres = p_activeRegion.getWEResolution();
    nsres = p_activeRegion.getNSResolution();
    rows = p_activeRegion.getRows();
    cols = p_activeRegion.getCols();

    monitor = new PrintStreamProgressMonitor(p_out);
  }
예제 #2
0
 public static void updateActiveregion() {
   String windPath = p_mapsetPath + File.separator + JGrassConstants.WIND;
   try {
     p_activeRegion = new JGrassRegion(windPath);
   } catch (IOException e) {
     e.printStackTrace();
   }
   north = p_activeRegion.getNorth();
   south = p_activeRegion.getSouth();
   east = p_activeRegion.getEast();
   west = p_activeRegion.getWest();
   weres = p_activeRegion.getWEResolution();
   nsres = p_activeRegion.getNSResolution();
   rows = p_activeRegion.getRows();
   cols = p_activeRegion.getCols();
   p_out.println("Updated active region...");
 }
예제 #3
0
  @SuppressWarnings("nls")
  public void testFlow() throws IOException {
    JGrassMapEnvironment jGrassMapEnvironment = GrassMapTest.jME;

    // set active region to the needed
    JGrassRegion fileRegion = jGrassMapEnvironment.getFileRegion();
    JGrassRegion activeRegion = jGrassMapEnvironment.getActiveRegion();
    JGrassRegion.writeWINDToMapset(jGrassMapEnvironment.getMAPSET().getAbsolutePath(), fileRegion);

    PrintStream out = System.out;
    PrintStream err = System.err;

    String global_grassdb = jGrassMapEnvironment.getLOCATION().getParent();
    String global_location = jGrassMapEnvironment.getLOCATION().getName();
    String global_mapset = jGrassMapEnvironment.getMAPSET().getName();
    String global_startdate = "null";
    String global_enddate = "null";
    String global_deltat = "-1";
    String global_remotedb = "null";
    h_flow flow = new h_flow(out, err);
    Argument[] flowArgs = new Argument[7];
    flowArgs[0] = new Argument("grassdb", global_grassdb, true);
    flowArgs[1] = new Argument("location", global_location, true);
    flowArgs[2] = new Argument("mapset", global_mapset, true);
    flowArgs[3] = new Argument("time_start_up", global_startdate, true);
    flowArgs[4] = new Argument("time_ending_up", global_enddate, true);
    flowArgs[5] = new Argument("time_delta", global_deltat, true);
    flowArgs[6] = new Argument("remotedburl", global_remotedb, true);
    flow.initialize(flowArgs);

    DummyInputGrassCoverageMap igrass_pit =
        new DummyInputGrassCoverageMap(out, err, GrassMapTest.pitData);
    Argument[] inputArgs = new Argument[9];
    inputArgs[0] = new Argument("igrass", "pit", true);
    inputArgs[1] = new Argument("quantityid", "pit", true);
    inputArgs[2] = new Argument("grassdb", global_grassdb, true);
    inputArgs[3] = new Argument("location", global_location, true);
    inputArgs[4] = new Argument("mapset", global_mapset, true);
    inputArgs[5] = new Argument("time_start_up", global_startdate, true);
    inputArgs[6] = new Argument("time_ending_up", global_enddate, true);
    inputArgs[7] = new Argument("time_delta", global_deltat, true);
    inputArgs[8] = new Argument("remotedburl", global_remotedb, true);
    igrass_pit.initialize(inputArgs);

    Link igrass_link_pit = new Link(null, "pit");
    igrass_link_pit.connect(
        igrass_pit, igrass_pit.getOutputExchangeItem(0), flow, flow.getInputExchangeItem(0));

    OutputGrassCoverageWriter dummyOutEI = new OutputGrassCoverageWriter(out, err);
    Argument[] dummyArguments = new Argument[9];
    dummyArguments[0] = new Argument("ograss", "flow", true);
    dummyArguments[1] = new Argument("quantityid", "flow", true);
    dummyArguments[2] = new Argument("grassdb", global_grassdb, true);
    dummyArguments[3] = new Argument("location", global_location, true);
    dummyArguments[4] = new Argument("mapset", global_mapset, true);
    dummyArguments[5] = new Argument("time_start_up", global_startdate, true);
    dummyArguments[6] = new Argument("time_ending_up", global_enddate, true);
    dummyArguments[7] = new Argument("time_delta", global_deltat, true);
    dummyArguments[8] = new Argument("remotedburl", global_remotedb, true);
    dummyOutEI.initialize(dummyArguments);

    Link dummyOutLink = new Link(null, "flow");
    dummyOutLink.connect(
        flow, flow.getOutputExchangeItem(0), dummyOutEI, dummyOutEI.getInputExchangeItem(0));

    assertTrue(dummyOutLink.isConnected());

    igrass_pit.prepare();
    flow.prepare();
    IValueSet valueSet = flow.getValues(null, dummyOutLink.getID());
    igrass_pit.finish();
    flow.finish();

    GridCoverage2D rasterData = ((JGrassGridCoverageValueSet) valueSet).getGridCoverage2D();

    checkMatrixEqual(rasterData.getRenderedImage(), GrassMapTest.flowData, 0);

    // set active region to the needed
    JGrassRegion.writeWINDToMapset(
        jGrassMapEnvironment.getMAPSET().getAbsolutePath(), activeRegion);
  }