1.
public class POI {
2.
private double longitude;
3.
private double latitude;
4.
private String name;
5.
6.
public POI(String name, double longitude, double latitude) {
7.
this.name = name;
8.
this.longitude = longitude;
9.
this.latitude = latitude;
10.
}
11.
12.
public double getLatitude() {
13.
return latitude;
14.
}
15.
16.
public double getLongitude() {
17.
return longitude;
18.
}
19.
20.
public String getName() {
21.
return name;
22.
}
23.
24.
public static List getPOIs(InputStream is) throws IOException {
25.
List res = new ArrayList();
26.
int b = -1;
27.
while ((b = is.read())> -1) {
28.
if (b == 0 || b == 2) {
29.
30.
long total = readLong(is);
31.
32.
double longitude = (double) readLong(is) / 100000.0;
33.
double latitude = (double) readLong(is) / 100000.0;
34.
35.
byte[] r = new byte[(int) total - 13];
36.
is.read(r);
37.
38.
POI p = new POI(new String(r), longitude, latitude);
39.
res.add(p);
40.
}
41.
}
42.
return res;
43.
}
44.
45.
private static long readLong(InputStream is) throws IOException {
46.
long res = is.read();
47.
res += is.read() <<8;
48.
res += is.read() <<16;
49.
res += is.read() <<24;
50.
return res;
51.
}
52.
}
Bookmarks