Skip to content

Commit 8be848b

Browse files
committed
try correct by avg of the time
1 parent 08c2650 commit 8be848b

13 files changed

+7563
-15139
lines changed

TDriveMapMatching/.idea/workspace.xml

Lines changed: 114 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TDriveMapMatching/fcd-entries-all-invalid-time-correct-by-avg-v2.csv

Lines changed: 3717 additions & 0 deletions
Large diffs are not rendered by default.

TDriveMapMatching/fcd-entries-all-invalid-time-correct-by-avg.csv

Lines changed: 3717 additions & 0 deletions
Large diffs are not rendered by default.

TDriveMapMatching/fcd-entries-invalid-time-correct-by-avg.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
taxi_id, latitude, longitude, ele, date_time, speed
1+
taxi_id, latitude, longitude, ele, date_time
22
1368, 39.95860513207179, 116.45978074058401, 0.0, 2008-02-02 15:52:24-0300
33
1368, 39.955488554138434, 116.45632273978717, 0.0, 2008-02-02 15:52:23-0300
44
1368, 39.95541199942109, 116.45624152845684, 0.0, 2008-02-02 15:52:23-0300

TDriveMapMatching/fcd-match-with-fill-gaps-date-format-speed-estimated-2.csv

Lines changed: 0 additions & 3717 deletions
This file was deleted.

TDriveMapMatching/fcd-match-with-fill-gaps-date-format.csv

Lines changed: 0 additions & 3717 deletions
This file was deleted.

TDriveMapMatching/fcd-match-with-fill-gaps.csv

Lines changed: 0 additions & 3717 deletions
This file was deleted.

TDriveMapMatching/map-matching-gpx-entries.csv

Lines changed: 0 additions & 3839 deletions
This file was deleted.

TDriveMapMatching/src/main/java/com/tdrive/App.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
package com.tdrive;
22

3-
import com.graphhopper.matching.GPXExtension;
4-
import com.graphhopper.matching.MatchResult;
53
import com.graphhopper.util.GPXEntry;
64
import com.tdrive.dao.Repository;
7-
import com.tdrive.service.EstimatedSpeedAndTime;
85
import com.tdrive.service.FCDMatcher;
96
import com.tdrive.service.TrajectoryMapMatching;
107
import com.tdrive.util.CSVWriter;
118
import com.tdrive.util.FCDEntry;
129

13-
import com.tdrive.service.EstimatedSpeedAndTime.SpeedMatch;
14-
15-
import java.sql.Date;
16-
import java.text.DateFormat;
17-
import java.text.SimpleDateFormat;
18-
import java.util.ArrayList;
1910
import java.util.List;
2011
import java.util.Map;
21-
import java.util.stream.Collectors;
2212

2313
public class App {
2414
private static final String TABLE = "taxi_graph_hopper_teste",
@@ -29,7 +19,7 @@ public static void main(String[] args) {
2919
Repository repository = new Repository();
3020
try {
3121
int limit = 140;
32-
Map<Integer, List<GPXEntry>> gpxEntries = repository.getAllEntriesAsGPX(TABLE, 30);
22+
Map<Integer, List<GPXEntry>> gpxEntries = repository.getAllEntriesAsGPX(TABLE, limit);
3323

3424
TrajectoryMapMatching mapMatching = new TrajectoryMapMatching(OSM_FILE_PATH, GHLOCATION);
3525

@@ -90,18 +80,18 @@ private static void useFCDEntries (List<GPXEntry> gpxUnmatched, TrajectoryMapMat
9080

9181
System.out.println(fcdMatch.size() + " - " + qtd + " Matched with data set");
9282

93-
9483
// double speed = fcdMatch.get(0).getSpeed();
9584

9685
// Remove gaps in FCD entries
9786
List<FCDEntry> fcdEntriesNoGaps = FCDMatcher.fillGaps(fcdMatch);
9887

88+
9989
FCDMatcher.fillInvalidTimesByAvg(fcdEntriesNoGaps);
10090

10191

10292
// Export to CSV
10393

104-
String filename = "fcd-entries-invalid-time-correct-by-avg.csv";
94+
String filename = "fcd-entries-all-invalid-time-correct-by-avg-v2.csv";
10595
CSVWriter.writerFCDEntries(filename, fcdEntriesNoGaps, 1368);
10696
}
10797

TDriveMapMatching/src/main/java/com/tdrive/service/FCDMatcher.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,13 @@ public static void fillInvalidTimes (List<FCDEntry> values) {
272272
}
273273

274274
public static void fillInvalidTimesByAvg(List<FCDEntry> values) {
275-
long time;
276-
for (int i = 0; i < values.size(); i++) {
275+
long time1, time2, avg;
276+
for (int i = 0; i < values.size() - 1; i++) {
277277
if (values.get(i).getTime() <= 0) {
278-
time = values.get(i + 1).getTime() + 1;
279-
values.get(i).setTime(time);
278+
time1 = values.get(i + 1).getTime();
279+
time2 = values.get(i - 1).getTime();
280+
avg = (time2 - time1) / 2;
281+
values.get(i).setTime(time1 + avg);
280282
}
281283
}
282284
}

0 commit comments

Comments
 (0)