source: josm/src/org/openstreetmap/josm/data/osm/Way.java@ 298

Last change on this file since 298 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 1.4 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.List;
7
8import org.openstreetmap.josm.data.osm.visitor.Visitor;
9
10/**
11 * One full way, consisting of several way segments chained together.
12 *
13 * @author imi
14 */
15public final class Way extends OsmPrimitive {
16
17 /**
18 * All way segments in this way
19 */
20 public final List<Segment> segments = new ArrayList<Segment>();
21
22 @Override public void visit(Visitor visitor) {
23 visitor.visit(this);
24 }
25
26 /**
27 * Create an identical clone of the argument (including the id)
28 */
29 public Way(Way clone) {
30 cloneFrom(clone);
31 }
32
33 public Way() {
34 }
35
36 @Override public void cloneFrom(OsmPrimitive osm) {
37 super.cloneFrom(osm);
38 segments.clear();
39 segments.addAll(((Way)osm).segments);
40 }
41
42 @Override public String toString() {
43 return "{Way id="+id+" segments="+Arrays.toString(segments.toArray())+"}";
44 }
45
46 @Override public boolean realEqual(OsmPrimitive osm, boolean semanticOnly) {
47 return osm instanceof Way ? super.realEqual(osm, semanticOnly) && segments.equals(((Way)osm).segments) : false;
48 }
49
50 public int compareTo(OsmPrimitive o) {
51 return o instanceof Way ? Long.valueOf(id).compareTo(o.id) : -1;
52 }
53
54 public boolean isIncomplete() {
55 for (Segment s : segments)
56 if (s.incomplete)
57 return true;
58 return false;
59 }
60}
Note: See TracBrowser for help on using the repository browser.