1 package osm;
2
3 import java.io.IOException;
4 import java.net.URISyntaxException;
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import org.opentrafficsim.importexport.osm.Network;
9 import org.opentrafficsim.importexport.osm.Tag;
10 import org.opentrafficsim.importexport.osm.input.ReadOSMFile;
11
12
13
14
15
16
17
18
19
20
21 public class ReadOSM
22 {
23
24 private static String loc = "duesseldorf_germany.osm.bz2";
25
26
27
28
29 private static List<Tag> wt;
30
31
32 private static List<String> ft;
33
34
35
36
37 private static void makeWanted()
38 {
39 Tag t1 = new Tag("highway", "primary");
40 wt.add(t1);
41 Tag t2 = new Tag("highway", "secondary");
42 wt.add(t2);
43 Tag t3 = new Tag("highway", "tertiary");
44 wt.add(t3);
45 Tag t4 = new Tag("highway", "cycleway");
46 wt.add(t4);
47 Tag t5 = new Tag("highway", "trunk");
48 wt.add(t5);
49 Tag t6 = new Tag("highway", "path");
50 wt.add(t6);
51 Tag t8 = new Tag("cyclway", "lane");
52 wt.add(t8);
53 Tag t9 = new Tag("highway", "residental");
54 wt.add(t9);
55 Tag t10 = new Tag("highway", "service");
56 wt.add(t10);
57 Tag t11 = new Tag("highway", "motorway");
58 wt.add(t11);
59 Tag t12 = new Tag("highway", "bus_stop");
60 wt.add(t12);
61 }
62
63
64
65
66 private static void makeFilter()
67 {
68 ft.add("highway");
69 ft.add("cycleway");
70 ft.add("lanes");
71 ft.add("name");
72 ft.add("maxspeed");
73 ft.add("junction");
74 ft.add("oneway");
75 ft.add("sidewalk");
76 ft.add("busway");
77 ft.add("junction");
78 ft.add("service");
79 ft.add("ele");
80 ft.add("location");
81 ft.add("layer");
82 ft.add("bridge");
83 ft.add("tunnel");
84 }
85
86
87
88
89 public static void main(final String[] args)
90 {
91 ft = new ArrayList<String>();
92 wt = new ArrayList<Tag>();
93 makeWanted();
94 makeFilter();
95 try
96 {
97 System.out.println("Parsing " + loc);
98 String prefix = "file:///D:/";
99 ReadOSMFile osmf = new ReadOSMFile(prefix + loc, wt, ft);
100 while (!osmf.checkisReaderThreadDead())
101 {
102 System.out.println("Processing");
103 }
104 Network net = osmf.getNetwork();
105 System.out.println("Got Network. Start Conversion");
106 System.out.println("Making links");
107 net.makeLinks();
108 System.out.println("Made " + net.getLinks().size() + " links");
109 System.out.println("Removing redundancies");
110 net.removeRedundancy();
111 System.out.println(net.getLinks().size() + " links after redudancy removal");
112 System.out.println("Not yet converting to OTS internal format - terminating");
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 }
157 catch (URISyntaxException exception)
158 {
159 exception.printStackTrace();
160 }
161 catch (IOException exception)
162 {
163 exception.printStackTrace();
164 }
165 }
166
167 }