コード例 #1
0
  public void printInfo(boolean printCoordinates) {
    System.out.printf(
        "%d, %s: %d parts, %d points",
        this.getRecordNumber(),
        this.getShapeType(),
        this.getNumberOfParts(),
        this.getNumberOfPoints());
    for (Map.Entry<String, Object> a : this.getAttributes().getEntries()) {
      if (a.getKey() != null) System.out.printf(", %s", a.getKey());
      if (a.getValue() != null) System.out.printf(", %s", a.getValue());
    }
    System.out.println();

    System.out.print("\tAttributes: ");
    for (Map.Entry<String, Object> entry : this.getAttributes().getEntries()) {
      System.out.printf("%s = %s, ", entry.getKey(), entry.getValue());
    }
    System.out.println();

    if (!printCoordinates) return;

    VecBuffer vb = this.getPointBuffer(0);
    for (LatLon ll : vb.getLocations()) {
      System.out.printf("\t%f, %f\n", ll.getLatitude().degrees, ll.getLongitude().degrees);
    }
  }
コード例 #2
0
  public void exportAsXML(XMLStreamWriter xmlWriter) throws IOException, XMLStreamException {
    if (xmlWriter == null) {
      String message = Logging.getMessage("Export.UnsupportedOutputObject");
      Logging.logger().warning(message);
      throw new IllegalArgumentException(message);
    }

    xmlWriter.writeStartElement("Record");

    xmlWriter.writeAttribute("id", Integer.toString(this.getRecordNumber()));
    xmlWriter.writeAttribute(
        "shape", this.getShapeType().substring(this.getShapeType().lastIndexOf("Shape") + 5));
    xmlWriter.writeAttribute("parts", Integer.toString(this.getNumberOfParts()));
    xmlWriter.writeAttribute("points", Integer.toString(this.getNumberOfPoints()));
    xmlWriter.writeCharacters("\n");

    for (Map.Entry<String, Object> a : this.getAttributes().getEntries()) {
      xmlWriter.writeStartElement("Attribute");

      xmlWriter.writeAttribute("name", a.getKey() != null ? a.getKey().toString() : "");
      xmlWriter.writeAttribute("value", a.getValue() != null ? a.getValue().toString() : "");

      xmlWriter.writeEndElement(); // Attribute
      xmlWriter.writeCharacters("\n");
    }

    if (this.getNumberOfParts() > 0) {
      VecBuffer vb = this.getPointBuffer(0);
      for (LatLon ll : vb.getLocations()) {
        xmlWriter.writeStartElement("Point");
        xmlWriter.writeAttribute("x", Double.toString(ll.getLatitude().degrees));
        xmlWriter.writeAttribute("y", Double.toString(ll.getLongitude().degrees));
        xmlWriter.writeEndElement(); // Point
        xmlWriter.writeCharacters("\n");
      }
    }

    // TODO: export record-type specific fields

    xmlWriter.writeEndElement(); // Record
  }