Package org.openstreetmap.josm.data.gpx
Class GpxImageEntry
- java.lang.Object
-
- org.openstreetmap.josm.data.gpx.GpxImageEntry
-
- All Implemented Interfaces:
Comparable<GpxImageEntry>
,IQuadBucketType
- Direct Known Subclasses:
ImageEntry
public class GpxImageEntry extends Object implements Comparable<GpxImageEntry>, IQuadBucketType
Stores info about each image- Since:
- 14205 (extracted from gui.layer.geoimage.ImageEntry)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GpxImageEntry.NoMetadataReaderWarning
-
Field Summary
Fields Modifier and Type Field Description private Projections
cameraProjection
private Double
elevation
Elevation (altitude) in metersprivate LatLon
exifCoor
private Instant
exifGpsTime
Temporary source of GPS time if not correlated with GPX track.private Double
exifImgDir
private Integer
exifOrientation
private Instant
exifTime
private File
file
private Instant
gpsTime
The time after correlation with a gpx trackprivate int
height
private String
iptcCaption
private String
iptcHeadline
private List<String>
iptcKeywords
private String
iptcObjectName
private boolean
isNewGpsData
Flag isNewGpsData indicates that the GPS data of the image is new or has changed.private CachedLatLon
pos
The following values are computed from the correlation with the gpx track or extracted from the image EXIF data.private Double
speed
Speed in kilometer per hourprivate GpxImageEntry
tmp
When the correlation dialog is open, we like to show the image position for the current time offset on the map in real time.private int
width
-
Constructor Summary
Constructors Constructor Description GpxImageEntry()
Constructs a newGpxImageEntry
.GpxImageEntry(File file)
Constructs a newGpxImageEntry
.GpxImageEntry(GpxImageEntry other)
Constructs a newGpxImageEntry
from an existing instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
applyTmp()
Copy the values from the temporary variable to the main instance.WayPoint
asWayPoint()
Returns aWayPoint
representation of this GPX image entry.int
compareTo(GpxImageEntry image)
GpxImageEntry
createTmp()
Make a fresh copy and save it in the temporary variable.void
discardTmp()
Delete the temporary variable.boolean
equals(Object obj)
void
extractExif()
Extract GPS metadata from image EXIF.void
flagNewGpsData()
Indicates that the image has new GPS data.BBox
getBBox()
Fetches the bounding box of the primitive.private static Date
getDefensiveDate(Instant date)
String
getDisplayName()
Returns a display name for this entryDouble
getElevation()
Returns the elevation value.LatLon
getExifCoor()
Instant
getExifGpsInstant()
Returns the EXIF GPS time.Date
getExifGpsTime()
Deprecated.Double
getExifImgDir()
Instant
getExifInstant()
Returns EXIF timeInteger
getExifOrientation()
Returns EXIF orientationFile
getFile()
Returns associated file.Instant
getGpsInstant()
Returns the GPS time value.Date
getGpsTime()
Deprecated.UsegetGpsInstant()
int
getHeight()
Returns height of the image this GpxImageEntry represents.String
getIptcCaption()
Returns the IPTC caption.String
getIptcHeadline()
Returns the IPTC headline.List<String>
getIptcKeywords()
Returns the IPTC keywords.String
getIptcObjectName()
Returns the IPTC object name.CachedLatLon
getPos()
Returns the position value.Projections
getProjectionType()
Get the projection type for this entryDouble
getSpeed()
Returns the speed value.GpxImageEntry
getTmp()
Get temporary variable that is used for real time parameter adjustments.int
getWidth()
Returns width of the image this GpxImageEntry represents.boolean
hasExifGpsTime()
Convenient way to determine if this entry has a EXIF GPS time, without the cost of building a defensive copy.boolean
hasExifTime()
Convenient way to determine if this entry has a EXIF time, without the cost of building a defensive copy.boolean
hasGpsTime()
Convenient way to determine if this entry has a GPS time, without the cost of building a defensive copy.int
hashCode()
boolean
hasNewGpsData()
Queries whether the GPS data changed.private static <T> void
ifNotNull(T value, Consumer<T> setter)
boolean
isTagged()
If it has been tagged i.e.BufferedImage
read(Dimension target)
Reads the image represented by this entry in the given target dimension.void
setElevation(Double elevation)
Sets the elevation.void
setExifCoor(LatLon exifCoor)
void
setExifGpsTime(Instant exifGpsTime)
Sets the EXIF GPS time.void
setExifImgDir(Double exifDir)
void
setExifOrientation(Integer exifOrientation)
Sets EXIF orientation.void
setExifTime(Instant exifTime)
Sets EXIF time.void
setFile(File file)
Sets associated file.void
setGpsTime(Instant gpsTime)
Sets the GPS time.void
setHeight(int height)
Sets the height of this GpxImageEntry.void
setIptcCaption(String iptcCaption)
Sets the IPTC caption.void
setIptcHeadline(String iptcHeadline)
Sets the IPTC headline.void
setIptcKeywords(List<String> iptcKeywords)
Sets the IPTC keywords.void
setIptcObjectName(String iptcObjectName)
Sets the IPTC object name.void
setPos(CachedLatLon pos)
Sets the position.void
setPos(LatLon pos)
Sets the position.void
setSpeed(Double speed)
Sets the speed.void
setWidth(int width)
Sets the width of this GpxImageEntry.protected void
tmpUpdated()
Indicate that the temporary copy has been updated.String
toString()
String representation.void
unflagNewGpsData()
Remove the flag that indicates new GPS data.
-
-
-
Field Detail
-
exifOrientation
private Integer exifOrientation
-
exifImgDir
private Double exifImgDir
-
cameraProjection
private Projections cameraProjection
-
isNewGpsData
private boolean isNewGpsData
Flag isNewGpsData indicates that the GPS data of the image is new or has changed. GPS data includes the position, speed, elevation, time (e.g. as extracted from the GPS track). The flag can used to decide for which image file the EXIF GPS data is (re-)written.
-
exifGpsTime
private Instant exifGpsTime
Temporary source of GPS time if not correlated with GPX track.
-
iptcCaption
private String iptcCaption
-
iptcHeadline
private String iptcHeadline
-
iptcKeywords
private List<String> iptcKeywords
-
iptcObjectName
private String iptcObjectName
-
pos
private CachedLatLon pos
The following values are computed from the correlation with the gpx track or extracted from the image EXIF data.
-
width
private int width
-
height
private int height
-
tmp
private GpxImageEntry tmp
When the correlation dialog is open, we like to show the image position for the current time offset on the map in real time. On the other hand, when the user aborts this operation, the old values should be restored. We have a temporary copy, that overrides the normal values if it is not null. (This may be not the most elegant solution for this, but it works.)
-
-
Constructor Detail
-
GpxImageEntry
public GpxImageEntry()
Constructs a newGpxImageEntry
.
-
GpxImageEntry
public GpxImageEntry(GpxImageEntry other)
Constructs a newGpxImageEntry
from an existing instance.- Parameters:
other
- existing instance- Since:
- 14624
-
GpxImageEntry
public GpxImageEntry(File file)
Constructs a newGpxImageEntry
.- Parameters:
file
- Path to image file on disk
-
-
Method Detail
-
getWidth
public int getWidth()
Returns width of the image this GpxImageEntry represents.- Returns:
- width of the image this GpxImageEntry represents
- Since:
- 13220
-
getHeight
public int getHeight()
Returns height of the image this GpxImageEntry represents.- Returns:
- height of the image this GpxImageEntry represents
- Since:
- 13220
-
getPos
public CachedLatLon getPos()
Returns the position value. The position value from the temporary copy is returned if that copy exists.- Returns:
- the position value
-
getSpeed
public Double getSpeed()
Returns the speed value. The speed value from the temporary copy is returned if that copy exists.- Returns:
- the speed value
-
getElevation
public Double getElevation()
Returns the elevation value. The elevation value from the temporary copy is returned if that copy exists.- Returns:
- the elevation value
-
getGpsTime
@Deprecated public Date getGpsTime()
Deprecated.UsegetGpsInstant()
Returns the GPS time value. The GPS time value from the temporary copy is returned if that copy exists.- Returns:
- the GPS time value
-
getGpsInstant
public Instant getGpsInstant()
Returns the GPS time value. The GPS time value from the temporary copy is returned if that copy exists.- Returns:
- the GPS time value
-
hasGpsTime
public boolean hasGpsTime()
Convenient way to determine if this entry has a GPS time, without the cost of building a defensive copy.- Returns:
true
if this entry has a GPS time- Since:
- 6450
-
getDisplayName
public String getDisplayName()
Returns a display name for this entry- Returns:
- a display name for this entry
-
getExifOrientation
public Integer getExifOrientation()
Returns EXIF orientation- Returns:
- EXIF orientation
-
getExifInstant
public Instant getExifInstant()
Returns EXIF time- Returns:
- EXIF time
- Since:
- 17715
-
hasExifTime
public boolean hasExifTime()
Convenient way to determine if this entry has a EXIF time, without the cost of building a defensive copy.- Returns:
true
if this entry has a EXIF time- Since:
- 6450
-
getExifGpsTime
@Deprecated public Date getExifGpsTime()
Deprecated.Returns the EXIF GPS time.- Returns:
- the EXIF GPS time
- Since:
- 6392
-
getExifGpsInstant
public Instant getExifGpsInstant()
Returns the EXIF GPS time.- Returns:
- the EXIF GPS time
- Since:
- 17715
-
hasExifGpsTime
public boolean hasExifGpsTime()
Convenient way to determine if this entry has a EXIF GPS time, without the cost of building a defensive copy.- Returns:
true
if this entry has a EXIF GPS time- Since:
- 6450
-
getDefensiveDate
private static Date getDefensiveDate(Instant date)
-
getExifCoor
public LatLon getExifCoor()
-
getExifImgDir
public Double getExifImgDir()
-
setWidth
public void setWidth(int width)
Sets the width of this GpxImageEntry.- Parameters:
width
- set the width of this GpxImageEntry- Since:
- 13220
-
setHeight
public void setHeight(int height)
Sets the height of this GpxImageEntry.- Parameters:
height
- set the height of this GpxImageEntry- Since:
- 13220
-
setPos
public void setPos(CachedLatLon pos)
Sets the position.- Parameters:
pos
- cached position
-
setPos
public void setPos(LatLon pos)
Sets the position.- Parameters:
pos
- position (will be cached)
-
setElevation
public void setElevation(Double elevation)
Sets the elevation.- Parameters:
elevation
- elevation
-
setExifOrientation
public void setExifOrientation(Integer exifOrientation)
Sets EXIF orientation.- Parameters:
exifOrientation
- EXIF orientation
-
setExifTime
public void setExifTime(Instant exifTime)
Sets EXIF time.- Parameters:
exifTime
- EXIF time- Since:
- 17715
-
setExifGpsTime
public void setExifGpsTime(Instant exifGpsTime)
Sets the EXIF GPS time.- Parameters:
exifGpsTime
- the EXIF GPS time- Since:
- 17715
-
setGpsTime
public void setGpsTime(Instant gpsTime)
Sets the GPS time.- Parameters:
gpsTime
- the GPS time- Since:
- 17715
-
setExifCoor
public void setExifCoor(LatLon exifCoor)
-
setExifImgDir
public void setExifImgDir(Double exifDir)
-
setIptcCaption
public void setIptcCaption(String iptcCaption)
Sets the IPTC caption.- Parameters:
iptcCaption
- the IPTC caption- Since:
- 15219
-
setIptcHeadline
public void setIptcHeadline(String iptcHeadline)
Sets the IPTC headline.- Parameters:
iptcHeadline
- the IPTC headline- Since:
- 15219
-
setIptcKeywords
public void setIptcKeywords(List<String> iptcKeywords)
Sets the IPTC keywords.- Parameters:
iptcKeywords
- the IPTC keywords- Since:
- 15219
-
setIptcObjectName
public void setIptcObjectName(String iptcObjectName)
Sets the IPTC object name.- Parameters:
iptcObjectName
- the IPTC object name- Since:
- 15219
-
getIptcCaption
public String getIptcCaption()
Returns the IPTC caption.- Returns:
- the IPTC caption
- Since:
- 15219
-
getIptcHeadline
public String getIptcHeadline()
Returns the IPTC headline.- Returns:
- the IPTC headline
- Since:
- 15219
-
getIptcKeywords
public List<String> getIptcKeywords()
Returns the IPTC keywords.- Returns:
- the IPTC keywords
- Since:
- 15219
-
getIptcObjectName
public String getIptcObjectName()
Returns the IPTC object name.- Returns:
- the IPTC object name
- Since:
- 15219
-
compareTo
public int compareTo(GpxImageEntry image)
- Specified by:
compareTo
in interfaceComparable<GpxImageEntry>
-
createTmp
public GpxImageEntry createTmp()
Make a fresh copy and save it in the temporary variable. UseapplyTmp()
ordiscardTmp()
if the temporary variable is not needed anymore.- Returns:
- the fresh copy.
-
getTmp
public GpxImageEntry getTmp()
Get temporary variable that is used for real time parameter adjustments. The temporary variable is created if it does not exist yet. UseapplyTmp()
ordiscardTmp()
if the temporary variable is not needed anymore.- Returns:
- temporary variable
-
applyTmp
public void applyTmp()
Copy the values from the temporary variable to the main instance. The temporary variable is deleted.- See Also:
discardTmp()
-
discardTmp
public void discardTmp()
Delete the temporary variable. Temporary modifications are lost.- See Also:
applyTmp()
-
isTagged
public boolean isTagged()
If it has been tagged i.e. matched to a gpx track or retrieved lat/lon from exif- Returns:
true
if it has been tagged
-
flagNewGpsData
public void flagNewGpsData()
Indicates that the image has new GPS data. That flag is set by new GPS data providers. It is used e.g. by the photo_geotagging plugin to decide for which image file the EXIF GPS data needs to be (re-)written.- Since:
- 6392
-
tmpUpdated
protected void tmpUpdated()
Indicate that the temporary copy has been updated. Mostly used to prevent UI issues. By default, this is a no-op. Override when needed in subclasses.- Since:
- 17579
-
getBBox
public BBox getBBox()
Description copied from interface:IQuadBucketType
Fetches the bounding box of the primitive.- Specified by:
getBBox
in interfaceIQuadBucketType
- Returns:
- Bounding box of the object
-
unflagNewGpsData
public void unflagNewGpsData()
Remove the flag that indicates new GPS data. The flag is cleared by a new GPS data consumer.
-
hasNewGpsData
public boolean hasNewGpsData()
Queries whether the GPS data changed. The flag value from the temporary copy is returned if that copy exists.- Returns:
true
if GPS data changed,false
otherwise- Since:
- 6392
-
extractExif
public void extractExif()
Extract GPS metadata from image EXIF. Has no effect if the image file is not set If successful, fills in the LatLon, speed, elevation, image direction, and other attributes- Since:
- 9270
-
read
public BufferedImage read(Dimension target) throws IOException
Reads the image represented by this entry in the given target dimension.- Parameters:
target
- the desired dimension used for subsampling ornull
- Returns:
- the read image, or
null
- Throws:
IOException
- if any I/O error occurs- Since:
- 18246
-
getProjectionType
public Projections getProjectionType()
Get the projection type for this entry- Returns:
- The projection type
- Since:
- 18246
-
asWayPoint
public WayPoint asWayPoint()
Returns aWayPoint
representation of this GPX image entry.- Returns:
- a
WayPoint
representation of this GPX image entry (containing position, instant and elevation) - Since:
- 18065
-
-