I am currently working on a project where we have to figure out the position of one point based on the known position of two (user-input) points.
Now the problem is that the users could provide two points in different UTM zones, so we have to project one of the points to the other system (at least that is how we do it.)
I coded a reference implementation in Python to test it, and now we want to use this feature in production on iOS. It seems as if the only swift proj library here is out of date and can not be used.
We looked around for a bit, but did not find a description of how to project a point from one zone to the other one without additional software.
Do you know whether this is possible, or whether there is an up-to-date proj library for swift?
Project point from one UTM zone to other
As you may well know, since you've coded a reference implementation in Python, this is accomplished in two steps:
1. Unproject one point from UTM to Geographic Coordinates, that is from [E, N, Zone, Hemisphere] to latitude, longitude (φ, λ);
and then,
2. Project the resulting Geographic Coordinates to UTM (another Zone, different from 1), that is from latitude, longitude (φ, λ) to UTM coordinates (E, N).
Since you haven't mentioned any Datum conversion, PROJ library becomes overkill to accomplish this task. Besides, the question is not about How to call C from Swift.
Even more because there are plenty of UTM implementations, even here on SO, for the majority of the mainstream languages (Java, Javascript, Python, C#), or at least Transverse Mercator implementations that can be easily adapted to UTM (UTM system uses Transverse Mercator as Cartographic Projection).
For Swift I couldn't find any on SO, but on GitHub I could.
https://github.com/wtw-software/UTMConversion
The conversion happens between a custom struct UTMCoordinate and CoreLocation's CLLocationCoordinate2D and CLLocation.
And it is even possible to specify a custom Datum provided you are not using the default value WGS84
used by the library.
import CoreLocation
import UTMConversion
let utmCoordinate = UTMCoordinate(northing: 7034313, easting: 569612, zone: 32, hemisphere: .northern)
let datum = UTMDatum(equitorialRadius: 6378137, polarRadius: 6356752.3142)
let coordinate = utmCoordinate.coordinate(datum: datum)
Accuracy can be accessed by comparing the library output with the results from your Python implementation.
In case you are not satisfied with the results you can always modify the source code particularly the following file where the Transverse Mercator projection (the hard math) is:
https://github.com/wtw-software/UTMConversion/blob/master/UTMConversion/TMCoordinate.swift