Ticket Created

WERETECH-8118

Sim issue with saveWaypoints

In the sim using 3.1.5, the following sometimes doesn't work.

Toybox.PersistedContent.saveWaypoint(location, {:name => name});

It works fine in the device (a real 1030).

  • It looks like saveWaypoint() always adds the waypoint, creating a new name if the name is already used.

    saveWaypoint() should return the new waypoint with the updated name.

  • That's what I do in the code (I provide an option to exist as an intent).

    function getLocation(name)
    {
    if(appbase.hasStorage)
    {
    if (PersistedContent has :getWaypoints)
    {
    name = name.substring(0, iNameLength);

    var cit = PersistedContent.getWaypoints();
    while (cit != null)
    {
    var waypoint = cit.next();
    if (waypoint == null)
    {
    break;
    }
    if(waypoint.getName().equals(name))
    {
    return waypoint;
    }
    }
    }
    }
    return null;
    }

  • If it was saving, you'd be able to find it in the waypoints collection. It doesn't find it in the sim (but does in the real device).

  • Both. It's a different coordinates and in another place in the code.

    function addLocation(itemLocation)
    {
    var name = itemLocation["name"];
    var lat = itemLocation["lat"];
    var lon = itemLocation["lon"];

    try
    {
    System.println("Downloaded location: "+name.toString()+" "+lat.toString()+","+lon.toString());

    var location = new Position.Location({:latitude => lat.toFloat(), :longitude => lon.toFloat(), :format => :degrees});

    var track = getCurrentTrack(false);

    if (track != null && track instanceof TrackObj)
    {
    if(track.isource.equals(:frompluscode) || track.isource.equals(:fromsendpoints))
    {
    name = "+ "+name;
    }
    }

    if (Toybox has :PersistedContent)
    {
    Toybox.PersistedContent.saveWaypoint(location, {:name => name});
    }

    courseLoadedLast = getLocation(name);

    itypeLoadedLast = :type_loc;

    if (track != null && track instanceof TrackObj)
    {
    var bEncode = false;
    if(track.isource.equals(:frompluscode))
    {
    track.details = "Plus Code location";
    }
    else if(track.isource.equals(:fromsendpoints))
    {
    track.details = "Sendpoints location";
    bEncode = true;
    }

    track.file_type = :type_waypoint;

    track.title = name;
    track.coursename = name;
    track.lat = lat;
    track.lon = lon;

    track.details += " "+track.title + ".";

    if(bEncode)
    {
    track.details += " "+OLCObj.encodeOLC(lat.toFloat(), lon.toFloat());
    }

    track.distanceFrom(appbase.latCurrent, appbase.lonCurrent, unitsDistance);

    if(track.web.equals(""))
    {
    track.web = ""%.8f")+","+track.lon.toDouble().format("%.8f");">maps.google.com
    }

    track.distanceFrom(appbase.latCurrent, appbase.lonCurrent, unitsDistance);

    addCourse(track);
    }
    }
    catch (ex)
    {
    System.println(ex.getErrorMessage());
    appbase.strStatus = "Download "+name+" failed";
    }
    }

  • This is what I have at this point to test that the Waypoints are being sucessfully saved. Is this a valid case to cover the bug we are discussing?
    To make this easier I clear %TEMP%/Garmin so I always see only the 1 waypoint.

                var location = new Position.Location({:latitude => 39.737306, :longitude => -104.990852, :format => :degrees});
                System.println("Hit A");
                PersistedContent.saveWaypoint(location, {:name => "Denver"});
                
                var wpIterator = PersistedContent.getWaypoints();
                System.println("");
    
                var wp = wpIterator.next();
                while (wp != null) {
                    System.println(wp.getId());
                    System.println(wp.getName());
                    wp.remove();
                    wp = wpIterator.next();
                }