source: josm/trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java@ 1670

Last change on this file since 1670 was 1670, checked in by Gubaer, 15 years ago

fixed: bug in OsmApi.getOsmApi()
cleanup: exception handling in interfacing with OSM API
new: new action for updating individual elements with the their current state on the server (including new menu item in the file menu)
new: improved user feedback in case of conflicts
new: handles 410 Gone conflicts when uploading a changeset
new: undoable command for "purging" a primitive from the current dataset (necessary if the primitive is already deleted on the server and the user wants to remove it from its local dataset)
new: undoable command for "undeleting" an already deleted primitive on the server (kind of "cloning")
new: after a full upload, checks whether there are primitives in the local dataset which might be deleted on the server.
new: data structures for history data
new: history download support in io package

File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm.history;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
10
11import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
12/**
13 * Represents an immutable OSM way in the context of a historical view on
14 * OSM data.
15 *
16 */
17public class HistoryWay extends HistoryOsmPrimitive {
18
19 private ArrayList<Long> nodeIds;
20
21 public HistoryWay(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp) {
22 super(id, version, visible, user, uid, changesetId, timestamp);
23 nodeIds = new ArrayList<Long>();
24 }
25
26 public HistoryWay(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) {
27 this(id, version, visible, user, uid, changesetId, timestamp);
28 this.nodeIds.addAll(nodeIdList);
29 }
30
31 /**
32 * replies the number of nodes in this way
33 * @return the number of nodes
34 */
35 public int getNumNodes() {
36 return nodeIds.size();
37 }
38
39 /**
40 * replies the idx-th node id in the list of node ids of this way
41 *
42 * @param idx the index
43 * @return the idx-th node id
44 * @exception IndexOutOfBoundsException thrown, if idx <0 || idx >= {#see {@link #getNumNodes()}
45 */
46 public long getNodeId(int idx) throws IndexOutOfBoundsException {
47 if (idx < 0 || idx >= nodeIds.size())
48 throw new IndexOutOfBoundsException(tr("parameter {0} not in range 0..{1}, got {2}", "idx", nodeIds.size(),idx));
49 return nodeIds.get(idx);
50 }
51
52 /**
53 * replies an immutable list of the ways node ids
54 *
55 * @return the ways node ids
56 */
57 public List<Long> getNodes() {
58 return Collections.unmodifiableList(nodeIds);
59 }
60
61 /**
62 * replies the ways type, i.e. {@see OsmPrimitiveType#WAY}
63 *
64 * @return the ways type
65 */
66 @Override
67 public OsmPrimitiveType getType() {
68 return OsmPrimitiveType.WAY;
69 }
70
71 /**
72 * adds a node id to the list nodes of this way
73 *
74 * @param ref the node id to add
75 */
76 public void addNode(long ref) {
77 nodeIds.add(ref);
78 }
79}
Note: See TracBrowser for help on using the repository browser.