-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOSMRoad.java
More file actions
85 lines (61 loc) · 1.44 KB
/
Copy pathOSMRoad.java
File metadata and controls
85 lines (61 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
public class OSMRoad{
//Add the fileds here
private OSMNode[] nodes = {};
private double weight;
private int num;
public OSMRoad(OSMNode[] ns, double val, int num) {
//Constructor
nodes = ns;
weight = val;
this.num = num;
}
public OSMRoad() {
}
public int getNum() {
return num;
}
public OSMNode getNode(int nth) {
//Returns the Nth node of the road
if(nth < nodes.length){
return nodes[nth];
}
else{
return null;
}
}
public int getNumNodes() {
//Returns number of nodes in the road
return nodes.length;
}
public boolean containsNode(OSMNode n) {
//Checks if node n exist in this road or not
for(OSMNode i: nodes){
if(i.equals(n)){
return true;
}
}
return false;
}
public OSMNode intersects(OSMRoad r) {
//Returns the intersection node of this road and road r
if(this == null || r == null){
return null;
}
for(int i = 0; i < r.getNumNodes(); i++){
if(this.containsNode(r.getNode(i))){
return r.getNode(i);
}
}
return null;
}
public OSMNode[] adjacentNodes(OSMNode n) {
/*Optional method
Returning a list of adjacent nodes by n in this road
*/
return new OSMNode[]{};
}
public double getWidth() {
// TODO Auto-generated method stub
return this.weight;
}
}