1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.Main;
|
---|
5 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
6 | import org.openstreetmap.josm.data.coor.EastNorth;
|
---|
7 | import org.openstreetmap.josm.data.osm.visitor.Visitor;
|
---|
8 |
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * One node data, consisting of one world coordinate waypoint.
|
---|
12 | *
|
---|
13 | * @author imi
|
---|
14 | */
|
---|
15 | public final class Node extends OsmPrimitive {
|
---|
16 |
|
---|
17 | public LatLon coor;
|
---|
18 | public volatile EastNorth eastNorth;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Create an incomplete Node object
|
---|
22 | */
|
---|
23 | public Node(long id) {
|
---|
24 | this.id = id;
|
---|
25 | incomplete = true;
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Create an identical clone of the argument (including the id)
|
---|
30 | */
|
---|
31 | public Node(Node clone) {
|
---|
32 | cloneFrom(clone);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Node(LatLon latlon) {
|
---|
36 | this.coor = latlon;
|
---|
37 | eastNorth = Main.proj.latlon2eastNorth(latlon);
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Override public void visit(Visitor visitor) {
|
---|
41 | visitor.visit(this);
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override public void cloneFrom(OsmPrimitive osm) {
|
---|
45 | super.cloneFrom(osm);
|
---|
46 | coor = ((Node)osm).coor;
|
---|
47 | eastNorth = ((Node)osm).eastNorth;
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override public String toString() {
|
---|
51 | return "{Node id="+id+",lat="+coor.lat()+",lon="+coor.lon()+"}";
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override public boolean realEqual(OsmPrimitive osm, boolean semanticOnly) {
|
---|
55 | return osm instanceof Node ? super.realEqual(osm, semanticOnly) && coor.equals(((Node)osm).coor) : false;
|
---|
56 | }
|
---|
57 |
|
---|
58 | public int compareTo(OsmPrimitive o) {
|
---|
59 | return o instanceof Node ? Long.valueOf(id).compareTo(o.id) : 1;
|
---|
60 | }
|
---|
61 | }
|
---|