Opened 6 years ago

Last modified 6 years ago

#18494 closed enhancement

[RFC PATCH] GPX layers should use the name from the file instead of `Downloaded GPX Data` whenever possible — at Version 2

Reported by: taylor.smock Owned by: team
Priority: normal Milestone: 20.01
Component: Core Version:
Keywords: gpx Cc:

Description (last modified by Don-vip)

Right now it is not possible to set the name of a GPX layer on download. This means that GPX layers are commonly called Download GPX Data. It would be nice, if there is a name in the metadata, if JOSM could use that instead.

Use cases:
Tasking Managers could send an XML file that looks like this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<gpx creator="HOT Tasking Manager" version="1.1">
  <metadata>
    <link href="https://github.com/hotosm/tasking-manager">
      <text>HOT Tasking Manager</text>
    </link>
    <time>2019-12-31T21:56:28.586152</time>
    <name>Tasking Manager: Project 1, Task 1</name>
  </metadata>
  <trk>
    <name>Task for project 1. Do not edit outside of this area!</name>
    <trkseg>
      <trkpt lat="39.070328" lon="-108.561121"/>
      <trkpt lat="39.070438" lon="-108.571025"/>
      <trkpt lat="39.077663" lon="-108.57099"/>
      <trkpt lat="39.077499" lon="-108.56091"/>
      <trkpt lat="39.070328" lon="-108.561121"/>
    </trkseg>
  </trk>
  <wpt lat="39.070328" lon="-108.561121"/>
  <wpt lat="39.070438" lon="-108.571025"/>
  <wpt lat="39.077663" lon="-108.57099"/>
  <wpt lat="39.077499" lon="-108.56091"/>
  <wpt lat="39.070328" lon="-108.561121"/>
</gpx>

Please note that the current version of the tasking manager (TM3) creates an empty layer with the desired name and then loads in the GPX file.

Change History (4)

by taylor.smock, 6 years ago

Attachment: 18494.patch added

Initial patch (no tests)

comment:1 by taylor.smock, 6 years ago

Summary: [PATCH] GPX layers should use the name from the file instead of `Downloaded GPX Data` whenever possible[RFC PATCH] GPX layers should use the name from the file instead of `Downloaded GPX Data` whenever possible

As I was writing the test, I noticed that the default name comes from the file name.

What should be preferred? Name from file name, or name from the metadata? I (think) name from file name should be preferred, but it will make it harder to write a test case.

by taylor.smock, 6 years ago

Attachment: 18494.1.patch added

Move newLayerName logic to getLayerName function. Also, remove a pointless call in GpxLayer (super(nameInFile); setName(name);, where the super call essentially sets the name is pointless).

comment:2 by Don-vip, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.