private RPFImage[] deprojectSouthernDatelineFrames(int frameNumber, BufferedImage frame, PixelTransformer pt) { // We have to split this frame at the dateline. RPFImage[] images = new RPFImage[2]; // Compute a tight bounds for western half... int minX = pixelColumn(0, frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int maxX = pixelColumn(this.frameStructure.getPixelRowsPerFrame(), frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int minY = pixelRow(0, frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int maxY = pixelRow(this.frameStructure.getPixelRowsPerFrame(), frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int midX = (minX + maxX) / 2; int midY = (minY + maxY) / 2; // Below we are using knowledge about the frames that make up the lower 1/2 part of the middle // column, and which borders and edges constitute the extrema... MinMaxLatLon bndsWest = new MinMaxLatLon(); bndsWest.minLon = -180.; // center-most frame is different... if (isCenterFrame(frameNumber)) { bndsWest.maxLon = 0.; // here max lat is at center of frame bndsWest.maxLat = pt.pixel2Latitude(midX, midY, this.frameStructure.getPolarPixelConstant()); // min lat is at an arbitrary corner... bndsWest.minLat = pt.pixel2Latitude(minX, minY, this.frameStructure.getPolarPixelConstant()); } else { // min lat is one of the lower corners... bndsWest.minLat = pt.pixel2Latitude(minX, maxY, this.frameStructure.getPolarPixelConstant()); // max lat is center of top edge... bndsWest.maxLat = pt.pixel2Latitude(midX, minY, this.frameStructure.getPolarPixelConstant()); // UL corner of frame gives us max lon... bndsWest.maxLon = pt.pixel2Longitude(minX, minY); } Sector sector = Sector.fromDegrees(bndsWest.minLat, bndsWest.maxLat, bndsWest.minLon, bndsWest.maxLon); BufferedImage destImage = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); resampleFrameFile(sector, frame, destImage, frameNumber, pt); images[0] = new RPFImage(sector, destImage); // East half... MinMaxLatLon bndsEast = new MinMaxLatLon(); // has same latitude bounds... bndsEast.minLat = bndsWest.minLat; bndsEast.maxLat = bndsWest.maxLat; // max lon is LR corner, unless we're center frame... if (isCenterFrame(frameNumber)) { bndsEast.minLon = 0.; bndsEast.maxLon = 180.; } else { bndsEast.minLon = pt.pixel2Longitude(maxX, minY); bndsEast.maxLon = 180.; } sector = Sector.fromDegrees(bndsEast.minLat, bndsEast.maxLat, bndsEast.minLon, bndsEast.maxLon); destImage = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); resampleFrameFile(sector, frame, destImage, frameNumber, pt); images[1] = new RPFImage(sector, destImage); return(images); }
public Sector computeFrameCoverage(int frameNumber) { int maxFrameNumber = getMaximumFrameNumber(); if (frameNumber < 0 || frameNumber > maxFrameNumber) { String message = Logging.getMessage("generic.ArgumentOutOfRange", frameNumber); Logging.logger().severe(message); throw new ArgumentException(message); } int minX = pixelColumn(0, frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int maxY = pixelRow(0, frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int maxX = pixelColumn(this.frameStructure.getPixelRowsPerFrame(), frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); int minY = pixelRow(this.frameStructure.getPixelRowsPerFrame(), frameNumber, this.frameStructure.getPixelRowsPerFrame(), this.frameStructure.getPolarFrames()); // we'll need these below... int midX = (minX + maxX) / 2; int midY = (minY + maxY) / 2; // Find the bounds. This is kind of tedious... PixelTransformer pt = (this.zoneCode == '9') ? northernPixels : southernPixels; MinMaxLatLon bounds = new MinMaxLatLon(); // LL double lat = pt.pixel2Latitude(minX, minY, this.frameStructure.getPolarPixelConstant()); double lon = pt.pixel2Longitude(minX, minY); bounds.setMinMax(lat, lon); // LR lat = pt.pixel2Latitude(maxX, minY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(maxX, minY); bounds.setMinMax(lat, lon); // UL lat = pt.pixel2Latitude(minX, maxY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(minX, maxY); bounds.setMinMax(lat, lon); // UR lat = pt.pixel2Latitude(maxX, maxY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(maxX, maxY); bounds.setMinMax(lat, lon); // middle top lat = pt.pixel2Latitude(midX, maxY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(midX, maxY); bounds.setMinMax(lat, lon); // middle right lat = pt.pixel2Latitude(maxX, midY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(maxX, midY); bounds.setMinMax(lat, lon); // middle bottom lat = pt.pixel2Latitude(midX, minY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(midX, minY); bounds.setMinMax(lat, lon); // middle left lat = pt.pixel2Latitude(minX, midY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(minX, midY); bounds.setMinMax(lat, lon); // center lat = pt.pixel2Latitude(midX, midY, this.frameStructure.getPolarPixelConstant()); lon = pt.pixel2Longitude(midX, midY); bounds.setMinMax(lat, lon); return(Sector.fromDegrees(bounds.minLat, bounds.maxLat, bounds.minLon, bounds.maxLon)); }