Exemple #1
0
  public static void printFileInformation(File file) throws IOException {
    RandomAccessFile r = new RandomAccessFile(file.getAbsolutePath(), "r");
    try {
      BinaryMapIndexReader index = new BinaryMapIndexReader(r);
      int i = 1;
      System.out.println("Binary index " + file.getName() + " version = " + index.getVersion());
      for (BinaryIndexPart p : index.getIndexes()) {
        String partname = "";
        if (p instanceof MapIndex) {
          partname = "Map";
        } else if (p instanceof TransportIndex) {
          partname = "Transport";
        } else if (p instanceof AddressRegion) {
          partname = "Address";
        }
        String name = p.getName() == null ? "" : p.getName();
        System.out.println(
            MessageFormat.format(
                "{0}. {1} data {3} - {2} bytes", i, partname, p.getLength(), name));
        if (p instanceof TransportIndex) {
          TransportIndex ti = ((TransportIndex) p);
          int sh = (31 - BinaryMapIndexReader.TRANSPORT_STOP_ZOOM);
          System.out.println(
              "\t Bounds "
                  + formatBounds(
                      ti.getLeft() << sh,
                      ti.getRight() << sh,
                      ti.getTop() << sh,
                      ti.getBottom() << sh));
        } else if (p instanceof MapIndex) {
          MapIndex m = ((MapIndex) p);
          int j = 1;
          for (MapRoot mi : m.getRoots()) {
            System.out.println(
                MessageFormat.format(
                    "\t{4}.{5} Map level minZoom = {0}, maxZoom = {1}, size = {2} bytes \n\t\tBounds {3}",
                    mi.getMinZoom(),
                    mi.getMaxZoom(),
                    mi.getLength(),
                    formatBounds(mi.getLeft(), mi.getRight(), mi.getTop(), mi.getBottom()),
                    i,
                    j++));
          }
        }
        i++;
      }

    } catch (IOException e) {
      System.err.println("File is not valid index : " + file.getAbsolutePath());
      throw e;
    }
  }