Пример #1
0
  private void writeMetaData() {
    Map<String, Object> attr = data.attr;
    openln("metadata");

    // write the description
    if (attr.containsKey(META_DESC)) {
      simpleTag("desc", data.getString(META_DESC));
    }

    // write the author details
    if (attr.containsKey(META_AUTHOR_NAME) || attr.containsKey(META_AUTHOR_EMAIL)) {
      openln("author");
      // write the name
      simpleTag("name", data.getString(META_AUTHOR_NAME));
      // write the email address
      if (attr.containsKey(META_AUTHOR_EMAIL)) {
        String[] tmp = data.getString(META_AUTHOR_EMAIL).split("@");
        if (tmp.length == 2) {
          inline("email", "id=\"" + tmp[0] + "\" domain=\"" + tmp[1] + '\"');
        }
      }
      // write the author link
      gpxLink((GpxLink) data.get(META_AUTHOR_LINK));
      closeln("author");
    }

    // write the copyright details
    if (attr.containsKey(META_COPYRIGHT_LICENSE) || attr.containsKey(META_COPYRIGHT_YEAR)) {
      openAtt("copyright", "author=\"" + data.get(META_COPYRIGHT_AUTHOR) + '\"');
      if (attr.containsKey(META_COPYRIGHT_YEAR)) {
        simpleTag("year", (String) data.get(META_COPYRIGHT_YEAR));
      }
      if (attr.containsKey(META_COPYRIGHT_LICENSE)) {
        simpleTag("license", encode((String) data.get(META_COPYRIGHT_LICENSE)));
      }
      closeln("copyright");
    }

    // write links
    if (attr.containsKey(META_LINKS)) {
      for (GpxLink link : data.<GpxLink>getCollection(META_LINKS)) {
        gpxLink(link);
      }
    }

    // write keywords
    if (attr.containsKey(META_KEYWORDS)) {
      simpleTag("keywords", data.getString(META_KEYWORDS));
    }

    Bounds bounds = data.recalculateBounds();
    if (bounds != null) {
      String b =
          "minlat=\""
              + bounds.getMinLat()
              + "\" minlon=\""
              + bounds.getMinLon()
              + "\" maxlat=\""
              + bounds.getMaxLat()
              + "\" maxlon=\""
              + bounds.getMaxLon()
              + '\"';
      inline("bounds", b);
    }

    if (data.fromServer) {
      openln("extensions");
      simpleTag("josm:from-server", "true");
      closeln("extensions");
    }

    closeln("metadata");
  }