Ejemplo n.º 1
0
  /**
   * Prints a VPF Library
   *
   * @param prefix lines get printed with this prefix
   * @param cat the CoverageAttributeTable (Library) to print
   */
  public static void printLibrary(String prefix, CoverageAttributeTable cat) {
    StringBuffer printedlayers = new StringBuffer();
    String printedlayername = null;

    if (cat == null) {
      System.err.println(prefix + "Library doesn't exist");
      return;
    }
    String[] coverages = cat.getCoverageNames();
    if (Debug.debugging("vpf")) {
      Debug.output(prefix + "uses " + (cat.isTiledData() ? "tiled" : "untiled") + " data");
    }
    for (int i = 0; i < coverages.length; i++) {
      printedlayername = printCoverageProperties(prefix, cat, coverages[i]);
      if (printedlayername != null) {
        printedlayers.append(" " + printedlayername);
      }
    }
    println("# Summary:" + printedlayers);
  }
Ejemplo n.º 2
0
  /**
   * Prints a VPF Coverage
   *
   * @param prefix this will be the prefix of the generated layer name
   * @param covname the name of the coverage to print
   * @param cat the CoverageAttributeTable to get the Coverage from
   */
  public static String printCoverageProperties(
      String prefix, CoverageAttributeTable cat, String covname) {
    String layername = prefix + "_" + covname;
    List text_features = new ArrayList();
    List edge_features = new ArrayList();
    List area_features = new ArrayList();
    List point_features = new ArrayList();

    // add topology level
    CoverageTable ct = cat.getCoverageTable(covname);

    String path = ct.getDataPath();
    String fcaPath = path + "/fca";

    File fca = new File(fcaPath);
    if (!fca.exists()) {
      fcaPath = path + "/fca.";
      fca = new File(fcaPath);
    }
    if (!fca.canRead()) {
      println("");
      return null;
    }
    try {
      DcwRecordFile fcadesc = new DcwRecordFile(fcaPath);
      int fclass = fcadesc.whatColumn("fclass");
      int type = fcadesc.whatColumn("type");
      // int descr = fcadesc.whatColumn("descr");
      List v = new ArrayList();
      while (fcadesc.parseRow(v)) {
        String name = (String) v.get(fclass);
        String t = (String) v.get(type);
        // String desc = (String) v.get(descr);
        // String tstring = "[unknown] ";
        if (t.equals("T")) {
          text_features.add(name);
        } else if (t.equals("L")) {
          edge_features.add(name);
        } else if (t.equals("A")) {
          area_features.add(name);
        } else if (t.equals("P")) {
          point_features.add(name);
        }
      }
    } catch (FormatException fe) {
      // nevermind, skip it
    }

    // only print something, if we really found features
    if (!(text_features.isEmpty()
        && edge_features.isEmpty()
        && area_features.isEmpty()
        && point_features.isEmpty())) {

      println("### VPF " + cat.getCoverageDescription(covname) + " Layer");
      println(layername + ".class=com.bbn.openmap.layer.vpf.VPFLayer");
      println(
          layername + ".prettyName=" + "VPF " + cat.getCoverageDescription(covname) + " " + prefix);
      println(layername + ".vpfPath=" + rootpath);
      println(layername + ".coverageType=" + covname);
      println(layername + ".featureTypes=" + "area edge text point");

      printFeatures("text", text_features, layername);
      printFeatures("edge", edge_features, layername);
      printFeatures("area", area_features, layername);
      printFeatures("point", point_features, layername);
      println("");

    } else {
      return null;
    }

    return layername;
  }