source: josm/trunk/src/org/openstreetmap/josm/data/imagery/CoordinateConversion.java@ 13388

Last change on this file since 13388 was 12669, checked in by Don-vip, 7 years ago

see #15182 - remove dependence on JMapViewer for package data.coor (only useful for imagery)

File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.imagery;
3
4import org.openstreetmap.gui.jmapviewer.Coordinate;
5import org.openstreetmap.gui.jmapviewer.Projected;
6import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
7import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;
8import org.openstreetmap.josm.data.coor.EastNorth;
9import org.openstreetmap.josm.data.coor.LatLon;
10
11/**
12 * Allows easy conversion between JMapViewer coordinate types and JOSM coordinate types.
13 * @since 12669
14 */
15public final class CoordinateConversion {
16
17 private CoordinateConversion() {
18 // Hide default constructor for utility classes
19 }
20
21 /**
22 * Converts an {@link EastNorth} to an {@link IProjected} instance.
23 * @param en east/north coordinate
24 * @return {@code IProjected} instance
25 */
26 public static IProjected enToProj(EastNorth en) {
27 return new Projected(en.east(), en.north());
28 }
29
30 /**
31 * Converts an {@link IProjected} to an {@link EastNorth} instance.
32 * @param p projected coordinate
33 * @return {@code EastNorth} instance
34 */
35 public static EastNorth projToEn(IProjected p) {
36 return new EastNorth(p.getEast(), p.getNorth());
37 }
38
39 /**
40 * Converts a {@link LatLon} to an {@link ICoordinate} instance.
41 * @param ll latitude/longitude coordinate
42 * @return {@code ICoordinate} instance
43 */
44 public static ICoordinate llToCoor(LatLon ll) {
45 return new Coordinate(ll.lat(), ll.lon());
46 }
47
48 /**
49 * Converts an {@link ICoordinate} to a {@link LatLon} instance.
50 * @param c coordinate
51 * @return {@code LatLon} instance
52 */
53 public static LatLon coorToLL(ICoordinate c) {
54 return new LatLon(c.getLat(), c.getLon());
55 }
56}
Note: See TracBrowser for help on using the repository browser.