[patch] export relation to GPX file or convert to a new GPX layer (e.g. for further editing such as simplify way)

I've tackled on the lack of an export feature for route relations,
and this is what I've come up with..

..in the hope it will be useful to someone.

The algorithm runs recursively on the found relation members,
but ignores incomplete relations (i.e. downloading of incomplete
relations is not done automatically currently, but could be added).

sort order of the relations is untouched and roles forward/backward are recognized

single-membered roundabouts are silently skipped (i.e. no new trkSeg is started)

loops (forward/backward) should be handled correctly (i.e. one direction is ignored,
depending on the menu entry chosen)

The aim is primarily to reply a single segmented track from A to B, but if the sort
order of the relation does not provide this, multiple track segments for the generated
GPX are created. We could run the relationSorter and try to fix a broken order before
GPX export, but this discourages users to actually fix broken route relations, so the
algorithm _intentionally_ takes the sort order of the relation as they are.

2nd line produces unique names in the event that more than one tracks (with exactly one segment each) result from traveling the route relation (i.e. if it is broken or unsorted) OR from splitting an existing gpx track with multiple segments into tracks (.. with one segment each)

1st line ensures that the name suffix does not grow when split / combine actions are called repeatedly, e.g. to avoid Interesting Route #2 #2 #2 after three iterations, this line is probably only important when (count>0) is used instead (or when the track has been saved, first segment removed and reimported, so that a #2 suffixed segment is at the start of the track list).

The messages need some improvements to make them translatable into other languages. Especially the "first"/"last" messages are not translatable at the moment. E.g. this in ExportRelationToGpxAction.java:

Please do not assume that the order of words and inflection of first/last is the same in all languages in the world. To make it translatable we need complete sentences, not a word puzzle. So that needs to be 4 sentences.

Please make this two strings, one starting with "first" and one starting with "last":

tr("Flatten this relation to a single gpx track "+"recursively, starting with the {0} member(s), "+"successively continuing to the {1}.",
mode.contains(FROM_FIRST_MEMBER)? tr("first"): tr("last"),
mode.contains(FROM_FIRST_MEMBER)? tr("last"): tr("first")),

If it can be "member" and "members" in English then that need to be 2 trn().

The mouseover hint says e.g. "...starting with the first member(s)...". How can the first member be plural?

There may either be a first member or some first members, which is why the s is put within parentheses.

Compare

the first natural number

1, 2, 3 are among the first natural numbers

the first couple/triple/(..) in a row

"First" is an attribute to qualify a position in an ordered set, but it does not constrain the object qualified to be singular. Do you have a reference that stands in contradiction?

Even in places where the "first" commonly is a singularity, say a race, there is the rare case of a shared first place, i.e. two or more first places, if the contestants where measured to have done equally well with respect to the game rules.

That being said, it's probably pedantic to account for this here, so I do not oppose using the singular form instead, if you consider this bug.

There may either be a first member or some first members, which is why the s is put within parentheses.

@cmuelle8: Out of curiosity: Do you have an example of a relation with multiple first or last members? I looked at the definition of a relation (e.g. ​https://wiki.openstreetmap.org/wiki/OSM_XML), and I think there is always exactly one first and one last element (or no first/last if it is an empty relation). I can select multiple relations and call your function, but I assume then you process the relations one-by-one, so it will be still one first/last member. Or do you think of the case where the first/last element is another relation with multiple members?

The "member(s)" looks fishy, as if you forgot to use the singular/plural version of tr(), see the last sentence in comment:14.

Add Comment

This ticket has been modified since you started editing. You should review the
other modifications which have been appended above,
and any conflicts shown in the preview below.
You can nevertheless proceed and submit your changes if you wish so.