Fix grid math for negative longitudes

Fixes #737