Ticket #21523: photoadjust_21523_fix_direction_360.patch

File photoadjust_21523_fix_direction_360.patch, 1.5 KB (added by gillux, 2 months ago)

Patch to fix the issue

  • photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java

    diff --git a/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java b/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java
    index 013a167..ab78cf6 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1515import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    1616import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;
    1717import org.openstreetmap.josm.gui.layer.geoimage.ImageViewerDialog;
     18import org.openstreetmap.josm.gui.util.imagery.Vector3D;
     19import org.openstreetmap.josm.tools.Utils;
    1820
    1921/**
    2022 * Class that does the actual work.
    public class PhotoAdjustWorker {  
    239241            return;
    240242        }
    241243        final LatLon mouseLL = MainApplication.getMap().mapView.getLatLon(evt.getX(), evt.getY());
     244        Vector3D viewerVector = ImageViewerDialog.getInstance().getRotation(photo);
     245        double viewerAngle = viewerVector != null ? Utils.toDegrees(viewerVector.getPolarAngle()) : 0d;
    242246        // The projection doesn't matter here.
    243         double direction = photoLL.bearing(mouseLL) * 360.0 / 2.0 / Math.PI;
     247        double direction = photoLL.bearing(mouseLL) * 360.0 / 2.0 / Math.PI - viewerAngle;
    244248        if (direction < 0.0) {
    245249            direction += 360.0;
    246250        } else if (direction >= 360.0) {