Changeset 29631 in osm for applications/editors


Ignore:
Timestamp:
2013-06-06T21:46:20+02:00 (11 years ago)
Author:
donvip
Message:

[josm_directupload] fix #josm8758 - upload track to server: use description and keywords from gpx file

Location:
applications/editors/josm/plugins/DirectUpload
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/DirectUpload

    • Property svn:ignore
      •  

        old new  
        22build.log
        33build.err
         4bin
  • applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java

    r28014 r29631  
    3232
    3333import org.openstreetmap.josm.Main;
     34import org.openstreetmap.josm.data.gpx.GpxConstants;
    3435import org.openstreetmap.josm.data.gpx.GpxData;
     36import org.openstreetmap.josm.data.gpx.GpxTrack;
    3537import org.openstreetmap.josm.gui.ExtendedDialog;
    3638import org.openstreetmap.josm.gui.JMultilineLabel;
     
    140142       
    141143        List<String> descHistory = new LinkedList<String>(Main.pref.getCollection("directupload.description.history", new LinkedList<String>()));
    142         // we have to reverse the history, because ComboBoxHistory will reverse it againin addElement()
     144        // we have to reverse the history, because ComboBoxHistory will reverse it again in addElement()
    143145        // XXX this should be handled in HistoryComboBox
    144146        Collections.reverse(descHistory);
     
    175177
    176178    private void initTitleAndDescriptionFromGpxData(GpxData gpxData) {
    177       String description, title;
    178       try {
    179           description = gpxData.storageFile.getName().replaceAll("[&?/\\\\]"," ").replaceAll("(\\.[^.]*)$","");
     179      String description, title, tags = "";
     180      if (gpxData != null) {
     181          GpxTrack firstTrack = gpxData.tracks.iterator().next();
     182          Object meta_desc = gpxData.attr.get(GpxConstants.META_DESC);
     183          if (meta_desc != null) {
     184              description = meta_desc.toString();
     185          } else if (firstTrack != null && gpxData.tracks.size() == 1 && firstTrack.get("desc") != null) {
     186              description = firstTrack.getString("desc");
     187          } else {
     188              description = gpxData.storageFile.getName().replaceAll("[&?/\\\\]"," ").replaceAll("(\\.[^.]*)$","");
     189          }
    180190          title = tr("Selected track: {0}", gpxData.storageFile.getName());
     191          Object meta_tags = gpxData.attr.get(GpxConstants.META_KEYWORDS);
     192          if (meta_tags != null) {
     193              tags = meta_tags.toString();
     194          }
    181195      }
    182       catch(Exception e) {
     196      else {
    183197          description = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
    184198          title = tr("No GPX layer selected. Cannot upload a trace.");
     
    186200      OutputDisplay.setText(title);
    187201      descriptionField.setText(description);
     202      tagsField.setText(tags);
    188203    }
    189204
     
    191206     * This is the actual workhorse that manages the upload.
    192207     * @param String Description of the GPX track being uploaded
    193      * @param String Tags assosciated with the GPX track being uploaded
     208     * @param String Tags associated with the GPX track being uploaded
    194209     * @param boolean Shall the GPX track be public
    195210     * @param GpxData The GPX Data to upload
Note: See TracChangeset for help on using the changeset viewer.