Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#16681 closed enhancement (fixed)

[Patch] Various enhancements for GPX correlation

Reported by: Bjoeni Owned by: team
Priority: normal Milestone: 18.09
Component: Core image mapping Version:
Keywords: gpx, correlate, geoimage, image mapping, tag Cc: stoecker

Description (last modified by Bjoeni)

I recently started tagging lots of my photos with existing GPX tracks and wanted to do this with JOSM. Since I combined my tracks from different sources, I wanted to interpolate between the tracks and had to modify the method a bit. Well... then I ran into some more trouble (mainly because of messed up, but according to the TopoGrafix standard perfectly correct GPX files) and decided to put all the modifications in a patch. Even though that is not the main purpose of JOSM (and I would be perfectly fine with the whole tagging stuff being in a plugin), I think that the GPX correlation should work properly (and be usable with all kinds of valid GPX files) if it's a part of JOSM core after all.

So here's what I ended up changing:

  • Interpolation of timestamps within segments, if missing (mainly for manually modified GPX tracks)
  • Options to interpolate between tracks/segments, depending on distance/time
  • Options to determine whether images close to the end of a track should be tagged (instead of a hardcoded value only applying *before* segments)
  • Sort tracks and segments in the file by timestamps (and therefore allow correct tagging and interpolation if that's messed up)
  • Option to temporarily force tagging of all pictures (by applying the settings above)
  • fixed bug that caused problems with empty segments or entire segments without waypoints
  • Set elevation and speed only when photo is actually within a track segment or interpolation is activated
  • fixed bug that didn't show a preview of the currently tagged photos when the dialog was first opened
  • inverted the way timezones are applied (the set timezone must be substracted from the EXIF time in order to get ZULU time, not added and that's also conform with what the setOffset dialog returns)
  • use regex to parse timezone and allow more than ±12h, e.g. DST in New Zealand is UTC+13, Samoa can have UTC+14
  • add GPX files to the Combobox in the dialog if they are added (as a layer) while the dialog is opened

Ideas that could implemented in the future (by me or anyone else)...

  • try to determine the timezone from the loaded pictures by the EXIF 2.31 OffsetTime tags, difference of UTC EXIF tags and timezone specific EXIF tags or the timezone of the modification date, if applicable (i.e. if modification date equals DateTimeOriginal except for the offset)
  • allow existing timestamps to be overwritten without removing all existing ones that are not covered by the current track
  • allow multiple tracks to be processed and prioritized (from different sources, e.g. GPS + phone + Google Timeline) [cut overlapping parts of less important tracks and replace by more important ones -> merge before handling]

These are quite a lot of changes and I tested everything as far as I could... but GPX files can be quite messed up and I'm open to feedback (regarding bugs, style, whether these changes make sense at all, whatever...).

Because of the JSpinners in the JCheckboxes, I had to split up the strings. Any idea how to handle that for translation? Use trc and copy the other half in the context? Or use a sign inside the string to split it up after translation?

And it might be a good idea to split up the CorrelateGpxWithImages.java, I left it in one file for the time being to keep the patch smaller.

This is the advanced options dialog with the default settings at the moment:

And these are the prefs:

Attachments (6)

AdvancedDialog.png (21.2 KB ) - added by Bjoeni 6 years ago.
GeoimageSettings.png (67.6 KB ) - added by Bjoeni 6 years ago.
GPXCorrelate.patch (35.3 KB ) - added by Bjoeni 6 years ago.
CorrelateDialog.png (20.3 KB ) - added by Bjoeni 6 years ago.
GPXCorrelateV2.patch (112.1 KB ) - added by Bjoeni 6 years ago.
GPXCorrelateV3.patch (112.8 KB ) - added by Bjoeni 6 years ago.

Download all attachments as: .zip

Change History (23)

by Bjoeni, 6 years ago

Attachment: AdvancedDialog.png added

by Bjoeni, 6 years ago

Attachment: GeoimageSettings.png added

by Bjoeni, 6 years ago

Attachment: GPXCorrelate.patch added

in reply to:  description ; comment:1 by Don-vip, 6 years ago

Thanks for the patch! :)

Replying to Bjoeni:

Even though that is not the main purpose of JOSM (and I would be perfectly fine with the whole tagging stuff being in a plugin), I think that the GPX correlation should work properly (and be usable with all kinds of valid GPX files) if it's a part of JOSM core after all.

I think it's fine for JOSM core too.

So here's what I ended up changing:

I had a very quick look and have no objection with these change.

These are quite a lot of changes and I tested everything as far as I could... but GPX files can be quite messed up and I'm open to feedback (regarding bugs, style, whether these changes make sense at all, whatever...).

I trust you but given the number of changes, unit tests to ensure there is no regression would be more than welcome.

Also you may be aware we're working to implement a modular structure for JOSM core: #15229

CorrelateGpxWithImages is a perfect example of what we must not do: a GUI class containing a lot of complex logic.

Could you please see if you can extract the correlation logic outside of this class into a new one in the data.gpx package, and add unit tests for it (at least for the code you add)?

Because of the JSpinners in the JCheckboxes, I had to split up the strings. Any idea how to handle that for translation? Use trc and copy the other half in the context? Or use a sign inside the string to split it up after translation?

Good question. Dirk what do you think?

And it might be a good idea to split up the CorrelateGpxWithImages.java, I left it in one file for the time being to keep the patch smaller.

So we have the same feeling :) I'm OK with a bigger patch if it comes with tests ;)

