Changeset 31359 in osm for applications/editors/josm
- Timestamp:
- 2015-07-09T16:09:25+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31355 r31359 204 204 SimpleDateFormat formatter = new SimpleDateFormat(format); 205 205 try { 206 Date dateTime = (Date)formatter.parse(date);206 Date dateTime = formatter.parse(date); 207 207 return dateTime.getTime(); 208 208 } catch (ParseException e) { … … 224 224 /** 225 225 * Sets the MapillarySequence object which contains the MapillaryImage. 226 * 226 * 227 227 * @param sequence 228 228 * The MapillarySequence that contains the MapillaryImage. … … 234 234 /** 235 235 * Returns the sequence which contains this image. 236 * 236 * 237 237 * @return The MapillarySequence object that contains this MapillaryImage. 238 238 */ … … 244 244 * If the MapillaryImage belongs to a MapillarySequence, returns the next 245 245 * MapillarySequence in it. 246 * 246 * 247 247 * @return The following MapillaryImage, or null if there is none. 248 248 */ … … 258 258 * If the MapillaryImage belongs to a MapillarySequence, returns the previous 259 259 * MapillarySequence in it. 260 * 260 * 261 261 * @return The previous MapillaryImage, or null if there is none. 262 262 */ -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31355 r31359 89 89 } 90 90 91 @Override 91 92 public String toString() { 92 93 return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon=" + this.latLon.lon() + ";ca=" + this.ca + "]"; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31357 r31359 109 109 double lonValue = 0; 110 110 double caValue = 0; 111 if (lat != null && lat.getValue() instanceof RationalNumber[])112 latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString());113 if (lon != null && lon.getValue() instanceof RationalNumber[])114 lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString());111 if (lat.getValue() instanceof RationalNumber[]) 112 latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString()); 113 if (lon.getValue() instanceof RationalNumber[]) 114 lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString()); 115 115 if (ca != null && ca.getValue() instanceof RationalNumber) 116 116 caValue = ((RationalNumber) ca.getValue()).doubleValue(); 117 if (lat_ref.getValue().toString().equals("S"))118 latValue = -latValue;119 if (lon_ref.getValue().toString().equals("W"))120 lonValue = -lonValue;121 117 if (datetimeOriginal != null) 122 MapillaryData.getInstance() .add(123 new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue()));118 MapillaryData.getInstance() 119 .add(new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue())); 124 120 else 125 121 MapillaryData.getInstance().add(new MapillaryImportedImage(latValue, lonValue, caValue, file)); … … 149 145 } 150 146 151 public static double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) { 152 RationalNumber deg = degMinSec[0]; 153 RationalNumber min = degMinSec[1]; 154 RationalNumber sec = degMinSec[2]; 155 return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue() / 3600; 147 /** 148 * Calculates the decimal degree-value from a degree value given in degrees-minutes-seconds-format 149 * 150 * @param degMinSec an array of length 3, the values in there are (in this order) degrees, minutes and seconds 151 * @param ref the latitude or longitude reference determining if the given value is: 152 * <ul> 153 * <li>north ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or 154 * south ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of the equator</li> 155 * <li>east ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or 156 * west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST}) of the equator</li> 157 * </ul> 158 * @return the decimal degree-value for the given input, negative when west of 0-meridian or south of equator, 159 * positive otherwise 160 * @throws IllegalArgumentException if {@code degMinSec} doesn't have length 3 or if {@code ref} is not one of the 161 * values mentioned above 162 */ // TODO: Maybe move into a separate utility class? 163 public static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) { 164 if (degMinSec == null || degMinSec.length != 3) { throw new IllegalArgumentException(); } 165 switch (ref) { 166 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH: 167 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH: 168 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST: 169 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST: 170 break; 171 default: 172 throw new IllegalArgumentException(); 173 } 174 175 double result = degMinSec[0].doubleValue(); // degrees 176 result += degMinSec[1].doubleValue() / 60; // minutes 177 result += degMinSec[2].doubleValue() / 3600; // seconds 178 179 if (ref == GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH 180 || ref == GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST) { 181 result *= -1; 182 } 183 184 return result; 156 185 } 157 186 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31355 r31359 104 104 double lonValue = 0; 105 105 double caValue = 0; 106 if (lat != null && lat.getValue() instanceof RationalNumber[]) 107 latValue = MapillaryImportAction.DegMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue() 108 .toString()); 109 if (lon != null && lon.getValue() instanceof RationalNumber[]) 110 lonValue = MapillaryImportAction.DegMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue() 111 .toString()); 106 if (lat.getValue() instanceof RationalNumber[]) 107 latValue = MapillaryImportAction.degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString()); 108 if (lon.getValue() instanceof RationalNumber[]) 109 lonValue = MapillaryImportAction.degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString()); 112 110 if (ca != null && ca.getValue() instanceof RationalNumber) 113 111 caValue = ((RationalNumber) ca.getValue()).doubleValue(); 114 if (lat_ref.getValue().toString().equals("S"))115 latValue = -latValue;116 if (lon_ref.getValue().toString().equals("W"))117 lonValue = -lonValue;118 112 119 113 MapillaryImportedImage image = new MapillaryImportedImage(latValue, lonValue, caValue, file,
Note:
See TracChangeset
for help on using the changeset viewer.