-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #646 from afischerdev/engine-mode
Update for new output logic
- Loading branch information
Showing
12 changed files
with
1,162 additions
and
948 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package btools.router; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.StringWriter; | ||
|
||
public class FormatCsv extends Formatter { | ||
|
||
|
||
public FormatCsv(RoutingContext rc) { | ||
super(rc); | ||
} | ||
|
||
@Override | ||
public String format(OsmTrack t) { | ||
try { | ||
StringWriter sw = new StringWriter(); | ||
BufferedWriter bw = new BufferedWriter(sw); | ||
writeMessages(bw, t); | ||
return sw.toString(); | ||
} catch (Exception ex) { | ||
return "Error: " + ex.getMessage(); | ||
} | ||
} | ||
|
||
public void writeMessages(BufferedWriter bw, OsmTrack t) throws Exception { | ||
dumpLine(bw, MESSAGES_HEADER); | ||
for (String m : t.aggregateMessages()) { | ||
dumpLine(bw, m); | ||
} | ||
if (bw != null) | ||
bw.close(); | ||
} | ||
|
||
private void dumpLine(BufferedWriter bw, String s) throws Exception { | ||
if (bw == null) { | ||
System.out.println(s); | ||
} else { | ||
bw.write(s); | ||
bw.write("\n"); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.