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

Last change on this file since 4153 was 4100, checked in by bastiK, 13 years ago

use IPrimitive to make upload code work for both OsmPrimitive and PrimitiveData

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 1.4 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;
6import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
7
8public class WayData extends PrimitiveData implements IWay {
9
10 private List<Long> nodes = new ArrayList<Long>();
11
12 public WayData() {
13
14 }
15
16 public WayData(WayData data) {
17 super(data);
18 nodes.addAll(data.getNodes());
19 }
20
21 public List<Long> getNodes() {
22 return nodes;
23 }
24
25 @Override
26 public int getNodesCount() {
27 return nodes.size();
28 }
29
30 @Override
31 public long getNodeId(int idx) {
32 return nodes.get(idx);
33 }
34
35 @Override
36 public boolean isClosed() {
37 if (isIncomplete()) return false;
38 return nodes.get(0).equals(nodes.get(nodes.size() - 1));
39 }
40
41 public void setNodes(List<Long> nodes) {
42 this.nodes = new ArrayList<Long>(nodes);
43 }
44
45 @Override
46 public WayData makeCopy() {
47 return new WayData(this);
48 }
49
50 @Override
51 public String toString() {
52 return super.toString() + " WAY" + nodes.toString();
53 }
54
55 @Override
56 public OsmPrimitiveType getType() {
57 return OsmPrimitiveType.WAY;
58 }
59
60 @Override
61 public void visit(PrimitiveVisitor visitor) {
62 visitor.visit(this);
63 }
64
65 @Override
66 public String getDisplayName(NameFormatter formatter) {
67 return formatter.format(this);
68 }
69
70}
Note: See TracBrowser for help on using the repository browser.