5
我想知道是否存在任何可以爲Tomtom導航設備生成poi數據的Java庫(通常該文件具有.ov2擴展名)。用於生成TomTom GPS poi數據的Java庫
我從Tomtom使用Tomtom makeov2.exe util,但它不穩定,似乎不再支持。
我想知道是否存在任何可以爲Tomtom導航設備生成poi數據的Java庫(通常該文件具有.ov2擴展名)。用於生成TomTom GPS poi數據的Java庫
我從Tomtom使用Tomtom makeov2.exe util,但它不穩定,似乎不再支持。
我沒能找到,它寫一個圖書館,雖然我沒有找到這個類來讀取.ov2
文件:
package readers;
import java.io.FileInputStream;
import java.io.IOException;
public class OV2RecordReader {
public static String[] readOV2Record(FileInputStream inputStream){
String[] record = null;
int b = -1;
try{
if ((b = inputStream.read())> -1) {
// if it is a simple POI record
if (b == 2) {
record = new String[3];
long total = readLong(inputStream);
double longitude = (double) readLong(inputStream)/100000.0;
double latitude = (double) readLong(inputStream)/100000.0;
byte[] r = new byte[(int) total - 13];
inputStream.read(r);
record[0] = new String(r);
record[0] = record[0].substring(0,record[0].length()-1);
record[1] = Double.toString(latitude);
record[2] = Double.toString(longitude);
}
//if it is a deleted record
else if(b == 0){
byte[] r = new byte[9];
inputStream.read(r);
}
//if it is a skipper record
else if(b == 1){
byte[] r = new byte[20];
inputStream.read(r);
}
else{
throw new IOException("wrong record type");
}
}
else{
return null;
}
}
catch(IOException e){
e.printStackTrace();
}
return record;
}
private static long readLong(FileInputStream is){
long res = 0;
try{
res = is.read();
res += is.read() <<8;
res += is.read() <<16;
res += is.read() <<24;
}
catch(IOException e){
e.printStackTrace();
}
return res;
}
}
我也發現這個PHP代碼寫入文件:
<?php
$csv = file("File.csv");
$nbcsv = count($csv);
$file = "POI.ov2";
$fp = fopen($file, "w");
for ($i = 0; $i < $nbcsv; $i++) {
$table = split(",", chop($csv[$i]));
$lon = $table[0];
$lat = $table[1];
$des = $table[2];
$TT = chr(0x02).pack("V",strlen($des)+14).pack("V",round($lon*100000)).pack("V",round($lat*100000)).$des.chr(0x00);
@fwrite($fp, "$TT");
}
fclose($fp);
我不知道如何去編寫一個Java類(或擴展上面的那個)來編寫像PHP函數那樣的文件,但是您可能能夠深入瞭解文件的編碼方式從中。
謝謝你的答案。但要說實話,我更願意準備好使用,測試,支持的庫,而不是從頭開始編寫新的。 – never