I ask you for help because for a long time I'm trying to find the solution to this code ...
I have a txt of gps track like this.
WGS 84;
U 1;
C 255,0,0,2,-1.0;
L -02:00:00
V 0.0 0.0 0 0 0 0 0.0 -1.0 0
E 0|1|00-NUL-00 00:00:00|00:00:00|0|2984
i I00
z 12.716222,42.410293,12.736302,42.449607
T A 42.41060087ºN 12.72081354ºE 25-SEP-08 07:13:34 N 841.8 0.0 0.0 0.0 0 -1000.0 9999999562023526400000000.0 -1 -1.0 -1.0
T A 42.41060045ºN 12.72082259ºE 25-SEP-08 07:13:39 s 842.7 0.0 0.0 0.0 0 -1000.0 9999999562023526400000000.0 -1 -1.0 -1.0
T A 42.41060296ºN 12.72083248ºE 25-SEP-08 07:13:44 s 842.3 0.0 0.0 0.0 0 -1000.0 9999999562023526400000000.0 -1 -1.0 -1.0 `
I need to import this coordinates ..into database of this format ...
{
TracksDB tracksDB = new TracksDB(context);
TrackPointsDB trackPointsDB = new TrackPointsDB(context);
tracksDB.open();
trackPointsDB.open();
File file = new File(path);
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
int count = 0;
try
{
Track track;
while ((track = (Track) in.readObject()) != null)
{
long id = tracksDB.insert(track.getName());
ArrayList<TrackPoint> points = track.getTrackPoints();
for (TrackPoint point : points)
{
trackPointsDB.insert(id, point.getLongitude(), point.getLatitude(), point.getAltitude(), point.getAccuracy(),
Long.toString(point.getTime()));
}
count++;
}
}
catch (EOFException eof)
{
}
// !// finally?
in.close();
tracksDB.close();
trackPointsDB.close();
return count;
}
I try to open a track file but I do not undestand how to create a db with same of import procedure ..please help! Thanks
Before calling insert method, call a method which creates database.
for ex. -
public void createDatabase(){
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
String sql = "CREATE DATABASE Tracks";
stmt.executeUpdate(sql);
}
Same way create table after that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.