diff --git a/doc/gpscorrelate-manpage.xml.in b/doc/gpscorrelate-manpage.xml.in index 1eb2b06..5436e13 100644 --- a/doc/gpscorrelate-manpage.xml.in +++ b/doc/gpscorrelate-manpage.xml.in @@ -499,6 +499,9 @@ inaccurate at slow speeds. Use your knowledge of the recording application to determine how much faith you can place in the resulting tags. + If this is used with instead of with + , then a fixed heading of 0 is written. + @@ -554,6 +557,9 @@ applies along the entire track, it's only generally useful when the camera is fixed in the vehicle during the trip. + This may be used with in which case + the argument is used as the camera direction without alteration. + diff --git a/latlong.c b/latlong.c index a59c64f..27d4103 100644 --- a/latlong.c +++ b/latlong.c @@ -252,7 +252,8 @@ int ParseLatLong(const char *latlongstr, struct GPSPoint* point) } /* Make a track from a single point */ -int MakeTrackFromLatLong(const struct GPSPoint* latlong, struct GPSTrack* track) +int MakeTrackFromLatLong(const struct GPSPoint* latlong, int direction, + struct GPSTrack* track) { struct GPSPoint* p1 = NewGPSPoint(); struct GPSPoint* p2 = NewGPSPoint(); @@ -262,10 +263,18 @@ int MakeTrackFromLatLong(const struct GPSPoint* latlong, struct GPSTrack* track) return 0; } memcpy(p1, latlong, sizeof(*p1)); + if (direction >= 0) { + p1->Heading = direction; + p1->MoveHeading = 0; + } p1->Time = track->MinTime = 0; p1->Next = p2; memcpy(p2, latlong, sizeof(*p2)); + if (direction >= 0) { + p2->Heading = direction; + p2->MoveHeading = 0; + } p2->Time = track->MaxTime = INT_MAX; p2->Next = NULL; p2->EndOfSegment = 1; diff --git a/latlong.h b/latlong.h index ffd9ebc..3031ad0 100644 --- a/latlong.h +++ b/latlong.h @@ -2,6 +2,6 @@ struct GPSPoint *NewGPSPoint(void); int ParseLatLong(const char *latlongstr, struct GPSPoint* point); -int MakeTrackFromLatLong(const struct GPSPoint* latlong, struct GPSTrack* track); +int MakeTrackFromLatLong(const struct GPSPoint* latlong, int direction, struct GPSTrack* track); int NumDecimals(const char *Decimal); diff --git a/main-command.c b/main-command.c index 1bc5e11..258b5fb 100644 --- a/main-command.c +++ b/main-command.c @@ -466,23 +466,6 @@ int main(int argc, char** argv) fprintf(stderr, _("Error parsing location.\n")); exit(EXIT_FAILURE); } - if (!MakeTrackFromLatLong(LatLong, &Track[NumTracks])) - { - fprintf(stderr, _("Out of memory.\n")); - exit(EXIT_FAILURE); - } - free(LatLong); - LatLong = NULL; - - /* Make room for a new end-of-array entry */ - ++NumTracks; - Track = (struct GPSTrack*) realloc(Track, sizeof(*Track)*(NumTracks+1)); - if (!Track) - { - fprintf(stderr, _("Out of memory.\n")); - exit(EXIT_FAILURE); - } - memset(&Track[NumTracks], 0, sizeof(*Track)); break; case 'z': @@ -633,6 +616,27 @@ int main(int argc, char** argv) break; } /* End switch(c) */ } /* End While(1) */ + + /* Create a fake track if a position was manually given */ + if (LatLong) { + if (!MakeTrackFromLatLong(LatLong, HeadingOffset, &Track[NumTracks])) + { + fprintf(stderr, _("Out of memory.\n")); + exit(EXIT_FAILURE); + } + free(LatLong); + LatLong = NULL; + + /* Make room for a new end-of-array entry */ + ++NumTracks; + Track = (struct GPSTrack*) realloc(Track, sizeof(*Track)*(NumTracks+1)); + if (!Track) + { + fprintf(stderr, _("Out of memory.\n")); + exit(EXIT_FAILURE); + } + memset(&Track[NumTracks], 0, sizeof(*Track)); + } /* Check to see if the user passed some files to work with. Not much * good if they didn't. */ diff --git a/tests/data/test171.param b/tests/data/test171.param new file mode 100644 index 0000000..4492d78 --- /dev/null +++ b/tests/data/test171.param @@ -0,0 +1,6 @@ +TITLE='Geotag a file from a specified location with direction' +PRECOMMAND='cat "$STAGINGDIR/point1-1.jpg" >"$LOGDIR/test.jpg"' +# Run in C locale to correctly parse these decimal numbers +COMMAND='env LC_ALL=C $PROGRAM -z+1 -l 12.34567,-123.456,78.9 --direction 321 "$LOGDIR/test.jpg" > "$OUTFILE" 2>&1 && exiv2 -pv pr "$LOGDIR/test.jpg" >> "$OUTFILE" 2>&1' +POSTCOMMAND='rm -f "$LOGDIR/test.jpg"' +RESULTCODE=0 diff --git a/tests/data/test171.result b/tests/data/test171.result new file mode 100644 index 0000000..0be93ca --- /dev/null +++ b/tests/data/test171.result @@ -0,0 +1,36 @@ +Legend: . = Ok, / = Interpolated, < = Rounded, - = No match, ^ = Too far + w = Write Fail, ? = No EXIF date, ! = GPS already present + +Correlate: / + +Completed correlation process. +Matched: 1 (0 Exact, 1 Interpolated, 0 Rounded). +Failed: 0 (0 Not matched, 0 Write failure, 0 Too Far, + 0 No Date, 0 GPS Already Present.) +0x011a Image XResolution Rational 1 72/1 +0x011b Image YResolution Rational 1 72/1 +0x0128 Image ResolutionUnit Short 1 2 +0x0132 Image DateTime Ascii 20 2012:11:22 12:34:56 +0x0213 Image YCbCrPositioning Short 1 1 +0x8769 Image ExifTag Long 1 134 +0x9000 Photo ExifVersion Undefined 4 48 50 49 48 +0x9003 Photo DateTimeOriginal Ascii 20 2012:11:22 12:34:56 +0x9004 Photo DateTimeDigitized Ascii 20 2012:11:22 12:34:56 +0x9101 Photo ComponentsConfiguration Undefined 4 1 2 3 0 +0xa000 Photo FlashpixVersion Undefined 4 48 49 48 48 +0xa001 Photo ColorSpace Short 1 65535 +0xa002 Photo PixelXDimension Long 1 64 +0xa003 Photo PixelYDimension Long 1 64 +0x8825 Image GPSTag Long 1 276 +0x0000 GPSInfo GPSVersionID Byte 4 2 2 0 0 +0x0001 GPSInfo GPSLatitudeRef Ascii 2 N +0x0002 GPSInfo GPSLatitude Rational 3 12/1 20/1 4441/100 +0x0003 GPSInfo GPSLongitudeRef Ascii 2 W +0x0004 GPSInfo GPSLongitude Rational 3 123/1 27/1 22/1 +0x0005 GPSInfo GPSAltitudeRef Byte 1 0 +0x0006 GPSInfo GPSAltitude Rational 1 789/10 +0x0007 GPSInfo GPSTimeStamp Rational 3 11/1 34/1 56/1 +0x0010 GPSInfo GPSImgDirectionRef Ascii 2 T +0x0011 GPSInfo GPSImgDirection Rational 1 321/1 +0x0012 GPSInfo GPSMapDatum Ascii 7 WGS-84 +0x001d GPSInfo GPSDateStamp Ascii 11 2012:11:22 diff --git a/tests/data/test172.param b/tests/data/test172.param new file mode 100644 index 0000000..e03904a --- /dev/null +++ b/tests/data/test172.param @@ -0,0 +1,6 @@ +TITLE='Geotag a file from a specified location with direction and heading' +PRECOMMAND='cat "$STAGINGDIR/point1-1.jpg" >"$LOGDIR/test.jpg"' +# Run in C locale to correctly parse these decimal numbers +COMMAND='env LC_ALL=C $PROGRAM -z0 -l "12.34567,-123.456 78.9" --direction 12 --heading "$LOGDIR/test.jpg" > "$OUTFILE" 2>&1 && exiv2 -pv pr "$LOGDIR/test.jpg" >> "$OUTFILE" 2>&1' +POSTCOMMAND='rm -f "$LOGDIR/test.jpg"' +RESULTCODE=0 diff --git a/tests/data/test172.result b/tests/data/test172.result new file mode 100644 index 0000000..1b668a4 --- /dev/null +++ b/tests/data/test172.result @@ -0,0 +1,38 @@ +Legend: . = Ok, / = Interpolated, < = Rounded, - = No match, ^ = Too far + w = Write Fail, ? = No EXIF date, ! = GPS already present + +Correlate: / + +Completed correlation process. +Matched: 1 (0 Exact, 1 Interpolated, 0 Rounded). +Failed: 0 (0 Not matched, 0 Write failure, 0 Too Far, + 0 No Date, 0 GPS Already Present.) +0x011a Image XResolution Rational 1 72/1 +0x011b Image YResolution Rational 1 72/1 +0x0128 Image ResolutionUnit Short 1 2 +0x0132 Image DateTime Ascii 20 2012:11:22 12:34:56 +0x0213 Image YCbCrPositioning Short 1 1 +0x8769 Image ExifTag Long 1 134 +0x9000 Photo ExifVersion Undefined 4 48 50 49 48 +0x9003 Photo DateTimeOriginal Ascii 20 2012:11:22 12:34:56 +0x9004 Photo DateTimeDigitized Ascii 20 2012:11:22 12:34:56 +0x9101 Photo ComponentsConfiguration Undefined 4 1 2 3 0 +0xa000 Photo FlashpixVersion Undefined 4 48 49 48 48 +0xa001 Photo ColorSpace Short 1 65535 +0xa002 Photo PixelXDimension Long 1 64 +0xa003 Photo PixelYDimension Long 1 64 +0x8825 Image GPSTag Long 1 276 +0x0000 GPSInfo GPSVersionID Byte 4 2 2 0 0 +0x0001 GPSInfo GPSLatitudeRef Ascii 2 N +0x0002 GPSInfo GPSLatitude Rational 3 12/1 20/1 4441/100 +0x0003 GPSInfo GPSLongitudeRef Ascii 2 W +0x0004 GPSInfo GPSLongitude Rational 3 123/1 27/1 22/1 +0x0005 GPSInfo GPSAltitudeRef Byte 1 0 +0x0006 GPSInfo GPSAltitude Rational 1 789/10 +0x0007 GPSInfo GPSTimeStamp Rational 3 12/1 34/1 56/1 +0x000e GPSInfo GPSTrackRef Ascii 2 T +0x000f GPSInfo GPSTrack Rational 1 0/1 +0x0010 GPSInfo GPSImgDirectionRef Ascii 2 T +0x0011 GPSInfo GPSImgDirection Rational 1 12/1 +0x0012 GPSInfo GPSMapDatum Ascii 7 WGS-84 +0x001d GPSInfo GPSDateStamp Ascii 11 2012:11:22