diff --git a/cdm/core/src/main/java/ucar/unidata/geoloc/LatLonPoints.java b/cdm/core/src/main/java/ucar/unidata/geoloc/LatLonPoints.java index 2beea32c26..657aebaf67 100644 --- a/cdm/core/src/main/java/ucar/unidata/geoloc/LatLonPoints.java +++ b/cdm/core/src/main/java/ucar/unidata/geoloc/LatLonPoints.java @@ -1,7 +1,8 @@ /* - * Copyright (c) 1998-2020 John Caron and University Corporation for Atmospheric Research/Unidata + * Copyright (c) 1998-2025 John Caron and University Corporation for Atmospheric Research/Unidata * See LICENSE for license information. */ + package ucar.unidata.geoloc; import java.util.Formatter; @@ -77,7 +78,7 @@ public static double lonNormalFrom(double lon, double start) { /** * Normalize the longitude to lie between +/-180 * - * @param lon east latitude in degrees + * @param lon east longitude in degrees * @return normalized lon */ public static double lonNormal(double lon) { diff --git a/cdm/core/src/test/java/ucar/unidata/geoloc/TestLatLonProjection.java b/cdm/core/src/test/java/ucar/unidata/geoloc/TestLatLonProjection.java index 20fc82221b..cb039697b3 100644 --- a/cdm/core/src/test/java/ucar/unidata/geoloc/TestLatLonProjection.java +++ b/cdm/core/src/test/java/ucar/unidata/geoloc/TestLatLonProjection.java @@ -1,29 +1,28 @@ /* - * Copyright (c) 1998-2018 University Corporation for Atmospheric Research/Unidata + * Copyright (c) 1998-2025 University Corporation for Atmospheric Research/Unidata * See LICENSE for license information. */ + package ucar.unidata.geoloc; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ucar.unidata.geoloc.projection.*; -import junit.framework.*; import java.lang.invoke.MethodHandles; /** * * @author John Caron */ -public class TestLatLonProjection extends TestCase { +public class TestLatLonProjection { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private LatLonProjection p; - public TestLatLonProjection(String name) { - super(name); - } - + @Before public void setUp() { p = new LatLonProjection(); } @@ -66,6 +65,7 @@ void runCenter(double center) { } } + @Test public void testLatLonToProjBB() { runCenter(); runCenter(110.45454545454547); @@ -82,6 +82,7 @@ public LatLonRect testIntersection(LatLonRect bbox, LatLonRect bbox2) { return result; } + @Test public void testIntersection() { LatLonRect bbox = new LatLonRect(LatLonPoint.create(40.0, -100.0), 10.0, 20.0); LatLonRect bbox2 = new LatLonRect(LatLonPoint.create(-40.0, -180.0), 120.0, 300.0); @@ -108,6 +109,7 @@ private LatLonRect testExtend(LatLonRect bbox, LatLonRect bbox2) { return bbox; } + @Test public void testExtend() { LatLonRect bbox; diff --git a/grib/src/main/java/ucar/nc2/grib/grib1/Grib1Gds.java b/grib/src/main/java/ucar/nc2/grib/grib1/Grib1Gds.java index 66cb6319c3..102f8dd7fa 100644 --- a/grib/src/main/java/ucar/nc2/grib/grib1/Grib1Gds.java +++ b/grib/src/main/java/ucar/nc2/grib/grib1/Grib1Gds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2018 John Caron and University Corporation for Atmospheric Research/Unidata + * Copyright (c) 1998-2025 John Caron and University Corporation for Atmospheric Research/Unidata * See LICENSE for license information. */ @@ -556,6 +556,9 @@ public String toString() { @Override public GdsHorizCoordSys makeHorizCoordSys() { LatLonProjection proj = new LatLonProjection(getEarth()); + double centerLon = ((int) ((lo2 - lo1 + deltaLon) / 2 / scale3)) * scale3; + proj.setCenterLon(centerLon); + // ProjectionPoint startP = proj.latLonToProj(LatLonPoint.create(la1, lo1)); double startx = lo1; // startP.getX(); double starty = la1; // startP.getY(); diff --git a/grib/src/main/java/ucar/nc2/grib/grib2/Grib2Gds.java b/grib/src/main/java/ucar/nc2/grib/grib2/Grib2Gds.java index 27117448fd..3550412711 100644 --- a/grib/src/main/java/ucar/nc2/grib/grib2/Grib2Gds.java +++ b/grib/src/main/java/ucar/nc2/grib/grib2/Grib2Gds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2018 John Caron and University Corporation for Atmospheric Research/Unidata + * Copyright (c) 1998-2025 John Caron and University Corporation for Atmospheric Research/Unidata * See LICENSE for license information. */ @@ -518,6 +518,8 @@ public int[] getOptionalPoints() { public GdsHorizCoordSys makeHorizCoordSys() { LatLonProjection proj = new LatLonProjection(getEarth()); + double centerLon = ((int) ((lo2 - lo1 + deltaLon) / 2 / getScale())) * getScale(); + proj.setCenterLon(centerLon); // ProjectionPoint startP = proj.latLonToProj(LatLonPoint.create(la1, lo1)); double startx = lo1; // startP.getX(); double starty = la1; // startP.getY();