1 | // License: GPL. See LICENSE file for details.
|
---|
2 | // Copyright 2007 by Christian Gallioz (aka khris78)
|
---|
3 | // Parts of code from Geotagged plugin (by Rob Neild)
|
---|
4 | // and the core JOSM source code (by Immanuel Scholz and others)
|
---|
5 |
|
---|
6 | package org.openstreetmap.josm.gui.layer.geoimage;
|
---|
7 |
|
---|
8 | import java.io.File;
|
---|
9 | import java.util.Date;
|
---|
10 | import java.awt.Image;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.coor.CachedLatLon;
|
---|
13 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
14 |
|
---|
15 | /*
|
---|
16 | * Stores info about each image
|
---|
17 | */
|
---|
18 |
|
---|
19 | final class ImageEntry implements Comparable<ImageEntry>, Cloneable {
|
---|
20 | File file;
|
---|
21 | Date time;
|
---|
22 | LatLon exifCoor;
|
---|
23 |
|
---|
24 | private CachedLatLon pos;
|
---|
25 | /** Speed in kilometer per second */
|
---|
26 | private Double speed;
|
---|
27 | /** Elevation (altitude) in meters */
|
---|
28 | private Double elevation;
|
---|
29 |
|
---|
30 | Image thumbnail;
|
---|
31 |
|
---|
32 | ImageEntry tmp;
|
---|
33 |
|
---|
34 | public CachedLatLon getPos() {
|
---|
35 | if (tmp != null) {
|
---|
36 | return tmp.pos;
|
---|
37 | }
|
---|
38 | return pos;
|
---|
39 | }
|
---|
40 | public Double getSpeed() {
|
---|
41 | if (tmp != null) {
|
---|
42 | return tmp.speed;
|
---|
43 | }
|
---|
44 | return speed;
|
---|
45 | }
|
---|
46 | public Double getElevation() {
|
---|
47 | if (tmp != null) {
|
---|
48 | return tmp.elevation;
|
---|
49 | }
|
---|
50 | return elevation;
|
---|
51 | }
|
---|
52 | public void setPos(CachedLatLon pos) {
|
---|
53 | this.pos = pos;
|
---|
54 | }
|
---|
55 | public void setSpeed(Double speed) {
|
---|
56 | this.speed = speed;
|
---|
57 | }
|
---|
58 | public void setElevation(Double speed) {
|
---|
59 | this.elevation = elevation;
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public ImageEntry clone() {
|
---|
64 | Object c;
|
---|
65 | try {
|
---|
66 | c = super.clone();
|
---|
67 | } catch (CloneNotSupportedException e) {
|
---|
68 | throw new RuntimeException();
|
---|
69 | }
|
---|
70 | return (ImageEntry) c;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public void setCoor(LatLon latlon)
|
---|
74 | {
|
---|
75 | pos = new CachedLatLon(latlon);
|
---|
76 | }
|
---|
77 |
|
---|
78 | public int compareTo(ImageEntry image) {
|
---|
79 | if (time != null && image.time != null)
|
---|
80 | return time.compareTo(image.time);
|
---|
81 | else if (time == null && image.time == null)
|
---|
82 | return 0;
|
---|
83 | else if (time == null)
|
---|
84 | return -1;
|
---|
85 | else
|
---|
86 | return 1;
|
---|
87 | }
|
---|
88 |
|
---|
89 | public void applyTmp() {
|
---|
90 | if (tmp != null) {
|
---|
91 | pos = tmp.pos;
|
---|
92 | speed = tmp.speed;
|
---|
93 | elevation = tmp.elevation;
|
---|
94 | tmp = null;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | public void cleanTmp() {
|
---|
98 | tmp = clone();
|
---|
99 | tmp.setPos(null);
|
---|
100 | tmp.tmp = null;
|
---|
101 | }
|
---|
102 |
|
---|
103 | public boolean isTagged() {
|
---|
104 | return pos != null;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * only partial info
|
---|
109 | */
|
---|
110 | public String toString() {
|
---|
111 | String result = file.getName()+": "+
|
---|
112 | "pos = "+pos+" | "+
|
---|
113 | "exifCoor = "+exifCoor+" | "+
|
---|
114 | (tmp == null ? " tmp==null" :
|
---|
115 | " [tmp] pos = "+tmp.pos+"");
|
---|
116 | return result;
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|