@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)); }
@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), } ); }
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), } ); } }
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(); }
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); }
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);  }