コード例 #1
0
ファイル: JDBCAccessBase.java プロジェクト: Geodan/geotools
  /**
   * Step 3 of the bootstrapping process.
   *
   * <p>Calculating the the resolution for each image level (original + pyramids). This calculation
   * is only done if the resultion info in the master table is SQL NULL. After calculation the meta
   * table is updated with the result to avoid this operation in the future.
   *
   * @param coverageName The coverage name in the sql meta table
   * @param con JDBC Connection
   * @throws SQLException
   * @throws IOException
   */
  void calculateResolutionsFromDB(String coverageName, Connection con)
      throws SQLException, IOException {
    PreparedStatement stmt = null;

    stmt = con.prepareStatement(config.getSqlUpdateResStatement());

    List<ImageLevelInfo> toBeRemoved = new ArrayList<ImageLevelInfo>();

    for (ImageLevelInfo li : levelInfos) {
      if (li.getCoverageName().equals(coverageName) == false) {
        continue;
      }

      if (li.calculateResolutionNeeded() == false) {
        continue;
      }

      Date start = new Date();
      if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Calculate resolutions for " + li.toString());

      double[] resolutions = getPixelResolution(li, con);

      if (resolutions == null) {
        if (LOGGER.isLoggable(Level.WARNING))
          LOGGER.log(Level.WARNING, "No image found, removing " + li.toString());
        toBeRemoved.add(li);

        continue;
      }

      li.setResX(resolutions[0]);
      li.setResY(resolutions[1]);
      if (LOGGER.isLoggable(Level.INFO))
        LOGGER.info("ResX: " + li.getResX() + " ResY: " + li.getResY());

      // li.setColorModel(loadedImage.getColorModel());
      stmt.setDouble(1, li.getResX().doubleValue());
      stmt.setDouble(2, li.getResY().doubleValue());
      stmt.setString(3, li.getCoverageName());
      stmt.setString(4, li.getTileTableName());
      stmt.setString(5, li.getSpatialTableName());
      stmt.execute();

      long msecs = (new Date()).getTime() - start.getTime();

      if (LOGGER.isLoggable(Level.INFO))
        LOGGER.info(
            "Calculate resolutions for " + li.toString() + " finished in " + msecs + " ms ");
    }

    levelInfos.removeAll(toBeRemoved);

    if (stmt != null) {
      stmt.close();
    }
  }
コード例 #2
0
ファイル: JDBCAccessBase.java プロジェクト: Geodan/geotools
  /**
   * Step 2 of the bootstrapping process.
   *
   * <p>Calculating the the extent for each image level (original + pyramids). This calculation is
   * only done if the extent info in the master table is SQL NULL. After calculation the meta table
   * is updated with the result to avoid this operation in the future.
   *
   * @param coverageName The coverage name in the sql meta table
   * @param con JDBC connection
   * @throws SQLException
   * @throws IOException
   */
  void calculateExtentsFromDB(String coverageName, Connection con)
      throws SQLException, IOException {
    PreparedStatement stmt = con.prepareStatement(config.getSqlUpdateMosaicStatement());

    List<ImageLevelInfo> toBeRemoved = new ArrayList<ImageLevelInfo>();

    for (ImageLevelInfo li : levelInfos) {
      if (li.getCoverageName().equals(coverageName) == false) {
        continue;
      }

      if (li.calculateExtentsNeeded() == false) {
        continue;
      }

      Date start = new Date();
      if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Calculate extent for " + li.toString());

      Envelope env = getExtent(li, con);

      if (env == null) {
        if (LOGGER.isLoggable(Level.WARNING))
          LOGGER.log(Level.WARNING, "No extent, removing this level");
        toBeRemoved.add(li);

        continue;
      }

      li.setExtentMaxX(new Double(env.getMaxX()));
      li.setExtentMaxY(new Double(env.getMaxY()));
      li.setExtentMinX(new Double(env.getMinX()));
      li.setExtentMinY(new Double(env.getMinY()));

      stmt.setDouble(1, li.getExtentMaxX().doubleValue());
      stmt.setDouble(2, li.getExtentMaxY().doubleValue());
      stmt.setDouble(3, li.getExtentMinX().doubleValue());
      stmt.setDouble(4, li.getExtentMinY().doubleValue());
      stmt.setString(5, li.getCoverageName());
      stmt.setString(6, li.getTileTableName());
      stmt.setString(7, li.getSpatialTableName());
      stmt.execute();

      long msecs = (new Date()).getTime() - start.getTime();

      if (LOGGER.isLoggable(Level.INFO))
        LOGGER.info("Calculate extent for " + li.toString() + " finished in " + msecs + " ms ");
    }

    levelInfos.removeAll(toBeRemoved);

    if (stmt != null) {
      stmt.close();
    }
  }
コード例 #3
0
ファイル: ImageLevelInfo.java プロジェクト: jericks/geotools
  public int compareTo(ImageLevelInfo other) {
    int res = 0;

    if ((res = getCoverageName().compareTo(other.getCoverageName())) != 0) {
      return res;
    }

    if ((res = getResX().compareTo(other.getResX())) != 0) {
      return res;
    }

    if ((res = getResY().compareTo(other.getResY())) != 0) {
      return res;
    }

    return 0;
  }