Skip to content

Commit

Permalink
Trim the waypoints before adding them
Browse files Browse the repository at this point in the history
  • Loading branch information
michieltjampens committed Nov 4, 2024
1 parent fd68c05 commit f380d2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/gis/Waypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public Waypoints(Path settingsPath, ScheduledExecutorService scheduler, Realtime
public Waypoint addWaypoint( String id, Waypoint wp ) {
if(wp.hasTravelCmd()&&checkTravel==null)
checkTravel = scheduler.scheduleAtFixedRate(this::checkWaypoints,5, CHECK_INTERVAL, TimeUnit.SECONDS);
Logger.info("Adding waypoint: "+id);
wps.put(id,wp);
Logger.info("Adding waypoint: <"+id+">");
wps.put(id.trim(),wp);
return wp;
}
public void addWaypoint( String id, double lat, double lon, double range) {
wps.put( id, Waypoint.build(id).lat(lat).lon(lon).range(range) );
wps.put( id.trim(), Waypoint.build(id).lat(lat).lon(lon).range(range) );
}
public Collection<Waypoint> items(){
return wps.values();
Expand Down Expand Up @@ -311,7 +311,7 @@ public Waypoint getWaypoint( String id, String name, boolean createIfNew ) {
var wp = wps.get(id);
if (wp == null){
if (createIfNew) {
wps.put(id, new Waypoint(name));
wps.put(id, new Waypoint(name.trim()));
return wps.get(id);
}
Logger.error("No such waypoint "+id+" in list: "+String.join(",", wps.keySet())+".");
Expand Down

0 comments on commit f380d2b

Please sign in to comment.