Modify

Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#18494 closed enhancement (fixed)

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

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.

Attachments (3)

18494.patch (1.5 KB) - added by taylor.smock 10 months ago.
Initial patch (no tests)
18494.1.patch (4.3 KB) - added by taylor.smock 10 months ago.
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).
18494.2.patch (4.9 KB) - added by taylor.smock 10 months ago.
Add advanced config variable to use meta data name over filename

Download all attachments as: .zip

Change History (10)

Changed 10 months ago by taylor.smock

Attachment: 18494.patch added

Initial patch (no tests)

comment:1 Changed 10 months ago by taylor.smock

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.

Changed 10 months ago by taylor.smock

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 Changed 10 months ago by Don-vip

Description: modified (diff)

comment:3 Changed 10 months ago by Don-vip

I would say file name should have priority over metadata. An advanced property that inverts this behaviour would be okay if you think it's worth it.

comment:4 in reply to:  3 Changed 10 months ago by taylor.smock

Replying to Don-vip:

I would say file name should have priority over metadata. An advanced property that inverts this behaviour would be okay if you think it's worth it.

I don't think it would be worth the added complexity. I'd pretty much have to have two branches, both doing essentially the same thing, but with the order reversed.

Changed 10 months ago by taylor.smock

Attachment: 18494.2.patch added

Add advanced config variable to use meta data name over filename

comment:5 Changed 10 months ago by Don-vip

Milestone: 20.01

comment:6 Changed 10 months ago by Don-vip

Resolution: fixed
Status: newclosed

In 15646/josm:

fix #18494 - GPX layers should use the name from the file instead of Downloaded GPX Data whenever possible (patch by taylor.smock, modified)

comment:7 Changed 10 months ago by Don-vip

In 15652/josm:

see #18494 - fix NPE when downloading GPX data by bounds and not by URL

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.