This is the advanced options dialog with the default settings at the moment:

When exactly is it displayed?

comment:2 by Don-vip, 6 years ago

Cc: stoecker added

in reply to:  1 comment:3 by stoecker, 6 years ago

Because of the JSpinners in the JCheckboxes, I had to split up the strings. Any idea how to handle that for translation? Use trc and copy the other half in the context? Or use a sign inside the string to split it up after translation?

Good question. Dirk what do you think?

You simply can't do it this way. While this is fine for English it wont work for a number of other languages. Stick to single texts. Either replace the value by X in the strings or set units in brackets or similar solutions. This in-text-style is untranslatable.

text....: checkbox

in reply to:  1 ; comment:4 by Bjoeni, 6 years ago

Replying to stoecker:

Because of the JSpinners in the JCheckboxes, I had to split up the strings. Any idea how to handle that for translation? Use trc and copy the other half in the context? Or use a sign inside the string to split it up after translation?

Good question. Dirk what do you think?

You simply can't do it this way. While this is fine for English it wont work for a number of other languages. Stick to single texts. Either replace the value by X in the strings or set units in brackets or similar solutions. This in-text-style is untranslatable.

text....: checkbox

That's why I suggested splitting the text on a sign. E.g. the translatable text would then be 'only when the tracks are less than # meters apart', the German translation 'nur wenn die Tracks weniger als # Meter auseinander liegen' and the Spinner will be where the # is (after translation). And it can obviously be at the end, if required by that language. Imo it looks better in any language I speak, but you're the boss ;)

Replying to Don-vip:

Could you please see if you can extract the correlation logic outside of this class into a new one in the data.gpx package, and add unit tests for it (at least for the code you add)?

Yes, I can do that. I'm just trying to figure out the handling of the configuration in the unit tests. Can I just put settings during the test without any side effects, and otherwise the defaults will be used?

This is the advanced options dialog with the default settings at the moment:

When exactly is it displayed?

When the 'Advanced settings' button in the correlation dialog is pressed:

