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

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        GROUPS => { 2 => 'Location' },
#
# 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{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 8, 14)));
                return undef unless $val =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/;
                return "$1:$2:$3 $4:$5:$6";
            },
            PrintConv => '$self->ConvertDateTime($val)',
        },
        GPSLatitude => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 38, 9)));
                return undef unless $val =~ /^([NS])(\d{2})(\d+$)$/;
                return ($2 + $3 / 600000) * ($1 eq 'S' ? -1 : 1);
            },
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
        },
        GPSLongitude => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 47, 10)));
                return undef unless $val =~ /^([EW])(\d{3})(\d+$)$/;
                return ($2 + $3 / 600000) * ($1 eq 'W' ? -1 : 1);
            },
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
        },
        GPSSpeed => {
            SubDoc => 1,
            Require => 'Text',
            RawConv => q{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 62, 3)));
                return undef unless $val =~ /^\d+$/;
                return $val + 0;
            },
        },
        Accelerometer => {
            SubDoc => 1,
            Require => 'Text',
            Notes => q{
                the first X,Y,Z accelerometer readings from the AccelerometerData, stored in
                text format
            },
            RawConv => q{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 0xad, 12)));
                return undef unless $val =~ /^([-+]\d{3})([-+]\d{3})([-+]\d{3})$/;
                return "$1 $2 $3";
            },
        },
        AccelerometerData => {
            SubDoc => 1,
            Require => 'Text',
            Notes => q{
                24 values in 6 groups of 4 values each.  For each group, the first value is
                zero and the next 3 are the X,Y,Z components of acceleration.  The first 5
                groups are likely samples taken at 5 Hz.  The last group often has zero
                entries, and its meaning is unknown
            },
            RawConv => q{
                $val = pack('C*', map { $_ ^ 0xaa } unpack('C*', substr($val[0], 0xba, 96)));
                my $order = GetByteOrder();
                SetByteOrder('II');
                $val = ReadValue(\$val, 0, 'float');
                SetByteOrder($order);
                return $val;
            },
        }            
    },
);

1;  #end
