source: josm/trunk/src/org/openstreetmap/josm/data/coor/ILatLon.java@ 13536

Last change on this file since 13536 was 13173, checked in by Don-vip, 6 years ago

see #15310 - remove most of deprecated APIs

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.coor;
3
4import org.openstreetmap.josm.data.projection.Projecting;
5
6/**
7 * This interface represents a coordinate in LatLon space.
8 * <p>
9 * It provides methods to get the coordinates. The coordinates may be unknown.
10 * In this case, both {@link #lat()} and {@link #lon()} need to return a NaN value and {@link #isLatLonKnown()} needs to return false.
11 * <p>
12 * Whether the coordinates are immutable or not is implementation specific.
13 *
14 * @author Michael Zangl
15 * @since 12161
16 */
17public interface ILatLon {
18
19 /**
20 * Returns the longitude, i.e., the east-west position in degrees.
21 * @return the longitude or NaN if {@link #isLatLonKnown()} returns false
22 */
23 double lon();
24
25 /**
26 * Returns the latitude, i.e., the north-south position in degrees.
27 * @return the latitude or NaN if {@link #isLatLonKnown()} returns false
28 */
29 double lat();
30
31 /**
32 * Determines if this object has valid coordinates.
33 * @return {@code true} if this object has valid coordinates
34 */
35 default boolean isLatLonKnown() {
36 return !Double.isNaN(lat()) && !Double.isNaN(lon());
37 }
38
39 /**
40 * Replies the projected east/north coordinates.
41 * <p>
42 * The result of the last conversion may be cached. Null is returned in case this object is invalid.
43 * @param projecting The projection to use.
44 * @return The projected east/north coordinates
45 * @since 10827
46 */
47 default EastNorth getEastNorth(Projecting projecting) {
48 if (!isLatLonKnown()) {
49 return null;
50 } else {
51 return projecting.latlon2eastNorth(this);
52 }
53 }
54}
Note: See TracBrowser for help on using the repository browser.