Changeset 36333 in osm for applications/editors


Ignore:
Timestamp:
2024-09-05T15:51:01+02:00 (4 months ago)
Author:
taylor.smock
Message:

Fix #23239: NPE when attempting to set a position of an image without a position already set

This will occur when attempting to position images when the image has no exif
location information.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java

    r36188 r36333  
    1010import org.openstreetmap.josm.data.coor.ILatLon;
    1111import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.data.projection.Projection;
    1213import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1314import org.openstreetmap.josm.gui.MainApplication;
     
    166167            } else {
    167168                disableCenterView();
     169                final Projection proj = ProjectionRegistry.getProjection();
     170                if (dragPhoto.getPos() == null) {
     171                    // Set a false location -- the image most likely has no position
     172                    // So we use a location in the middle of the projection bounds to ensure that everything works.
     173                    dragPhoto.setPos(proj.getWorldBoundsLatLon().getCenter());
     174                }
    168175                final EastNorth startEN = dragPhoto.getPos().getEastNorth(ProjectionRegistry.getProjection()).subtract(dragOffset);
    169176                final EastNorth currentEN = MainApplication.getMap().mapView.getEastNorth(evt.getX(), evt.getY());
Note: See TracChangeset for help on using the changeset viewer.