Skip to content

Commit

Permalink
Suunto empty distance hole fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksVasilev committed Oct 31, 2021
1 parent 8743549 commit eb74e7b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 25 additions & 11 deletions src/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ int run() { // Основной поэтапный цикл работы кон
int readStatus = this.read(); // read file to buffer
if(readStatus !=0) {return readStatus;}

int fixstatus = this.fix(); // try to fix data in non corrupted file
if(fixstatus !=0) {return fixstatus;}
int fixstatus = this.fix(); // try to fix data in non corrupted file
if(fixstatus !=0) {return fixstatus;}

if(OUT == Out.DATABASE) {

Expand Down Expand Up @@ -289,14 +289,21 @@ private int fix() { // fix various error and hole in data (#1, #13,
}
}

/* if(last_dist.equals(prev_dist) && speed != 0.0) {
row1.put("speed",String.valueOf(0.0));
row1.put("enhanced_speed",String.valueOf(0.0));
row1.put("fixed",append(row1.get("fixed"),"speed-to-zero,"));
speed = 0.0;
}
*/
prev_date = date;

if (row1.containsKey("position_lat") && row1.containsKey("position_long")) { // Fix 01-Bryton-hole-ele/Bryton-hole-coord - Bryton hole fix
last_lat = row1.get("position_lat");
last_lon = row1.get("position_long");

EmptyTrack = false;
} else if (!last_lat.equals("") && !last_lon.equals("") && speed == 0.0 && (last_dist.equals(prev_dist))) { // fix (01) only if distance not incremended

} else if (!last_lat.equals("") && !last_lon.equals("") && (last_dist.equals(prev_dist))) { // fix (01) only if distance not incremended
row1.put("position_lat", last_lat);
row1.put("position_long", last_lon);
row1.put("fixed",append(row1.get("fixed"),"Bryton-hole-coord,"));
Expand Down Expand Up @@ -352,7 +359,7 @@ private int fix() { // fix various error and hole in data (#1, #13,
row3.put("altitude",ele);
row3.put("fixed",append(row3.get("fixed"),"Bryton-start-ele,"));

Buffer.put(map03b_i.getKey(), new HashMap<>() { { row3.forEach(this::put); } }); // write change to buffer
Buffer.put(map03b_i.getKey(), new HashMap<>() { { this.putAll(row3); } }); // write change to buffer
row3.clear();
} else {
break;
Expand All @@ -376,13 +383,15 @@ private int fix() { // fix various error and hole in data (#1, #13,
String start;
String end;

if(row0.get("position_lat") != null && row0.get("position_long") != null && row0.get("distance") != null) {
last_lat_d = checkD(row0.get("position_lat"));
last_lon_d = checkD(row0.get("position_long"));
last_dist = checkD(row0.get("distance"));
if(row0.get("position_lat") != null && row0.get("position_long") != null) {
if(row0.get("distance") != null) {
last_lat_d = checkD(row0.get("position_lat"));
last_lon_d = checkD(row0.get("position_long"));
last_dist = checkD(row0.get("distance"));
}
}

if(row0.get("position_lat") == null && row0.get("position_long") == null) { // Search for first entry fith empty coordinates
if(row0.get("position_lat") == null && row0.get("position_long") == null) { // Search for first entry with empty coordinates
start = m.getKey();

ArrayList<Double> dist_steps = new ArrayList<>();
Expand All @@ -394,6 +403,8 @@ private int fix() { // fix various error and hole in data (#1, #13,
Double d = Double.parseDouble(row00.get("distance"));
dist_steps.add(d - last_dist);
} catch (Exception ignore) { }
} else {
dist_steps.add(0.0);
}

if(row00.get("distance") != null) {
Expand All @@ -419,8 +430,11 @@ private int fix() { // fix various error and hole in data (#1, #13,
row_insert.put("position_lat", String.valueOf(step_lat));
row_insert.put("position_long", String.valueOf(step_lon));
row_insert.put("fixed",append(row_insert.get("fixed"),"Swim-no-coord,"));
if(row_insert.get("distance") == null) {
row_insert.put("distance", String.valueOf(last_dist));
}

Buffer.put(insert.getKey(), new HashMap<>() { { row_insert.forEach(this::put); } }); // write change to buffer
Buffer.put(insert.getKey(), new HashMap<>() { { this.putAll(row_insert); } }); // write change to buffer
row_insert.clear();
st++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/fit2gpx.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class fit2gpx extends Component {

static final String _version_ = "0.1.15";
static final String _version_ = "0.1.17";

static ResourceBundle tr = ResourceBundle.getBundle("locale/tr", Locale.getDefault());
static ArrayList<Mode> WorkMODE = new ArrayList<>();
Expand Down

0 comments on commit eb74e7b

Please sign in to comment.