solidified proj3 code, can be used as base for proj4