#------------------------------------------------------------------------------
# File:         nksc.config
#
# Description:  This config file contains tag definitions to extract metadata
#               from RDF/XML-based Nikon ViewNX NKSC sidecar files
#
# Usage:        exiftool -config nksc.config -ext nksc DIR
#
# Requires:     ExifTool version 11.38 or later
#
# Revisions:    2019/04/24 - P. Harvey Created
#------------------------------------------------------------------------------

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::Main' => {
        ast => {
            SubDirectory => { TagTable => 'Image::ExifTool::UserDefined::ast' },
        },
        sdc => {
            SubDirectory => { TagTable => 'Image::ExifTool::UserDefined::sdc' },
        },
        nine => {
            SubDirectory => { TagTable => 'Image::ExifTool::UserDefined::nine' },
        },
    },
    'Image::ExifTool::Composite' => {
        GPSLatitude => {
            Require => {
                0 => 'XMP-ast:GPSLatitude',
                1 => 'XMP-ast:GPSLatitudeRef',
            },
            ValueConv => '$prt[1] =~ /^S/i ? -$val[0] : $val[0]',
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
        },
        GPSLongitude => {
            Require => {
                0 => 'XMP-ast:GPSLongitude',
                1 => 'XMP-ast:GPSLongitudeRef',
            },
            ValueConv => '$prt[1] =~ /^W/i ? -$val[0] : $val[0]',
            PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
        },
    },
);

%Image::ExifTool::UserDefined::ast = (
    GROUPS        => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Location' },
    NAMESPACE     => { 'ast' => 'http://ns.nikon.com/asteroid/1.0/' },
    about   => { Groups => { 2 => 'Image' } },
    version => { Groups => { 2 => 'Image' } },
    GPSVersionID => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            ReadValue($valPt, 0, 'int8u', 4, length($$valPt));
        },
        PrintConv => '$val =~ tr/ /./; $val',
    },
    GPSLatitude => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            $val = ReadValue($valPt, 0, 'double', 3, length($$valPt));
            Image::ExifTool::GPS::ToDegrees($val);
        },
        PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val)',
    },
    GPSLatitudeRef => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            ReadValue($valPt, 0, 'int32u', 3, length($$valPt));
        },
        PrintConv => { 0 => 'North', 1 => 'South' },
    },
    GPSLongitude => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            $val = ReadValue($valPt, 0, 'double', 3, length($$valPt));
            Image::ExifTool::GPS::ToDegrees($val);
        },
        PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val)',
    },
    GPSLongitudeRef => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            ReadValue($valPt, 0, 'int32u', 3, length($$valPt));
        },
        PrintConv => { 2 => 'East', 3 => 'West' },
    },
    GPSAltitude => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            SetByteOrder('II');
            ReadValue($valPt, 0, 'double');
        },
        PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
    },
    GPSAltitudeRef => {
        ValueConv => q{
            my $valPt = Image::ExifTool::XMP::DecodeBase64($val);
            ReadValue($valPt, 0, 'int8u');
        },
        PrintConv => {
            0 => 'Above Sea Level',
            1 => 'Below Sea Level',
        },
    },
    GPSMapDatum => { },
    XMLPackets => {
        Name => 'XMP',
        Groups => { 2 => 'Image' },
        RawConv => 'Image::ExifTool::XMP::DecodeBase64($val)',
        SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
    },
    IPTC => {
        Name => 'IPTC',
        Groups => { 2 => 'Image' },
        RawConv => 'Image::ExifTool::XMP::DecodeBase64($val)',
        SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
    },
);

%Image::ExifTool::UserDefined::sdc = (
    GROUPS        => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
    NAMESPACE     => { 'sdc' => 'http://ns.nikon.com/sdc/1.0/' },
    about   => { },
    version => { },
    appversion => { },
    appname => { },
);

%Image::ExifTool::UserDefined::nine = (
    GROUPS        => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
    NAMESPACE     => { 'nine' => 'http://ns.nikon.com/nine/1.0/' },
    about   => { },
    version => { },
    NineEdits => { Binary => 1 },
    Label   => { },
    Rating  => { },
    Trim    => { ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' },
);

1;  #end
