-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
Description
An unexpected coordinate truncation happens when coordinates exceed -180, which does not seem to happen in the Python variant.
The truncation happens here:
https://github.com/locationtech/proj4j/blob/master/core/src/main/java/org/locationtech/proj4j/proj/Projection.java#L326
I discovered this via this Geotrellis code:
val orig = Point(182.086672726415,69.3350337120443)
val origNormalized = Point(182.086672726415 - 360,69.3350337120443)
val utm01 = CRS.fromName("EPSG:32601")
val reprojected = orig.reproject(LatLng, utm01)
val normalizedReprojected = origNormalized.reproject(LatLng, utm01)
val roundTrip = reprojected.reproject(utm01,LatLng)
assertTrue(reprojected.equalsExact(normalizedReprojected, 0.1) )
assertTrue(orig.equalsExact(roundTrip, 0.00001) )Python variant can also be tested:
import pyproj
# Define the input coordinates in EPSG:4326
longitude, latitude = 182.086672726415, 69.3350337120443
# Define the source and target CRS
source_crs = pyproj.CRS("EPSG:4326")
target_crs = pyproj.CRS("EPSG:32601") # UTM Zone 1N
# Create a transformer object
transformer = pyproj.Transformer.from_crs(source_crs, target_crs, always_xy=True)
# Transform the coordinates
utm_x, utm_y = transformer.transform(longitude, latitude)