If posts are in place, take the measurement from the inside of one post to the inside of the other.

Measure the height of your piers/posts from the ground to underneath the capping (if any)

Decide on which side the latch needs to be fitted as viewed from the roadside or the outside looking in.