/** * Prepare a calculator for points expressed in input coordinate system. * * @param crs The coordinate reference system of future given points. */ OrthodromicEngine(final CoordinateReferenceSystem crs) { engine = new GeodeticCalculator(crs); if (crs instanceof GeographicCRS) { if (Utilities.isLatLon((GeographicCRS)crs)) { strategy = this::computeGeoLatLon; } else { strategy = this::computeGeo; } } else strategy = this::compute; }
if (crs instanceof GeographicCRS) { geoCrs = (GeographicCRS) crs; if (isLatLon(geoCrs)) { positionConversion = in -> new Coordinate(in.y, in.x); // transform lat,lon to lon,lat } else { throw new RuntimeException(ex); final boolean isLatLon = isLatLon(geoCrs); positionConversion = base -> transform(base, proj2Geo, isLatLon); } else {
private void testProjection(final CoordinateReferenceSystem proj) throws FactoryException { final CoordinateOperation op = CRS.findOperation(CommonCRS.defaultGeographic(), proj, null); final MathTransform geoToProj = op.getMathTransform(); test(proj, c -> Utilities.transform(c, geoToProj, false)); }
private static UnaryOperator<Coordinate> getTransformer(final CoordinateReferenceSystem target) throws FactoryException { if (org.apache.sis.util.Utilities.equalsApproximatively(target, CommonCRS.defaultGeographic())) { return UnaryOperator.identity(); } else { final CoordinateOperation op = CRS.findOperation(CommonCRS.defaultGeographic(), target, null); final MathTransform geoToTarget = op.getMathTransform(); return c -> Utilities.transform(c, geoToTarget, false); } }