1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm.history;
|
---|
3 |
|
---|
4 | import java.util.Date;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
7 | import org.openstreetmap.josm.data.osm.Node;
|
---|
8 | import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
---|
9 | import org.openstreetmap.josm.data.osm.User;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Represents an immutable OSM node in the context of a historical view on
|
---|
13 | * OSM data.
|
---|
14 | *
|
---|
15 | */
|
---|
16 | public class HistoryNode extends HistoryOsmPrimitive {
|
---|
17 |
|
---|
18 | /** the coordinates. May be null for deleted nodes */
|
---|
19 | private LatLon coords;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code HistoryNode}.
|
---|
23 | *
|
---|
24 | * @param id the id (> 0 required)
|
---|
25 | * @param version the version (> 0 required)
|
---|
26 | * @param visible whether the node is still visible
|
---|
27 | * @param user the user (! null required)
|
---|
28 | * @param changesetId the changeset id (> 0 required)
|
---|
29 | * @param timestamp the timestamp (! null required)
|
---|
30 | * @param coords the coordinates
|
---|
31 | * @throws IllegalArgumentException if preconditions are violated
|
---|
32 | */
|
---|
33 | public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords) throws IllegalArgumentException {
|
---|
34 | this(id, version, visible, user, changesetId, timestamp, coords, true);
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Constructs a new {@code HistoryNode} with a configurable checking of historic parameters.
|
---|
39 | * This is needed to build virtual HistoryNodes for modified nodes, which do not have a timestamp and a changeset id.
|
---|
40 | *
|
---|
41 | * @param id the id (> 0 required)
|
---|
42 | * @param version the version (> 0 required)
|
---|
43 | * @param visible whether the node is still visible
|
---|
44 | * @param user the user (! null required)
|
---|
45 | * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
|
---|
46 | * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
|
---|
47 | * @param coords the coordinates
|
---|
48 | * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp}
|
---|
49 | * @throws IllegalArgumentException if preconditions are violated
|
---|
50 | * @since 5440
|
---|
51 | */
|
---|
52 | public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords, boolean checkHistoricParams) throws IllegalArgumentException {
|
---|
53 | super(id, version, visible, user, changesetId, timestamp, checkHistoricParams);
|
---|
54 | setCoords(coords);
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Constructs a new {@code HistoryNode} from an existing {@link Node}.
|
---|
59 | * @param n the node
|
---|
60 | */
|
---|
61 | public HistoryNode(Node n) {
|
---|
62 | super(n);
|
---|
63 | setCoords(n.getCoor());
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public OsmPrimitiveType getType() {
|
---|
68 | return OsmPrimitiveType.NODE;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Replies the coordinates. May be null.
|
---|
73 | * @return the coordinates. May be null.
|
---|
74 | */
|
---|
75 | public LatLon getCoords() {
|
---|
76 | return coords;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Sets the coordinates. Can be null.
|
---|
81 | * @param coords the coordinates. Can be null.
|
---|
82 | */
|
---|
83 | public void setCoords(LatLon coords) {
|
---|
84 | this.coords = coords;
|
---|
85 | }
|
---|
86 |
|
---|
87 | @Override
|
---|
88 | public String getDisplayName(HistoryNameFormatter formatter) {
|
---|
89 | return formatter.format(this);
|
---|
90 | }
|
---|
91 | }
|
---|