1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.Main;
|
---|
5 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
6 | import org.openstreetmap.josm.data.coor.ILatLon;
|
---|
7 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
8 | import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * INode captures the common functions of {@link Node} and {@link NodeData}.
|
---|
12 | * @since 4098
|
---|
13 | */
|
---|
14 | public 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 | }
|
---|