Ignore:
Timestamp:
2013-03-20T08:05:48+01:00 (12 years ago)
Author:
zverik
Message:

some updates to iodb plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java

    r29376 r29377  
    1919public class ImageryOffsetTools {
    2020    public static final String DIALOG_TITLE = tr("Imagery Offset");
    21     public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
    2221   
    2322    public static ImageryLayer getTopImageryLayer() {
     
    4241        Projection proj = Main.getProjection();
    4342        EastNorth offsetCenter = proj.latlon2eastNorth(center);
    44         EastNorth centerOffset = offsetCenter.add(-layer.getDx(), -layer.getDy()); // todo: add or substract?
     43        EastNorth centerOffset = offsetCenter.add(-layer.getDx(), -layer.getDy());
    4544        LatLon offsetLL = proj.eastNorth2latlon(centerOffset);
    4645        return offsetLL;
     
    4847   
    4948    public static void applyLayerOffset( ImageryLayer layer, ImageryOffset offset ) {
     49        double[] dxy = calculateOffset(offset);
     50        layer.setOffset(dxy[0], dxy[1]);
     51    }
     52
     53    /**
     54     * Calculate dx and dy for imagery offset.
     55     * @return [dx, dy]
     56     */
     57    public static double[] calculateOffset( ImageryOffset offset ) {
    5058        Projection proj = Main.getProjection();
    5159        EastNorth center = proj.latlon2eastNorth(offset.getPosition());
    5260        EastNorth offsetPos = proj.latlon2eastNorth(offset.getImageryPos());
    53         layer.setOffset(center.getX() - offsetPos.getX(), center.getY() - offsetPos.getY());
     61        return new double[] { center.getX() - offsetPos.getX(), center.getY() - offsetPos.getY() };
    5462    }
    5563   
Note: See TracChangeset for help on using the changeset viewer.