Modify

Opened 11 years ago

Closed 5 years ago

Last modified 5 years ago

#11710 closed enhancement (fixed)

[Patch] Re-geotagging hides pictures that are not covered by gpx track

Reported by: skorbut Owned by: Bjoeni
Priority: normal Milestone: 21.05
Component: Core image mapping Version:
Keywords: Cc:

Description

There is a somewhat special condition where JOSM/the photo geotagging plugin doesn't behave ideally:

  • Load some geotagged images in JOSM
  • Try to correlate those images using a gpx track which only covers some, but not all of the images (use the option 'Override position for images with geo location in exif data', otherwise the images wont be repositioned)
  • Images that were not covered by the gpx track disappear, although they still have the original geotagging.
  • (Writing the coordinates to the files that are covered by the gpx track and reloading all images into JOSM displays everything again in correct fashion. So the situation is not too bad...)

This happened to me in the following situation: I have a camera with an integrated, rather low-quality GPS. To improve the accuracy I also have an external logger whose gpx track is of better quality and that I want to use as a primary source of geotagging. When the battery of the external logger was exhausted, the camera still recorded the (low-quality) position that I would prefer to use if the alternative was to discard the image completely.

Attachments (2)

11710-V2.patch (7.9 KB ) - added by Bjoeni 5 years ago.
11710-V3.patch (22.1 KB ) - added by Bjoeni 5 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 by Don-vip, 8 years ago

Owner: changed from bastiK to team

comment:2 by Bjoeni, 5 years ago

Component: Plugin photo_geotaggingCore image mapping
Owner: changed from team to Bjoeni

comment:3 by Bjoeni, 5 years ago

Summary: Re-geotagging hides pictures that are not covered by gpx track[Patch] Re-geotagging hides pictures that are not covered by gpx track

Prevent removal of geotags from files that weren't matched to the track:

  • src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java

     
    229229                    break;
    230230                }
    231231                long tagms = TimeUnit.MINUTES.toMillis(tagTime);
    232                 if (curTmp.getPos() == null &&
    233                         (Math.abs(time - curWpTime) <= tagms
    234                         || Math.abs(prevWpTime - time) <= tagms)) {
     232                if (Math.abs(time - curWpTime) <= tagms
     233                        || Math.abs(prevWpTime - time) <= tagms) {
    235234                    if (prevWp != null && time < curWpTime - half) {
    236235                        curTmp.setPos(prevWp.getCoor());
    237236                    } else {
     
    255254                if (imgTime < prevWpTime) {
    256255                    break;
    257256                }
    258                 if (curTmp.getPos() == null) {
    259                     // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
    260                     double timeDiff = (double) (imgTime - prevWpTime) / Math.abs(curWpTime - prevWpTime);
    261                     curTmp.setPos(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff));
    262                     curTmp.setSpeed(speed);
    263                     if (curElevation != null && prevElevation != null) {
    264                         curTmp.setElevation(prevElevation + (curElevation - prevElevation) * timeDiff);
    265                     }
    266                     curTmp.setGpsTime(curImg.getExifInstant().minusMillis(offset));
    267                     curTmp.flagNewGpsData();
    268                     curImg.tmpUpdated();
     257                // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
     258                double timeDiff = (double) (imgTime - prevWpTime) / Math.abs(curWpTime - prevWpTime);
     259                curTmp.setPos(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff));
     260                curTmp.setSpeed(speed);
     261                if (curElevation != null && prevElevation != null) {
     262                    curTmp.setElevation(prevElevation + (curElevation - prevElevation) * timeDiff);
     263                }
     264                curTmp.setGpsTime(curImg.getExifInstant().minusMillis(offset));
     265                curTmp.flagNewGpsData();
     266                curImg.tmpUpdated();
    269267
    270                     ret++;
    271                 }
     268                ret++;
    272269                i--;
    273270            }
    274271        }
  • src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

     
    10901090            // Construct a list of images that have a date, and sort them on the date.
    10911091            List<ImageEntry> dateImgLst = getSortedImgList();
    10921092            // Create a temporary copy for each image
    1093             for (ImageEntry ie : dateImgLst) {
    1094                 ie.createTmp();
    1095                 ie.getTmp().setPos(null);
    1096             }
     1093            dateImgLst.forEach(ImageEntry::createTmp);
    10971094
    10981095            GpxDataWrapper selGpx = selectedGPX(false);
    10991096            if (selGpx == null)

See also the changes from #16681 allowing the user to determine what images should be matched.

Version 0, edited 5 years ago by Bjoeni (next)

comment:4 by simon04, 5 years ago

Milestone: 21.05

comment:5 by Bjoeni, 5 years ago

Ticket #11015 has been marked as a duplicate of this ticket.

comment:6 by Bjoeni, 5 years ago

@Simon (or someone else)
could you please commit this patch in the near future? #20795 depends on it (or it would at least conflict, so it's easier when this one is committed before I provide a patch for the other one)

comment:7 by simon04, 5 years ago

This patch breaks the unit test org.openstreetmap.josm.data.gpx.GpxImageCorrelationTest#testMatchGpxTrack

comment:8 by Bjoeni, 5 years ago

That's interesting, I thought I checked that. I'll have a look.

comment:9 by Bjoeni, 5 years ago

Fixed that (note to self: shouldn't change a patch after running the tests...). Sorry about that.

I also added another ImageEntry i7 to testMatchGpxTrack (testing the changes of this ticket).

by Bjoeni, 5 years ago

Attachment: 11710-V2.patch added

comment:10 by Bjoeni, 5 years ago

Btw. I just noticed that checkstyle complains that the testMatchGpxTrack() method is now too long (157 executable statements). I'll change that.

by Bjoeni, 5 years ago

Attachment: 11710-V3.patch added

comment:11 by Bjoeni, 5 years ago

Restructured GpxImageCorrelationTest into separate methods

comment:12 by simon04, 5 years ago

Resolution: fixed
Status: newclosed

In 17878/josm:

fix #11710 - Re-geotagging hides pictures that are not covered by GPX track (patch by Bjoeni)

comment:13 by simon04, 5 years ago

Thank you!

comment:14 by simon04, 5 years ago

In 17882/josm:

see #11710 - Fix MethodOrderer deprecation

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Bjoeni.
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.