updates to make solution work for complete longitude ranges which are not just [-180,180] such as [0,360]