My apologies. The target point is indeed near one of the poles of that projection. I was misled by a wrong distance calculation elsewhere.
Sorry for the unnecessary noise. The issue is resolved. -- Daniel Armak On Tue, Mar 30, 2021 at 9:03 PM Daniel Armak <danar...@gmail.com> wrote: > Hello, > > Some combinations of ObliqueMercator center points and points to be > projected trigger the error in ObliqueMercator.java:541 > <https://github.com/geotools/geotools/blob/25.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/projection/ObliqueMercator.java#L539>, > with the message “v value is infinite”. > > I’m choosing the centerpoint and projected points at random (during > testing). Below is one example: projection center point lat=30, lon=-165 > with azimuth 0; try to project the point lat=-0.09, lon=-75.15. (This is > random data from testing.) The code calculates an intermediate value U such > that abs(abs(U) - 1.0) ~= 1.91E-7, less than the code’s constant of EPSILON > = 1E-6, which has the comment “Maximum difference allowed when comparing > real numbers”. > > What does this mean? Is the implementation unable to project some points > (which are not near the poles) due to finite floating-point precision? If > so, is there a workaround that would give an approximate projection that > will always work (to some precision)? > > Full reproduction: > > val wkt = s"""PROJCS["Custom Oblique Mercator", > | GEOGCS["WGS 84", > | DATUM["World Geodetic System 1984", > | SPHEROID["WGS 84", 6378137.0, 298.257223563]], > | PRIMEM["Prime", 0.0], > | UNIT["degree", 0.017453292519943295]], > | PROJECTION["Oblique Mercator"], > | PARAMETER["longitude_of_center", -165.0], > | PARAMETER["latitude_of_center", 30.0], > | PARAMETER["azimuth", 0.0], > | PARAMETER["scale_factor", 1.0], > | PARAMETER["false_easting", 0.0], > | PARAMETER["false_northing", 0.0], > | UNIT["m", 1.0]] > |""".stripMargin > val transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, > CRS.parseWKT(wkt)) > > val geometryFactory = JTSFactoryFinder.getGeometryFactory(null) > val point = geometryFactory.createPoint(new Coordinate(-75.15, -0.09)) > > val result = JTS.transform(point, transform).asInstanceOf[Point] > println(result) > > The call to transform throws the error: > > Exception in thread "main" > org.geotools.referencing.operation.projection.ProjectionException: v value is > infinite > at > org.geotools.referencing.operation.projection.ObliqueMercator.transformNormalized(ObliqueMercator.java:539) > at > org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:893) > at > org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:939) > at > org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:109) > at > org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:262) > at > org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:253) > at > org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:128) > at org.geotools.geometry.jts.JTS.transform(JTS.java:436) > > Thank you! > -- > Daniel Armak >
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users