source: josm/trunk/src/org/openstreetmap/josm/data/osm/WayData.java@ 13512

Last change on this file since 13512 was 12193, checked in by Don-vip, 7 years ago

fix #14810 - partial revert of r12190

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.List;
6
7import 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 */
12public class WayData extends PrimitiveData implements IWay {
13
14 private static final long serialVersionUID = 106944939313286415L;
15 private List<Long> nodes = new ArrayList<>();
16
17 /**
18 * Constructs a new {@code NodeData}.
19 */
20 public WayData() {
21 // contents can be set later with setters
22 }
23
24 /**
25 * Constructs a new {@code WayData} with given id.
26 * @param id id
27 * @since 12017
28 */
29 public WayData(long id) {
30 super(id);
31 }
32
33 /**
34 * Constructs a new {@code WayData}.
35 * @param data way data to copy
36 */
37 public WayData(WayData data) {
38 super(data);
39 nodes.addAll(data.getNodes());
40 }
41
42 /**
43 * Gets a list of nodes the way consists of
44 * @return The ids of the nodes
45 */
46 public List<Long> getNodes() {
47 return nodes;
48 }
49
50 @Override
51 public int getNodesCount() {
52 return nodes.size();
53 }
54
55 @Override
56 public long getNodeId(int idx) {
57 return nodes.get(idx);
58 }
59
60 @Override
61 public boolean isClosed() {
62 if (isIncomplete()) return false;
63 return nodes.get(0).equals(nodes.get(nodes.size() - 1));
64 }
65
66 /**
67 * Sets the nodes array
68 * @param nodes The nodes this way consists of
69 */
70 public void setNodes(List<Long> nodes) {
71 this.nodes = new ArrayList<>(nodes);
72 }
73
74 @Override
75 public WayData makeCopy() {
76 return new WayData(this);
77 }
78
79 @Override
80 public String toString() {
81 return super.toString() + " WAY" + nodes;
82 }
83
84 @Override
85 public OsmPrimitiveType getType() {
86 return OsmPrimitiveType.WAY;
87 }
88
89 @Override
90 public void accept(PrimitiveVisitor visitor) {
91 visitor.visit(this);
92 }
93
94}
Note: See TracBrowser for help on using the repository browser.