-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapefile.java
More file actions
80 lines (72 loc) · 1.91 KB
/
Shapefile.java
File metadata and controls
80 lines (72 loc) · 1.91 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
import java.util.ArrayList;
import java.io.PrintWriter;
public class Shapefile
{
public static void saveWaysToFile(ArrayList<Way> ways)
{
PrintWriter writer;
int i;
writer = null;
try
{
writer = new PrintWriter("./shapefiles/all_ways.ways", "ASCII");
}
catch (Exception e)
{
System.out.println("Could not write to file.");
}
i = 0;
for (Way way : ways)
{
writer.println(Way.getTypeName(way.type));
writer.println(way.length);
writer.println(way.time);
writer.println(way.speed_limit);
writer.println(way.id);
writer.println(way.oneway);
writer.println(way.accessGranted);
writer.println(way.start.lon + "," + way.start.lat);
for (Node node : way.nodes)
writer.println(node.lon + "," + node.lat);
writer.println(way.end.lon + "," + way.end.lat);
i++;
if (i != ways.size())
writer.println("");
}
writer.close();
}
public static void saveWayToFile(SearchNode searchNode, String start, String end)
{
PrintWriter writer;
int i;
writer = null;
try
{
writer = new PrintWriter("./shapefiles/" + start.replace(" ", "_") + "_" + end.replace(" ", "_") + ".ways", "ASCII");
System.out.println("Best way saved to " + "shapefiles/" + start.replace(" ", "_") + "_" + end.replace(" ", "_") + ".ways");
}
catch (Exception e)
{
System.out.println("Could not write to file.");
}
i = 0;
for (Way way : searchNode.ways)
{
writer.println(Way.getTypeName(way.type));
writer.println(way.length);
writer.println(way.time);
writer.println(way.speed_limit);
writer.println(way.id);
writer.println(way.oneway);
writer.println(way.accessGranted);
writer.println(way.start.lon + "," + way.start.lat);
for (Node node : way.nodes)
writer.println(node.lon + "," + node.lat);
writer.println(way.end.lon + "," + way.end.lat);
i++;
if (i != searchNode.ways.length)
writer.println("");
}
writer.close();
}
}