#------------------------------------------------------------------------------
# File:         mini0806.config
#
# Description:  This config file defines Composite tags to convert embedded
#               metadata in Mini 0806 dashcam videos
#
# Usage:        exiftool -config mini0806.config -ee FILE
#
#               Example command to create .gpx log file from Mini 0806 video
#               (requires gpx.fmt available in the full Exiftool distribution):
#
#               exiftool -config mini0806.config -p gpx.fmt -ee FILE
#
# Requires:     ExifTool version 10.75 or later
#
# Revisions:    2019/05/28 - P. Harvey Created
#------------------------------------------------------------------------------

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        GROUPS => { 2 => 'Location' },
#
# Example embedded "Text" from a Mini 0806 MOV video:
#
#   "A,270519,201555.000,3356.8925,N,08420.2071,W,000.0,331.0M,+01.84,-09.80,-00.61;\n"
#
# Note: SubDoc flag is set for all these tags so they will be generated for
#       all embedded documents
#
        GPSDateTime => {
            Description => 'GPS Date/Time',
            Groups => { 2 => 'Time' },
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                if ($val[0] =~ /^A,(\d{2})(\d{2})(\d{2}),(\d{2})(\d{2})(\d{2}(\.\d+)?)/) {
                    return "20$3:$2:$1 $4:$5:$6Z";
                } else {
                    return undef;
                }
            },
            PrintConv => '$self->ConvertDateTime($val)',
        },
        GPSLatitude => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                if ($val[0] =~ /^A,.*?,.*?,(\d{2})(\d+\.\d+),([NS])/) {
                    return ($1 + $2/60) * ($3 eq 'S' ? -1 : 1);
                } else {
                    return undef;
                }
            },
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
        },
        GPSLongitude => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                if ($val[0] =~ /^A,.*?,.*?,.*?,.*?,(\d{3})(\d+\.\d+),([EW])/) {
                    return ($1 + $2/60) * ($3 eq 'W' ? -1 : 1);
                } else {
                    return undef;
                }
            },
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
        },
        GPSAltitude => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                my @a = split ',', $val[0];
                return undef unless $a[0] eq 'A' and $a[8] =~ s/M$//;
                return $a[8];
            },
            PrintConv => '"$val m"',
        },
        GPSSpeed => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                my @a = split ',', $val[0];
                return undef unless $a[0] eq 'A' and $a[7] =~ /^\d+\.\d+$/;
                return $a[7]; # (NC)
            },
        },
        Accelerometer => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                my @a = split ',', $val[0];
                return undef unless $a[11] =~ s/;\s*$//;
                return "$a[9] $a[10] $a[11]";
            },
        },
    },
);

1;  #end
