GridUtility { @Deprecated public static Range[] getXYRangesFromLatLonRect(LatLonRect llr, GridCoordSystem gcs) throws InvalidRangeException { double[][] coords = { { llr.getLatMin(), llr.getLonMin() }, { llr.getLatMin(), llr.getLonMax() }, { llr.getLatMax(), llr.getLonMax() }, { llr.getLatMax(), llr.getLonMin() }, }; int[] currentIndices = new int[2]; int lowerX = Integer.MAX_VALUE; int upperX = Integer.MIN_VALUE; int lowerY = Integer.MAX_VALUE; int upperY = Integer.MIN_VALUE; for (int i = 0; i < coords.length; ++i) { gcs.findXYindexFromLatLon(coords[i][0], coords[i][1], currentIndices); if (currentIndices[0] < lowerX) { lowerX = currentIndices[0] ; } if (currentIndices[0] > upperX) { upperX = currentIndices[0] ; } if (currentIndices[1] < lowerY) { lowerY = currentIndices[1] ; } if (currentIndices[1] > upperY) { upperY = currentIndices[1] ; } } return bufferXYRanges(gcs, new Range[] { new Range(lowerX, upperX), new Range(lowerY, upperY), } ); } private  GridUtility(); static int getXAxisLength(GridCoordSystem gcs); static int getYAxisLength(GridCoordSystem gcs); static Range getXAxisRange(GridCoordSystem gcs); static Range getYAxisRange(GridCoordSystem gcs); static int getXAxisLengthQuick(GridCoordSystem gcs); static int getYAxisLengthQuick(GridCoordSystem gcs); static Range getXAxisRangeQuick(GridCoordSystem gcs); static Range getYAxisRangeQuick(GridCoordSystem gcs); static BoundingBox getBoundingBox(GridDatatype gdt); static BoundingBox getBoundingBox(GridCoordSystem gcs); static Range[] getXYRangesFromBoundingBox(BoundingBox bounds, GridCoordSystem gcs); static Range[] getXYRangesFromBoundingBox(BoundingBox bounds, GridCoordSystem gcs, boolean requireFullCoverage); @Deprecated static Range[] getXYRangesFromLatLonRect(LatLonRect llr, GridCoordSystem gcs); static Range[] bufferXYRanges(GridCoordSystem gcs, Range[] ranges); @Deprecated static IndexToCoordinateBuilder generateIndexToCellCenterLatLonCoordinateBuilder(GridCoordSystem gridCoordSystem); @Deprecated static IndexToCoordinateBuilder generateIndexToCellEdgeLatLonCoordinateBuilder(GridCoordSystem gridCoordSystem); static IndexToCoordinateBuilder generateIndexToCellCenterCoordinateBuilder(GridCoordSystem gridCoordSystem); static IndexToCoordinateBuilder generateIndexToCellEdgeCoordinateBuilder(GridCoordSystem gridCoordSystem);  }
@Test public void testRangesFromLatLonRect_Standard() throws TransformException, IOException, InvalidRangeException { LatLonRect llr = makeLatLonRect(ncLocation); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertNotNull(range); }
@Test(expected = InvalidRangeException.class) public void testRangesFromLatLonRect_InvalidRange() throws InvalidRangeException, IOException { getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(-1, -1), new LatLonPointImpl(-1, -1)); GridCoordSystem gcs = getGridCoordinateSystem(); GridUtility.getXYRangesFromLatLonRect(llr, gcs); }
@Test public void testTopOfGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXSmallestValid.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(42, -91), new LatLonPointImpl(42, -89)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 3x3 since they are buffered", (range[0].length() == 3 && range[1].length() == 3)); }
@Test public void testBottomOfGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXSmallestValid.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(40, -91), new LatLonPointImpl(40, -89)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 3x3 since they are buffered", (range[0].length() == 3 && range[1].length() == 3)); }
@Test public void testLeftOfGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXSmallestValid.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(40, -91), new LatLonPointImpl(42, -91)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 3x3 since they are buffered", (range[0].length() == 3 && range[1].length() == 3)); }
@Test public void testMiddleOfGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXSmallestValid.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(41, -90), new LatLonPointImpl(41, -90)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 3x3 since they are buffered", (range[0].length() == 3 && range[1].length() == 3)); }
@Test public void testMiddleOfBiggerGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXFourByFour.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(41, -90), new LatLonPointImpl(42, -89)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 4x4 since they are buffered", (range[0].length() == 4 && range[1].length() == 4)); }
@Test public void testTopMiddleOfBiggerGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXFourByFour.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(43, -90), new LatLonPointImpl(42, -89)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 4x3 since they are buffered", (range[0].length() == 4 && range[1].length() == 3)); }
@Test public void testBottomMiddleOfBiggerGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXFourByFour.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(41, -90), new LatLonPointImpl(40, -89)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 4x3 since they are buffered", (range[0].length() == 4 && range[1].length() == 3)); }
@Test public void testLeftMiddleOfBiggerGrid() throws IOException, InvalidRangeException { ncLocation = getResourceDir() + File.separator + "testCoverageTYXFourByFour.ncml"; getFeatureCollection(ncLocation); LatLonRect llr = new LatLonRect( new LatLonPointImpl(41, -91), new LatLonPointImpl(42, -90)); GridCoordSystem gcs = getGridCoordinateSystem(); Range[] range = GridUtility.getXYRangesFromLatLonRect(llr, gcs); assertTrue("Range should be 3x4 since they are buffered", (range[0].length() == 3 && range[1].length() == 4)); }