Beispiel #1
0
  @Override
  public void prepare(ProgressMonitor m) throws IOException {
    // round up all the files with the same name
    suppFiles = new ArrayList();
    prjFile = null;

    // getBaseName only gets the LAST extension so beware for .shp.aux.xml stuff
    final String baseName = getBaseName(file.name());

    for (Resource f : file.parent().list()) {
      if (f.equals(file)) {
        continue;
      }

      if (!f.name().startsWith(baseName)) {
        continue;
      }

      if (f.getType() != Type.RESOURCE) {
        continue;
      }

      String ext = f.name().substring(baseName.length());
      // once the basename is stripped, extension(s) should be present
      if (ext.charAt(0) == '.') {
        if (".prj".equalsIgnoreCase(ext)) {
          prjFile = f;
        } else {
          suppFiles.add(f);
        }
      }
    }
    if (format == null) {
      format = DataFormat.lookup(file);
    }

    // fix the prj file (match to official epsg wkt)
    try {
      fixPrjFile();
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Error fixing prj file", e);
    }
  }