- Timestamp:
- 2020-01-26T19:45:25+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
r15716 r15777 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.util.Arrays; 7 8 import java.util.List; 9 import java.util.stream.Collectors; 10 import java.util.stream.Stream; 8 11 9 12 import org.openstreetmap.josm.data.conflict.Conflict; 10 import org.openstreetmap.josm.data.coor.EastNorth;11 13 import org.openstreetmap.josm.data.coor.ILatLon; 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.coor.conversion.AbstractCoordinateFormat; 12 16 import org.openstreetmap.josm.data.coor.conversion.DecimalDegreesCoordinateFormat; 17 import org.openstreetmap.josm.data.coor.conversion.ProjectedCoordinateFormat; 13 18 import org.openstreetmap.josm.data.osm.BBox; 14 19 import org.openstreetmap.josm.data.osm.DataSet; … … 168 173 } else if (o instanceof IWay) { 169 174 addBbox(o); 170 add(tr("Centroid: "), 171 toStringCSV(", ", ProjectionRegistry.getProjection().eastNorth2latlon( 172 Geometry.getCentroid(((IWay<?>) o).getNodes())))); 175 add(tr("Centroid: "), toStringCSV(false, 176 ProjectionRegistry.getProjection().eastNorth2latlon(Geometry.getCentroid(((IWay<?>) o).getNodes())))); 173 177 addWayNodes((IWay<?>) o); 174 178 } else if (o instanceof IRelation) { … … 200 204 BBox bbox = o.getBBox(); 201 205 if (bbox != null) { 202 add(tr("Bounding box: "), bbox.toStringCSV(", ")); 203 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth(ProjectionRegistry.getProjection()); 204 EastNorth topLeft = bbox.getTopLeft().getEastNorth(ProjectionRegistry.getProjection()); 205 add(tr("Bounding box (projected): "), 206 Double.toString(topLeft.east()), ", ", 207 Double.toString(bottomRigth.north()), ", ", 208 Double.toString(bottomRigth.east()), ", ", 209 Double.toString(topLeft.north())); 210 add(tr("Center of bounding box: "), toStringCSV(", ", bbox.getCenter())); 206 final LatLon bottomRight = bbox.getBottomRight(); 207 final LatLon topLeft = bbox.getTopLeft(); 208 add(tr("Bounding box: "), toStringCSV(false, bottomRight, topLeft)); 209 add(tr("Bounding box (projected): "), toStringCSV(true, bottomRight, topLeft)); 210 add(tr("Center of bounding box: "), toStringCSV(false, bbox.getCenter())); 211 211 } 212 212 } … … 214 214 void addCoordinates(INode n) { 215 215 if (n.isLatLonKnown()) { 216 add(tr("Coordinates:"), " ", 217 Double.toString(n.lat()), ", ", 218 Double.toString(n.lon())); 219 EastNorth en = n.getEastNorth(); 220 add(tr("Coordinates (projected): "), 221 Double.toString(en.east()), ", ", 222 Double.toString(en.north())); 216 add(tr("Coordinates:"), " ", toStringCSV(false, n)); 217 add(tr("Coordinates (projected): "), toStringCSV(true, n)); 223 218 Pair<Integer, Hemisphere> utmZone = TransverseMercator.locateUtmZone(n.getCoor()); 224 219 String utmLabel = tr("UTM Zone"); … … 248 243 249 244 /** 250 * Returns lat/lon coordinate in human-readable format separated by {@code separator}.251 * @param separator values separator252 * @param ll the lat/lon253 * @return String in the format {@code "1.23456 [separator]2.34567"}245 * Returns the coordinates in human-readable format. 246 * @param projected whether to use projected coordinates 247 * @param coordinates the coordinates to format 248 * @return String in the format {@code "1.23456, 2.34567"} 254 249 */ 255 private static String toStringCSV(String separator, ILatLon ll) { 256 return String.join(separator, 257 DecimalDegreesCoordinateFormat.INSTANCE.latToString(ll), 258 DecimalDegreesCoordinateFormat.INSTANCE.lonToString(ll) 259 ); 250 private static String toStringCSV(boolean projected, ILatLon... coordinates) { 251 final AbstractCoordinateFormat format = projected 252 ? ProjectedCoordinateFormat.INSTANCE 253 : DecimalDegreesCoordinateFormat.INSTANCE; 254 return Arrays.stream(coordinates) 255 .flatMap(ll -> Stream.of(format.latToString(ll), format.lonToString(ll))) 256 .collect(Collectors.joining(", ")); 260 257 } 261 258
Note:
See TracChangeset
for help on using the changeset viewer.