Пример #1
0
 private void gpxExtensions(Extensions extensions) {
   if (extensions != null && !extensions.isEmpty()) {
     openln("extensions");
     for (Entry<String, String> e : extensions.entrySet()) {
       simpleTag("josm:" + e.getKey(), e.getValue());
     }
     closeln("extensions");
   }
 }
Пример #2
0
  /**
   * Writes the given GPX data.
   *
   * @param data The data to write
   */
  public void write(GpxData data) {
    this.data = data;
    // We write JOSM specific meta information into gpx 'extensions' elements.
    // In particular it is noted whether the gpx data is from the OSM server
    // (so the rendering of clouds of anonymous TrackPoints can be improved)
    // and some extra synchronization info for export of AudioMarkers.
    // It is checked in advance, if any extensions are used, so we know whether
    // a namespace declaration is necessary.
    boolean hasExtensions = data.fromServer;
    if (!hasExtensions) {
      for (WayPoint wpt : data.waypoints) {
        Extensions extensions = (Extensions) wpt.get(META_EXTENSIONS);
        if (extensions != null && !extensions.isEmpty()) {
          hasExtensions = true;
          break;
        }
      }
    }

    out.println("<?xml version='1.0' encoding='UTF-8'?>");
    out.println(
        "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"\n"
            + (hasExtensions
                ? String.format("    xmlns:josm=\"%s\"%n", JOSM_EXTENSIONS_NAMESPACE_URI)
                : "")
            + "    xmlns:xsi=\""
            + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
            + "\" \n"
            + "    xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">");
    indent = "  ";
    writeMetaData();
    writeWayPoints();
    writeRoutes();
    writeTracks();
    out.print("</gpx>");
    out.flush();
  }