001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.gpx;
003
004import java.util.Objects;
005
006/**
007 * Correlation settings used by {@link GpxImageCorrelation}.
008 * @since 18061
009 */
010public class GpxImageCorrelationSettings {
011
012    private final long offset;
013    private final boolean forceTags;
014    private final TimeSource imgTimeSource;
015    private final GpxImageDirectionPositionSettings directionPositionSettings;
016    private final GpxImageDatumSettings datumSettings;
017
018    /**
019     * Constructs a new {@code GpxImageCorrelationSettings}.
020     * @param offset offset in milliseconds
021     * @param forceTags force tagging of all photos, otherwise prefs are used
022     */
023    public GpxImageCorrelationSettings(long offset, boolean forceTags) {
024        this(offset, forceTags, TimeSource.EXIFCAMTIME,
025        new GpxImageDirectionPositionSettings(false, 0, false, 0, 0, 0),
026        new GpxImageDatumSettings(false, null)
027        );
028    }
029
030    /**
031     * Constructs a new {@code GpxImageCorrelationSettings}.
032     * @param offset offset in milliseconds
033     * @param forceTags force tagging of all photos, otherwise prefs are used
034     * @param imgTimeSource select image clock source: 
035     *                      "exifCamTime" for camera internal clock
036     *                      "exifGpsTime for the GPS clock of the camera
037     * @param directionPositionSettings direction/position settings
038     * @since 19426 @imgTimeSource was added
039     */
040    public GpxImageCorrelationSettings(long offset, boolean forceTags, TimeSource imgTimeSource,
041            GpxImageDirectionPositionSettings directionPositionSettings) {
042        this(offset, forceTags, imgTimeSource, directionPositionSettings,
043        new GpxImageDatumSettings(false, null));
044    }
045
046    /**
047     * Constructs a new {@code GpxImageCorrelationSettings}.
048     * @param offset offset in milliseconds
049     * @param forceTags force tagging of all photos, otherwise prefs are used
050     * @param imgTimeSource select image clock source: 
051     *                      "exifCamTime" for camera internal clock
052     *                      "exifGpsTime for the GPS clock of the camera
053     * @param directionPositionSettings direction/position settings
054     * @param datumSettings GPS datum settings
055     * @since 19387 @datumSettings was added
056     * @since 19426 @imgTimeSource was added
057     */
058    public GpxImageCorrelationSettings(long offset, boolean forceTags, TimeSource imgTimeSource,
059            GpxImageDirectionPositionSettings directionPositionSettings,
060            GpxImageDatumSettings datumSettings) {
061        this.offset = offset;
062        this.forceTags = forceTags;
063        this.imgTimeSource = imgTimeSource;
064        this.directionPositionSettings = Objects.requireNonNull(directionPositionSettings);
065        this.datumSettings = Objects.requireNonNull(datumSettings);
066    }
067    
068    /**
069     * Returns the offset in milliseconds.
070     * @return the offset in milliseconds
071     */
072    public long getOffset() {
073        return offset;
074    }
075
076    /**
077     * Determines if tagging of all photos must be forced, otherwise prefs are used
078     * @return {@code true} if tagging of all photos must be forced, otherwise prefs are used
079     */
080    public boolean isForceTags() {
081        return forceTags;
082    }
083
084    /**
085     * Return the selected image clock source, which is camera internal time, or GPS time
086     * @return the clock source
087     * @since 19426
088     */
089    public TimeSource getImgTimeSource() {
090        return imgTimeSource;
091    }
092
093    /**
094     * Returns the direction/position settings.
095     * @return the direction/position settings
096     */
097    public GpxImageDirectionPositionSettings getDirectionPositionSettings() {
098        return directionPositionSettings;
099    }
100
101    /**
102     * Returns the EXIF metadata datum settings.
103     * @return the EXIF metadata datum settings
104     * @since 19387
105     */
106    public GpxImageDatumSettings getDatumSettings() {
107        return datumSettings;
108    }
109
110    @Override
111    public String toString() {
112        return "[offset=" + offset + ", forceTags=" + forceTags
113                + ", clock source=" + imgTimeSource
114                + ", directionPositionSettings=" + directionPositionSettings
115                + ", datumSettings=" + datumSettings + ']';
116    }
117}