Ticket Created
over 5 years ago

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).

  • So, what I'm doing now is getting a list of matching locations (using the name as a prefix).

    Then, I look through the list to find the new location.

    The following is output from the real 1030.

    The name added is "wpt000 5" but it's reading it as "wpt000 2",

    aaa: Obj: 403 wpt000 2
    aaa: Obj: 402 wpt000 3
    aaa: Obj: 404 wpt000 1
    aaa: Obj: 405 wpt000
    aaa: Obj: 407 wpt000 4

    bbb: Obj: 408 wpt000 2

    ccc: Obj: 408 wpt000 2

    Added location: wpt000 [wpt000 2] 40.8342168,-74.1917787

    ======================

    The function (first call builds the list; second call uses the list).

    function getMatchingLocations(name, larray)
    {
    var bGetLocations = false;
    if(larray == null)
    {
    bGetLocations = true;
    larray = [];
    }

    if (!appbase.hasWaypoints)
    {
    return null;
    }

    name = name.substring(0, iNameLength);

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

    if(startsWith(waypoint.getName(), name))
    {
    if(bGetLocations)
    {
    System.println("aaa: "+waypoint.toString()+" "+waypoint.getName());
    larray.add(waypoint);
    }
    else
    {
    var bNew = true;

    System.println("bbb: "+waypoint.toString()+" "+waypoint.getName());

    for(var index1 = 0; index1 < larray.size(); index1++)
    {
    if(waypoint.equals(larray[index1]))
    {
    bNew = false;
    }
    }

    if(bNew)
    {
    System.println("ccc: "+waypoint.toString()+" "+waypoint.getName());
    return waypoint;
    }
    }
    }
    }

    if(bGetLocations)
    {
    return larray;
    }

    return null;
    }

  • function getMatchingLocations(name, larray) { var bGetLocations = false; if(larray == null) { bGetLocations = true; larray = []; } if (!appbase.hasWaypoints) { return null; } name = name.substring(0, iNameLength); var cit = PersistedContent.getWaypoints(); while (cit != null) { var waypoint = cit.next(); if (waypoint == null) { break; } if(startsWith(waypoint.getName(), name)) { if(bGetLocations) { System.println("aaa: "+waypoint.toString()+" "+waypoint.getName()); larray.add(waypoint); } else { var bNew = true; System.println("bbb: "+waypoint.toString()+" "+waypoint.getName()); for(var index1 = 0; index1 < larray.size(); index1++) { if(waypoint.equals(larray[index1])) { bNew = false; } } if(bNew) { System.println("ccc: "+waypoint.toString()+" "+waypoint.getName()); return waypoint; } } } } if(bGetLocations) { return larray; } return null; }

  • To delete the simulator's storage, you can delete the temporary Garmin folder which can be found at:

    Windows:
    Navigate to the %TEMP% directory and delete the "GARMIN" folder.

    Mac:
    Navigate to $TMPDIR directory and delete the "GARMIN" folder.

    For both, it will automatically be re-made when you run the simulator again.

  • It wound be "NameA 1" for the second one.

    The sim doesn't add the number.

    (I have to figure out how to flush the old data from the sim. I don't have "Clear Persistent Storage" enabled.)

  • So you're saying that 

    PersistedContent.saveWaypoint(location, {:name => "NameA"});
    PersistedContent.saveWaypoint(location, {:name => "NameB"});
    PersistedContent.saveWaypoint(location, {:name => "NameA"});
    

    On device would give you

    Waypoints:
    NameA
    NameA(2)
    NameB

    while simulator would give:

    Waypoints:
    NameA
    NameB