Example #1
0
  /**
   * This main function basically reads in the data sources (the shape file and the csv information
   * file, and creates a serialized graphics file that will act like a cache later.
   */
  public static void main(String[] argv) {
    String propertiesFile = null;
    String prefix = null;
    String outputFile = null;

    Debug.init();

    if (argv.length < 6) printUsage();

    for (int i = 0; i < argv.length; i++) {
      if (argv[i].equalsIgnoreCase("-props")) {
        propertiesFile = argv[++i];
      } else if (argv[i].equalsIgnoreCase("-prefix")) {
        prefix = argv[++i];
      } else if (argv[i].equalsIgnoreCase("-file")) {
        outputFile = argv[++i];
      }
    }

    if (propertiesFile == null || prefix == null || outputFile == null) {
      printUsage();
    }

    try {
      Properties properties = new Properties();
      // Read in the properties.
      URL propertiesURL = new URL(propertiesFile);
      InputStream is = propertiesURL.openStream();
      properties.load(is);

      // Let's make a file
      ShapeLayer sl = new ShapeLayer();
      sl.setProperties(prefix, properties);

      AreaHandler ah = new AreaHandler(sl.getSpatialIndex(), sl.getDrawingAttributes());

      // Set the properties in the handler.
      ah.setProperties(prefix, properties);
      // Write the saved graphics.
      ah.getGraphics().writeGraphics(outputFile);

    } catch (java.net.MalformedURLException murle) {
      Debug.error("Bad URL for properties file : " + propertiesFile);
      printUsage();
    } catch (java.io.IOException ioe) {
      Debug.error("IOException creating cached graphics file: " + outputFile);
      printUsage();
    }
  }
Example #2
0
  /**
   * The main program. Takes path arguments, and prints the DB it finds
   *
   * @param args the paths to print
   */
  public static void main(String[] args) throws FormatException {
    Debug.init();

    if (args.length == 0) {
      Debug.output(
          "Usage: java com.bbn.openmap.layer.vpf.GenerateVPFProperties <path to vpf database directory> <path to vpf database directory> ...");
      System.exit(0);
    }

    for (int argsi = 0; argsi < args.length; argsi++) {
      rootpath = args[argsi];
      LibrarySelectionTable lst = new LibrarySelectionTable(rootpath);
      if (Debug.debugging("vpf")) {
        Debug.output("Path to database: " + rootpath);
        Debug.output("Database Name: " + lst.getDatabaseName());
      }
      println("### Generated openmap.properties for");
      println("# VPF Data at: " + rootpath);
      println("# Description: " + lst.getDatabaseDescription());
      String[] libraries = lst.getLibraryNames();
      if (Debug.debugging("vpf")) {
        print("Database Libraries: ");
        for (int i = 0; i < libraries.length; i++) {
          print(libraries[i], " ");
        }
        println("");
        println("");
      }
      for (int i = 0; i < libraries.length; i++) {
        String prefix = lst.getDatabaseName() + "_" + libraries[i];
        println("# Library: " + prefix);
        printLibrary(prefix, lst.getCAT(libraries[i]));
        println("");
      }
    }
  }