Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29
  1. #21  
    Hi Metaview,

    I've tried PMing / posting source code to you, but this forum is preventing me from doing this (because I've only made 5 posts apparently).

    Could you PM me your email address and I'll send you the source code straight away.
  2. #22  
    Hi MetaView,

    I've pasted a small java class below, which I've used to convert GPS track data stored in a Mojo database. It assumes a table with 4 text columns: lat, lon, altitude, time. I used a convention in Mojo code of creating tables with name: Gyyyymmddhhmmss

    I used an open source SQLite JDBC driver to read the data on the desktop:
    SQLiteJDBC

    Please download sqlitejdbc-v056.jar, and copy to same directory as the Java class.

    After you've compiled with JDK, run as follows:
    java -cp .;sqlitejdbc-v056.jar MojoTrackConverter

    --------------------------- MojoTrackConverter.java ------------------------
    Code:
    import java.sql.*;
    import java.io.*;
    
    public class MojoTrackConverter
    {
        public static void main(String[] args) throws Exception
        {
            if (args.length < 2)
                System.out.println("Usage: MojoTrackConverter DbFile Tblname, or DbFile -l for list of tables");
            else
            {
                if (args[1].equals("-l"))
                    listTables(args[0]);
                else
                    convert(args[0], args[1]);
            }
        }
        
        private static void convert(String strDbFile, String strTable) throws Exception
        {
            FileWriter  outFile = null;
            PrintWriter out = null;
    		ResultSet   rs = null;
            
            Class.forName("org.sqlite.JDBC");
            Connection conn = DriverManager.getConnection("jdbc:sqlite:" + strDbFile);
            Statement stat = conn.createStatement();
             
    		try
            {
                outFile = new FileWriter(strTable + ".gpx");
                out = new PrintWriter(outFile);
                
                out.println("<?xml version=\"1.0\" standalone=\"yes\"?>");
                out.println("<gpx version=\"1.1\" creator=\"MojoTracker\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">");
                out.println("<trk><trkseg>");
            }
            catch (Exception e)
    	    {
                System.out.println("File Error. " + e.getMessage());
    			return;
            }
            
            try
            {
                rs = stat.executeQuery("select * from " + strTable + ";");
                while (rs.next())
    	        {
                    out.print("<trkpt lat=\"" + rs.getString("lat") + "\" ");
                    out.print("lon=\"" + rs.getString("lon") + "\">");
                    out.print("<ele>" + rs.getString("altitude") + "</ele>");
                    out.println("<time>" + rs.getString("time") + "</time></trkpt>");
                }
                out.println("</trkseg></trk>");
                out.println("</gpx>");
                System.out.println("\n--" + strTable + ".GPX created--");
    		}
    		catch(SQLException e)
    		{
                System.out.println("Database error occurred. " + e.getMessage());
    		}
    		catch(Exception e)
    		{
                System.out.println("Error occurred while converting. " + e.getMessage());
    		}
    		finally
    		{
                if (rs != null) rs.close();
                conn.close();
    	        out.close();
    		}
        }
        
        private static void listTables(String strDbFile) throws Exception
        {
            ResultSet rs;
            int       rscount = 0;
            
            Class.forName("org.sqlite.JDBC");
            Connection conn = DriverManager.getConnection("jdbc:sqlite:" + strDbFile);
            Statement stat = conn.createStatement();
            
            rs = stat.executeQuery("select tbl_name from sqlite_master where tbl_name like 'G%' order by tbl_name asc;");
    		while (rs.next())
            {
                System.out.println(rs.getString("tbl_name"));
                rscount++;
            }
            if (rscount == 0)
            {
                System.out.println("No tables found - have you supplied a correct Database file?");
            }
            rs.close();
            conn.close();
        }
    }
    --------------------------------------------------------
  3. #23  
    Thank you very much. Here is what I have so far: a tracking app without OSM connection I guess due the end of the week I might have a full functional "Track on OSM".
    If I understand you correctly you create a new table for each track? Makes it more difficult to list all tracks to the user o nthe device? I use a TrackID at the moment, which is the time-value of themoment starting the app. But I don't have something included yet to show a list of tracks to the user

    http://www.metaviewsoft.de/PUM-2009/MapTool.zip
    Check out MapTool Pro the best mapping app for all webOS devices!
    Let your kids practice their math101 Math This!
    Best image processing app for all webOS devices? Try ImageWorker Pro
  4. #24  
    Great stuff Metaview. Have just installed this, and can see that it's tracking. Agreed, it's probably best to just use one table for all tracks. Using separate tables seemed to keep it a bit tidier.

    Can't wait to see it displaying tiles from OSM!!

    One minor thing though... It doesn't seem to be generating SQLite .db files in the .appstorage folder. Maybe you have to prefix your database name with "ext:"?
  5. #25  
    hit Will change it.
    Check out MapTool Pro the best mapping app for all webOS devices!
    Let your kids practice their math101 Math This!
    Best image processing app for all webOS devices? Try ImageWorker Pro
  6. #26  
    Mojo Tracker seems to be available now:
    http://www.precentral.net/homebrew-apps/mojotracker

    Also, there is now an excellent App for displaying maps from OpenStreetMap:
    http://www.precentral.net/homebrew-apps/minimap
  7. #27  
    Hello Wonka,
    i am trying to convert the sql-db to a useable format.
    i downloaded sqlitejdbc-v056.jar, pastet your code in MojoTrackConverter.java (same directory as the jar-file) and entered java -cp .;sqlitejdbc-v056.jar MojoTrackConverter in a dos-box of Windows XP.
    I get this message:
    Exception in thread "main" java.lang.NoClassDefFoundError: MojoTrackConverter
    Caused by: java.lang.ClassNotFoundException: MojoTrackConverter
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    Any idea, what im doing wrong?
    Maybe i missed the statement "After you've compiled with JDK, run as follows"
    What do you mean with it?

    Kind regards,
    Normen
  8. #28  
    Maybe i missed the statement "After you've compiled with JDK, run as follows"
    Hi,

    You need to compile that code using the java compiler (javac.exe). This is easily done (javac MojoTrackConverter.java), but first you'll need to download the JDK from java.com.

    But in this case I'll arrange to send you the compiled module to save you any more hassle.

    If there's any real demand for this utility then I'll set up a website that will allow the DB files to be uploaded and converted to GPX.
  9. #29  
    OK, the attached zip file contains the java class for running MojoTrackConverter. It needs to be copied to the same folder as the Jar file, and DB file.
    Attached Files Attached Files
Page 2 of 2 FirstFirst 12

Posting Permissions