Before writing the metadata, you should probably do something like that:
var position = positionSource.position
and then use this variable instead of always referring to positionSource.position (in case it is updated in the meantime, leading to two different positions being used for the metadata of one picture)
Before writing the metadata, you should probably do something like that:
var position = positionSource. position
and then use this variable instead of always referring to positionSource. position (in case it is updated in the meantime, leading to two different positions being used for the metadata of one picture)