Changeset 5346 in josm for trunk/src/org
- Timestamp:
- 2012-07-17T09:34:34+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java
r4602 r5346 15 15 */ 16 16 public class HistoryNode extends HistoryOsmPrimitive { 17 /** the coordinates */17 /** the coordinates. May be null for deleted nodes */ 18 18 19 19 private LatLon coords; -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r5328 r5346 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.data.coor.CoordinateFormat; 21 import org.openstreetmap.josm.data.coor.LatLon; 21 22 import org.openstreetmap.josm.data.osm.Changeset; 22 23 import org.openstreetmap.josm.data.osm.IPrimitive; … … 556 557 sb.append(name); 557 558 } 558 sb.append(" (") 559 .append(node.getCoords().latToString(CoordinateFormat.getDefaultFormat())) 560 .append(", ") 561 .append(node.getCoords().lonToString(CoordinateFormat.getDefaultFormat())) 562 .append(")"); 559 LatLon coord = node.getCoords(); 560 if (coord != null) { 561 sb.append(" (") 562 .append(coord.latToString(CoordinateFormat.getDefaultFormat())) 563 .append(", ") 564 .append(coord.lonToString(CoordinateFormat.getDefaultFormat())) 565 .append(")"); 566 } 563 567 decorateNameWithId(sb, node); 564 568 return sb.toString(); -
trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java
r5266 r5346 15 15 16 16 import org.openstreetmap.josm.data.coor.CoordinateFormat; 17 import org.openstreetmap.josm.data.coor.LatLon; 17 18 import org.openstreetmap.josm.data.osm.history.HistoryNode; 18 19 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; … … 256 257 HistoryNode oppositeNode = (HistoryNode) opposite; 257 258 259 LatLon coord = node.getCoords(); 260 LatLon oppositeCoord = oppositeNode.getCoords(); 261 258 262 // display the coordinates 259 263 // 260 lblLat.setText( node.getCoords().latToString(CoordinateFormat.DECIMAL_DEGREES));261 lblLon.setText( node.getCoords().lonToString(CoordinateFormat.DECIMAL_DEGREES));264 lblLat.setText(coord != null ? coord.latToString(CoordinateFormat.DECIMAL_DEGREES) : tr("Deleted")); 265 lblLon.setText(coord != null ? coord.lonToString(CoordinateFormat.DECIMAL_DEGREES) : tr("Deleted")); 262 266 263 267 // update background color to reflect differences in the coordinates 264 268 // 265 if (node.getCoords().lat() == oppositeNode.getCoords().lat()) { 269 if (coord == oppositeCoord || 270 (coord != null && oppositeCoord != null && coord.lat() == oppositeCoord.lat())) { 266 271 lblLat.setBackground(Color.WHITE); 267 272 } else { 268 273 lblLat.setBackground(BGCOLOR_DIFFERENCE); 269 274 } 270 if (node.getCoords().lon() == oppositeNode.getCoords().lon()) { 275 if (coord == oppositeCoord || 276 (coord != null && oppositeCoord != null && coord.lon() == oppositeCoord.lon())) { 271 277 lblLon.setBackground(Color.WHITE); 272 278 } else { 273 279 lblLon.setBackground(BGCOLOR_DIFFERENCE); 274 280 } 275 276 281 } 277 282 … … 322 327 HistoryNode oppositeNode = (HistoryNode) opposite; 323 328 329 LatLon coord = node.getCoords(); 330 LatLon oppositeCoord = oppositeNode.getCoords(); 331 324 332 // update distance 325 333 // 326 double distance = node.getCoords().greatCircleDistance(oppositeNode.getCoords()); 327 if (distance > 0) { 328 lblDistance.setBackground(BGCOLOR_DIFFERENCE); 334 if (coord != null && oppositeCoord != null) { 335 double distance = coord.greatCircleDistance(oppositeCoord); 336 if (distance > 0) { 337 lblDistance.setBackground(BGCOLOR_DIFFERENCE); 338 } else { 339 lblDistance.setBackground(Color.WHITE); 340 } 341 lblDistance.setText(NavigatableComponent.getDistText(distance)); 329 342 } else { 330 lblDistance.setBackground(Color.WHITE); 343 lblDistance.setBackground(coord != oppositeCoord ? BGCOLOR_DIFFERENCE : Color.WHITE); 344 lblDistance.setText(tr("Deleted")); 331 345 } 332 lblDistance.setText(NavigatableComponent.getDistText(distance));333 346 } 334 347 } -
trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java
r5266 r5346 44 44 private ChangesetDataSet data; 45 45 46 // FIXME: this class has many similarities with OsmHistoryReader.Parser and should be merged 46 47 private class Parser extends DefaultHandler { 47 48 … … 103 104 } 104 105 105 protected Double get MandatoryAttributeDouble(Attributes attr, String name) throws SAXException{106 protected Double getAttributeDouble(Attributes attr, String name) throws SAXException{ 106 107 String v = attr.getValue(name); 107 108 if (v == null) { 108 throwException(tr("Missing mandatory attribute ''{0}''.", name));109 return null; 109 110 } 110 111 double d = 0.0; … … 112 113 d = Double.parseDouble(v); 113 114 } catch(NumberFormatException e) { 114 throwException(tr("Illegal value for mandatoryattribute ''{0}'' of type double. Got ''{1}''.", name, v));115 throwException(tr("Illegal value for attribute ''{0}'' of type double. Got ''{1}''.", name, v)); 115 116 } 116 117 return d; … … 160 161 HistoryOsmPrimitive primitive = null; 161 162 if (type.equals(OsmPrimitiveType.NODE)) { 162 double lat = getMandatoryAttributeDouble(atts, "lat"); 163 double lon = getMandatoryAttributeDouble(atts, "lon"); 163 Double lat = getAttributeDouble(atts, "lat"); 164 Double lon = getAttributeDouble(atts, "lon"); 165 LatLon coor = (lat != null && lon != null) ? new LatLon(lat,lon) : null; 164 166 primitive = new HistoryNode( 165 id,version,visible,user,changesetId,timestamp, new LatLon(lat,lon)167 id,version,visible,user,changesetId,timestamp,coor 166 168 ); 167 169 -
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r5266 r5346 42 42 private final HistoryDataSet data; 43 43 44 // FIXME: this class has many similarities with OsmChangesetContentParser.Parser and should be merged 44 45 private class Parser extends DefaultHandler { 45 46 … … 99 100 } 100 101 101 protected Double get MandatoryAttributeDouble(Attributes attr, String name) throws SAXException{102 String v = attr.getValue(name); 103 if (v == null) { 104 throwException(tr("Missing mandatory attribute ''{0}''.", name));102 protected Double getAttributeDouble(Attributes attr, String name) throws SAXException{ 103 String v = attr.getValue(name); 104 if (v == null) { 105 return null; 105 106 } 106 107 double d = 0.0; … … 108 109 d = Double.parseDouble(v); 109 110 } catch(NumberFormatException e) { 110 throwException(tr("Illegal value for mandatoryattribute ''{0}'' of type double. Got ''{1}''.", name, v));111 throwException(tr("Illegal value for attribute ''{0}'' of type double. Got ''{1}''.", name, v)); 111 112 } 112 113 return d; … … 154 155 HistoryOsmPrimitive primitive = null; 155 156 if (type.equals(OsmPrimitiveType.NODE)) { 156 double lat = getMandatoryAttributeDouble(atts, "lat"); 157 double lon = getMandatoryAttributeDouble(atts, "lon"); 157 Double lat = getAttributeDouble(atts, "lat"); 158 Double lon = getAttributeDouble(atts, "lon"); 159 LatLon coord = (lat != null && lon != null) ? new LatLon(lat,lon) : null; 158 160 primitive = new HistoryNode( 159 id,version,visible,user,changesetId,timestamp, new LatLon(lat,lon)161 id,version,visible,user,changesetId,timestamp,coord 160 162 ); 161 163
Note:
See TracChangeset
for help on using the changeset viewer.