ExifReader icon indicating copy to clipboard operation
ExifReader copied to clipboard

exif-reader.d.ts's NumberArrayTag type for GPSLatitude & GPSLongitude should be number[][] rather than number[]

Open alee8 opened this issue 10 months ago • 1 comments

Description

Exif's GPSLatitude & GPSLongitude type definition should be number[][] rather than number[].

getCalculatedGpsValue expects each of its first 3 function parameters (degrees, minutes, seconds) to be a number[]. Each parameter is based on value[0], value[1], and value[2] of GPSLatitude & GPSLongitude. Thus the value prop has a type of number[][].

Additional details

  • ExifReader version: 4.21.1
  • Web browser and version: chrome Version 123.0.6312.107 (Official Build) (arm64)
  • Node version: N/A
  • Can you reproduce the bug on the examples site? N/A
    • I was trying to replicate the computation of the latitude and longitude based on GPSLatitude/GPSLongitude & GPSLatitudeRef/GPSLongitudeRef. The same computation that ExifReader's getCalculatedGpsValue performs. https://mattiasw.github.io/ExifReader/

How to reproduce

  1. Read the tags from an Android photo using the example site's ES module

  2. Take the tags' GPSLatitude/GPSLongitude and pass it to a typescripted function akin to getCalculatedGpsValue such as gpsDMSToFloat(latLng: NumberArrayTag, latLngRef: StringArrayTag)

    function gpsDMSToFloat(latLng: NumberArrayTag, latLngRef: StringArrayTag) {
       const latLngDeg = latLng.value[0];
       const latLngMin = latLng.value[1];
       const latLngSec = llatLng.value[2];
       return (latLngDeg[0] / latLngDeg[1]) + (latLngMin[0] / latLngMin[1]) / 60 + (latLngSec[0] / latLngSec[1]) / 3600;
    }
    
  3. Typescript error regarding latLngDeg, latLngMin, latLngSec

What I expected would happen:

No typescript error associated with accessing value of GPSLatitude/GPSLongitude in the manner shown above.

What really happened:

Typescript error regarding latLngDeg, latLngMin, latLngSec

Example JPEG image

PXL_20240221_210408399 NIGHT

alee8 avatar Apr 06 '24 20:04 alee8