(I can move that button somewhere else, I just put it in a free spot in the dialog. Oh, and I just noticed that the ... probably doesn't make sense there - not sure if you guys have design guidelines for that)

by Bjoeni, 6 years ago

Attachment: CorrelateDialog.png added

in reply to:  4 comment:5 by stoecker, 6 years ago

Replying to Bjoeni:

You simply can't do it this way. While this is fine for English it wont work for a number of other languages. Stick to single texts. Either replace the value by X in the strings or set units in brackets or similar solutions. This in-text-style is untranslatable.

text....: checkbox

That's why I suggested splitting the text on a sign. E.g. the translatable text would then be 'only when the tracks are less than # meters apart', the German translation 'nur wenn die Tracks weniger als # Meter auseinander liegen' and the Spinner will be where the # is (after translation). And it can obviously be at the end, if required by that language. Imo it looks better in any language I speak, but you're the boss ;)

That's the typical answer of most programmers new to i18n. But there are languages where the sentence depends a lot on the value you have (even for English and German it does, but no so much). For them it simply never looks good, because you can't change the text based on the value for variable values. To do so would need to much work. And I'm pretty sure we can find a language where even that would not help (e.g. moving box positions depending on the value :-)

Perfect are language aware interfaces, where you can do things like proposed. As this is not manageable for a tool like JOSM we stick to the second best solution even if the result may not be as fancy: Translatable texts.

comment:6 by Bjoeni, 6 years ago

I thought that these languages could just put the sign at the end, so that languages where it's more fancy can use it somewhere in the middle, and languages where it doesn't really work restore the usual bahaviour. So basically the closest you can get to language aware interfaces ;)

But tbh I don't really care too much about that... Could you maybe propose a sentence that I could use (in English)?

comment:7 by Bjoeni, 6 years ago

Description: modified (diff)

in reply to:  1 ; comment:8 by Bjoeni, 6 years ago

Description: modified (diff)

Replying to Don-vip:

Could you please see if you can extract the correlation logic outside of this class into a new one in the data.gpx package, and add unit tests for it (at least for the code you add)?

Done. I didn't implement unit tests for segments specifically, because the logic is absolutely similar to the tracks. I can add them if required.

I can change the labels if somebody suggests a string that makes somewhat sense. For the time being it is still tr("only when the segments are less than # minutes apart").split("#"); and similar

And do I have to add the new unit test test/unit/org/openstreetmap/josm/data/gpx/GpxImageCorrelationTest.java to an index somewhere?

by Bjoeni, 6 years ago

Attachment: GPXCorrelateV2.patch added

comment:9 by Bjoeni, 6 years ago

Description: modified (diff)

in reply to:  8 comment:10 by Don-vip, 6 years ago

Replying to Bjoeni:

do I have to add the new unit test test/unit/org/openstreetmap/josm/data/gpx/GpxImageCorrelationTest.java to an index somewhere?

No. The tests only need to end with "Test.java" for unit tests, and "TestIT.java" for integration tests (those calling Taginfo and so on), see call-junit macro in build.xml:

<batchtest fork="yes" todir="${test.dir}/report">
    <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test@{testITsuffix}.class"/>
</batchtest>

comment:11 by Bjoeni, 6 years ago

Ah ok, that makes sense. I even had a quick look at the build.xml but didn't see it. Thanks.

Btw I just noticed that there were issues with the new timezone parser (one of which I would have noticed if I had run the according unit test...). Fixed that and added a test for parsing negative values (the one that wasn't caught by the TimezoneTest)

by Bjoeni, 6 years ago

Attachment: GPXCorrelateV3.patch added

comment:12 by Don-vip, 6 years ago

Awesome, thank you!

comment:13 by Don-vip, 6 years ago

@Dirk, a suggestion for proper translatable strings?

comment:14 by stoecker, 6 years ago

I'd leave the texts like they are: "only when the segments are less than # minutes apart", simply keep them as they are including the hash sign, maybe adding a ":" behind and then the value-box.

P.S. JOSM base is AE not BE, so use meters instead of metres.

comment:15 by Don-vip, 6 years ago

Resolution: fixed
Status: newclosed

In 14205/josm:

fix #16681 - Various enhancements for GPX correlation (patch by Bjoeni, modified)

comment:16 by Don-vip, 6 years ago

In 14209/josm:

see #16681 - spotbugs / pmd

comment:17 by Don-vip, 6 years ago

In 14210/josm:

see #16681 - sonarqube - squid:HiddenFieldCheck

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.