source: josm/trunk/src/org/openstreetmap/josm/data/osm/INode.java@ 14120

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

see #15229 - deprecate all Main methods related to projections. New ProjectionRegistry class

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import org.openstreetmap.josm.Main;
5import org.openstreetmap.josm.data.coor.EastNorth;
6import org.openstreetmap.josm.data.coor.ILatLon;
7import org.openstreetmap.josm.data.coor.LatLon;
8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
9
10/**
11 * INode captures the common functions of {@link Node} and {@link NodeData}.
12 * @since 4098
13 */
14public interface INode extends IPrimitive, ILatLon {
15
16 /**
17 * Returns lat/lon coordinates of this node.
18 * @return lat/lon coordinates of this node
19 */
20 LatLon getCoor();
21
22 /**
23 * Sets lat/lon coordinates of this node.
24 * @param coor lat/lon coordinates of this node
25 */
26 void setCoor(LatLon coor);
27
28 /**
29 * Replies the projected east/north coordinates.
30 * <p>
31 * Uses the {@link Main#getProjection() global projection} to project the lat/lon-coordinates.
32 * <p>
33 * @return the east north coordinates or {@code null} if {@link #isLatLonKnown()} is false.
34 * @since 13666
35 */
36 default EastNorth getEastNorth() {
37 return getEastNorth(ProjectionRegistry.getProjection());
38 }
39
40 /**
41 * Sets east/north coordinates of this node.
42 * @param eastNorth east/north coordinates of this node
43 */
44 void setEastNorth(EastNorth eastNorth);
45
46 /**
47 * Check whether this node connects 2 ways.
48 *
49 * @return true if isReferredByWays(2) returns true
50 * @see #isReferredByWays(int)
51 * @since 13669
52 */
53 default boolean isConnectionNode() {
54 return isReferredByWays(2);
55 }
56
57 /**
58 * Return true, if this primitive is referred by at least n ways
59 * @param n Minimal number of ways to return true. Must be positive
60 * @return {@code true} if this primitive is referred by at least n ways
61 * @since 13669
62 */
63 boolean isReferredByWays(int n);
64
65 @Override
66 default int compareTo(IPrimitive o) {
67 return o instanceof INode ? Long.compare(getUniqueId(), o.getUniqueId()) : 1;
68 }
69
70 @Override
71 default String getDisplayName(NameFormatter formatter) {
72 return formatter.format(this);
73 }
74}
Note: See TracBrowser for help on using the repository browser.