Menu

Bug - WaypointFile.write(String filename)?

Help
Sven-Ove
2012-01-21
2013-02-01
  • Sven-Ove

    Sven-Ove - 2012-01-21

    public static void main(String[] args) throws OziException {
            WaypointFile wpFile = new WaypointFile();
            wpFile.write("C:/temp/ozitest/WP.wpt");
            OziAPI.saveWaypointFlag(true);
        }

    Gives a file with the following contents:

    OziExplorer Waypoint File Version 1.1
    null
    Reserved 0
    null

    The WaypointFile.read(String filename) on a "valid" WPT-file is working as exptected.
    Any idea what could be wrong, or if it's a bug in the API?

     
  • Alan Burlison

    Alan Burlison - 2012-01-21

    Trying to write a waypoint file without any waypoints in it is the problem.

     
  • Sven-Ove

    Sven-Ove - 2012-01-21

    What I do:
    1. Start OziExplorer
    2. Add a few waypoints
    3. Start the Java-app, which then is supposed to save all waypoints to file, which isn't working…

    Am I misunderstanding what the Waypoint.write()-function should do?
    I thought it took all exisiting WP and saved it to a file, or am I wrong?

     
  • Alan Burlison

    Alan Burlison - 2012-01-21

    As I said in my previous reply you need to read and understand the original OziExporer API documentation - the Java interface can't provide facilities that aren't provided by the C API, and unfortunately the C API provides no way of iterating over the waypoints currently displayed on the map so there's no mechanism by which the WaypointFile could be automatically populated with the current set of dsiplayed waypoints. All the operations which communicate directly with OziExplorer are the ones in the http://oziapi-java.sourceforge.net/javadoc/oziapi/com/oziexplorer/OziAPI.html class.

    The WaypointFile is a pure-Java convenience class to allow you to read/write Waypoints from an OziExplorer file so you can manipulate them in your program. For example you could read in waypoints from a file using the WaypointFile class and then filter them and display selected ones using OziAPI.addWaypoint(), or you could load the entire file in using OziAPI.loadWaypointFile().

    I have noticed that for some unknown reason the OziAPI oziSaveWPfile function hasn't ended up in the Java interface in the OziAPI class, I'll fix that shortly, the new method will be OziAPI.saveWaypointFile. Once that's available if you wanted to get all the currently displayed waypoints you'd have to save all the waypoints using OziAPI.saveWaypointFie and then read them back in using the WaypointFile class.

     
  • Sven-Ove

    Sven-Ove - 2012-01-21

    The oziSaveWPfile was added in API v1.09, so that's probably why it has been forgotten in the Java API? :)
    Sounds like there will be a solutions for my problem after all then - great! :D

    Thanks a lot for a great API - as Ozi itself didn't have any java-support, I was really glad to find yours! :)

     
  • Alan Burlison

    Alan Burlison - 2012-01-22

    I've added in support for OziAPI.saveWaypointFile, release 0.6 is available from the website.

    Glad to see someone is using the library :-)

     
  • Sven-Ove

    Sven-Ove - 2012-01-22

    Great, I'll give that a try! :)

    We use OziExplorer in our Search&Rescue-operations and want to create a "multi-user" Ozi, so that the tactical-leader (creating each assignment for the searchteams in Ozi) and the communications-officer could have the same map-display on two computers. :)

    So I'm adding a autosave of tracks and WP on a given interval to do this. :)

     
  • Sven-Ove

    Sven-Ove - 2012-01-22

    I downloaded 0.6 now, and replaced the method with the new OziAPI.saveWaypointFile(), but I get an error:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: com.oziexplorer.OziAPI.saveWaypointFile(Ljava/lang/String;)V
    at com.oziexplorer.OziAPI.saveWaypointFile(Native Method)
    at Test.main(Test.java:19)
    Java Result: 1

    All I do i:

    public static void main(String[] args) throws OziException {
        OziAPI.saveWaypointFile("C:/temp/ozitest/WP.wpt");
    }
    

    Any idea?

     
  • Alan Burlison

    Alan Burlison - 2012-01-22

    I used to be in a mountain rescue team myself, although I now content myself being a voluntary national park ranger :-)

    Make sure you copied in all the bits into your build workspace, as well as the JAR file you also need the DLL that contains the Java-OziAPI bridge.

     
  • Sven-Ove

    Sven-Ove - 2012-01-22

    I copied the DLL's again and suddenly it started working!
    Strange, but I don't care as long as it works… ;)

    Out of curiocity, how's the mountain rescue organized in England (that's where you're from, right?)?

    Here in Norway, it's based on voulenteeres, Red Cross, Rescuedogs, etc.
    Just got the stats for the Red Cross for 2011:
    * 952 operations
    * 1.613 people assisted
    * 10.617 voulenteer search-personell
    * 52.040 hours spent

    And this in a country with about 5 million people! :)

     
  • Alan Burlison

    Alan Burlison - 2012-01-22

    Yes, I'm in the UK.  MR is voluntary here in the UK.  There's one organisation for England and Wales, and another for Scotland.  Websites with more info: http://www.mountain.rescue.org.uk/ http://www.mrcofs.org/  The organisation I'm part of is http://www.peakdistrict.gov.uk/looking-after/rangers - our 1437 square km national park gets more than 8 million visitors each year :-)

     
  • Sven-Ove

    Sven-Ove - 2012-01-22

    Sound interesting!
    Wow, you have more visitors to your national parks than we have citizens! :O

    Btw, if I don't specify that I want to run my project with 32-bits java, I get an exception:
    "Can't load IA 32-bit .dll on a AMD 64-bit platform"

    Is this due to the OziAPI.dll not being 64-bit, or does it have anything to do with the Java-API?

    It's not a big problem, but it does cause the java-program I'm making to fail to start if started with a doubleclick on the JAR-file and having to start it from cmd with a full path to the 32-bit java.exe instead… :-/

     
  • Alan Burlison

    Alan Burlison - 2012-01-23

    It's because the underlying OziAPI DLL is 32 bit (AFAIK OziExplorer is 32-bit as well).  That means the JNI DLL also has to be 32-bit, which means in turn you need to run Java in 32-bit mode.  There's a command-line flag you can use to specify Java should run in 32-bit which is "-d32".  It should be easy enough to make a PIF file that does that,

     
  • Sven-Ove

    Sven-Ove - 2012-01-23

    The "-d32"-parameter doesn't work on Windows:

    Error: This Java instance does not support a 32-bit JVM.
    Please install the desired version.

    It does seem though, that if a 32-bit java is installed, it's always located in "c:\Program Files (x86)\Java\jre6" (or jre7) and "c:\windows\syswow64".

    So I probably could make a bat-file that does some checking of java.exe-existance and launching the jar-file. :)

     

Log in to post a comment.