예제 #1
0
  public static void setDataRoot(String root) {
    clearFactories();
    Path rootPath = Paths.get(root);
    String rootPathString = null;
    LOGGER.info("Orekit root path trying to be set to: " + rootPath.toAbsolutePath().toString());
    if (Files.exists(rootPath)) {
      LOGGER.info("File exists");
      rootPathString = rootPath.toAbsolutePath().toString();
    } else {
      LOGGER.info("Attempting to set through URI");
      URL embeddedPath = OrekitUtils.class.getClass().getResource(root);
      if (embeddedPath != null) {
        URI uri;
        try {
          uri = embeddedPath.toURI();
          if (uri != null) {
            rootPathString = uri.getPath();
          }

        } catch (URISyntaxException e) {
          e.printStackTrace();
        }
      }
    }

    if (rootPathString != null) {
      System.setProperty(DataProvidersManager.OREKIT_DATA_PATH, rootPathString);
    } else {
      throw new IllegalArgumentException(
          "Invalid path: " + root + System.lineSeparator() + rootPath.toAbsolutePath().toString());
    }
  }