1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * The data (tags and node ids) that is stored for a way in the database.
|
---|
11 | * @since 2284
|
---|
12 | */
|
---|
13 | public class WayData extends PrimitiveData implements IWay<NodeData> {
|
---|
14 |
|
---|
15 | private static final long serialVersionUID = 106944939313286415L;
|
---|
16 | private List<Long> nodes = new ArrayList<>();
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Constructs a new {@code NodeData}.
|
---|
20 | */
|
---|
21 | public WayData() {
|
---|
22 | // contents can be set later with setters
|
---|
23 | }
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Constructs a new {@code WayData} with given id.
|
---|
27 | * @param id id
|
---|
28 | * @since 12017
|
---|
29 | */
|
---|
30 | public WayData(long id) {
|
---|
31 | super(id);
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Constructs a new {@code WayData}.
|
---|
36 | * @param data way data to copy
|
---|
37 | */
|
---|
38 | public WayData(WayData data) {
|
---|
39 | super(data);
|
---|
40 | nodes.addAll(data.getNodeIds());
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public List<NodeData> getNodes() {
|
---|
45 | throw new UnsupportedOperationException("Use getNodeIds() instead");
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public NodeData getNode(int index) {
|
---|
50 | throw new UnsupportedOperationException("Use getNodeId(int) instead");
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | public List<Long> getNodeIds() {
|
---|
55 | return nodes;
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public int getNodesCount() {
|
---|
60 | return nodes.size();
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public long getNodeId(int idx) {
|
---|
65 | return nodes.get(idx);
|
---|
66 | }
|
---|
67 |
|
---|
68 | @Override
|
---|
69 | public boolean isClosed() {
|
---|
70 | if (isIncomplete()) return false;
|
---|
71 | return nodes.get(0).equals(nodes.get(nodes.size() - 1));
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Override
|
---|
75 | public void setNodes(List<NodeData> nodes) {
|
---|
76 | throw new UnsupportedOperationException("Use setNodeIds(List) instead");
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Sets the nodes array
|
---|
81 | * @param nodes The nodes this way consists of
|
---|
82 | * @since 13907
|
---|
83 | */
|
---|
84 | public void setNodeIds(List<Long> nodes) {
|
---|
85 | this.nodes = new ArrayList<>(nodes);
|
---|
86 | }
|
---|
87 |
|
---|
88 | @Override
|
---|
89 | public WayData makeCopy() {
|
---|
90 | return new WayData(this);
|
---|
91 | }
|
---|
92 |
|
---|
93 | @Override
|
---|
94 | public String toString() {
|
---|
95 | return super.toString() + " WAY" + nodes;
|
---|
96 | }
|
---|
97 |
|
---|
98 | @Override
|
---|
99 | public OsmPrimitiveType getType() {
|
---|
100 | return OsmPrimitiveType.WAY;
|
---|
101 | }
|
---|
102 |
|
---|
103 | @Override
|
---|
104 | public void accept(PrimitiveVisitor visitor) {
|
---|
105 | visitor.visit(this);
|
---|
106 | }
|
---|
107 |
|
---|
108 | @Override
|
---|
109 | public BBox getBBox() {
|
---|
110 | throw new UnsupportedOperationException();
|
---|
111 | }
|
---|
112 |
|
---|
113 | @Override
|
---|
114 | public NodeData firstNode() {
|
---|
115 | throw new UnsupportedOperationException();
|
---|
116 | }
|
---|
117 |
|
---|
118 | @Override
|
---|
119 | public NodeData lastNode() {
|
---|
120 | throw new UnsupportedOperationException();
|
---|
121 | }
|
---|
122 |
|
---|
123 | @Override
|
---|
124 | public boolean isFirstLastNode(INode n) {
|
---|
125 | throw new UnsupportedOperationException();
|
---|
126 | }
|
---|
127 |
|
---|
128 | @Override
|
---|
129 | public boolean isInnerNode(INode n) {
|
---|
130 | throw new UnsupportedOperationException();
|
---|
131 | }
|
---|
132 | }
|
---|