-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
57 lines (47 loc) · 1.08 KB
/
Node.java
File metadata and controls
57 lines (47 loc) · 1.08 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
import java.util.ArrayList;
public class Node
{
public long id;
public double lat;
public double lon;
public boolean is_intersect;
public Way[] ways;
public boolean[] isAtStart;
public ArrayList<Way> tmp_ways;
public Node(long id, double latitude, double longitude)
{
this.id = id;
this.lat = latitude;
this.lon = longitude;
this.is_intersect = false;
ways = null;
tmp_ways = new ArrayList();
}
public void addNewWay(Way new_way)
{
tmp_ways.add(new_way);
}
public void validateWays()
{
int i;
i = 0;
ways = new Way[tmp_ways.size()];
isAtStart = new boolean[tmp_ways.size()];
for (Way way : tmp_ways)
{
ways[i] = way;
if (way.start == this)
isAtStart[i] = true;
else if (way.end == this)
isAtStart[i] = false;
else
System.out.println("BIG ERROR, node neither at end nor at the beginning of way.");
i++;
}
tmp_ways = null;
}
public String toString()
{
return ("NODE n " + id + " :\n is_intersect : " + is_intersect + "\n nb ways : " + (ways != null ? ways.length : 0) + "\n lat : " + lat + "\n lon : " + lon);
}
}