Skip to content

Instantly share code, notes, and snippets.

@tatesuke
Created March 16, 2020 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatesuke/794d2abfabb30a3a286a5d654de6ecb7 to your computer and use it in GitHub Desktop.
Save tatesuke/794d2abfabb30a3a286a5d654de6ecb7 to your computer and use it in GitHub Desktop.
contour gpsの動画からnmeaを抜き出す
> contour gpsの動画からnmeaを抜き出す
>
> usage : groovy extractNmea.groovy INPUT_FILE_PATH
> output : カレントディレクトリに「拡張子抜きのファイル名」.nmeaが出力される。
def filePath = args[0];
def file = new File(filePath);
def fileName = file.getName()
def outFileName = "out/" + fileName.substring(0, fileName.lastIndexOf(".")) + ".nmea"
def br, out;
try {
br = new BufferedReader(new FileReader(file));
out = new PrintWriter(new FileWriter(outFileName))
def line;
while ((line = br.readLine()) != null) {
def i = line.indexOf('$GPGGA');
if (i == -1) {
i = line.indexOf('$GPRMC');
}
if (i == -1) {
continue;
}
def nmeaLine = line.substring(i);
out.println(nmeaLine);
}
} finally {
br.close();
out.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment