📄 dtedcachehandler.java
字号:
if (Debug.debugging("dteddetail")) { Debug.output("DTEDCacheHandler: frameCacheSize remains at: " + numFramesNeeded); } } else { // calculate how many frames should be in the cache... numFramesNeeded = (int) (Math.abs(frameUp - frameDown) * Math.abs(frameRight - frameLeft) * 2); } if (xPixInterval != xpi || yPixInterval != ypi) { // Screen attributes changed!!!! xPixInterval = xpi; yPixInterval = ypi; // While it changed... dfsi.xPixInterval = xPixInterval; dfsi.yPixInterval = yPixInterval; // Trap for funky values... if (xpi == 0 || ypi == 0) { numXSubframes = 0; numYSubframes = 0; return; } int frame_width = (int) Math.ceil(1.0 / xpi); int frame_height = (int) Math.ceil(1.0 / ypi); // Even number of subframes in frame numXSubframes = frame_width / SF_PIXEL_HW; lastSubframeWidth = SF_PIXEL_HW; numYSubframes = frame_height / SF_PIXEL_HW; lastSubframeHeight = SF_PIXEL_HW; if (frame_width % SF_PIXEL_HW != 0) { lastSubframeWidth = frame_width - (numXSubframes * SF_PIXEL_HW); numXSubframes++; } if (frame_height % SF_PIXEL_HW != 0) { lastSubframeHeight = frame_height - (numYSubframes * SF_PIXEL_HW); numYSubframes++; } currentFrameCacheSize = numFramesNeeded; frameCache.resizeCache(numFramesNeeded, numXSubframes, numYSubframes); if (Debug.debugging("dteddetail")) { Debug.output("DTEDCacheHandler: frameCacheSize set to: " + numFramesNeeded); } if (Debug.debugging("dted")) Debug.output("***** Screen Parameters Changed! \n" + " Frame width (pix) = " + frame_width + "\n" + " Frame height (pix) = " + frame_height + "\n" + " Num x subframes = " + numXSubframes + "\n" + " Num y subframes = " + numYSubframes + "\n" + " last sf width = " + lastSubframeWidth + "\n" + " last sf height = " + lastSubframeHeight + "\n" + " X pix interval = " + xpi + "\n" + " Y pix interval = " + ypi + "\n"); } else if (Math.abs(numFramesNeeded - currentFrameCacheSize) > numFramesNeeded / 2) { currentFrameCacheSize = numFramesNeeded; frameCache.resizeCache(numFramesNeeded); if (Debug.debugging("dteddetail")) { Debug.output("DTEDCacheHandler: frameCacheSize set to: " + numFramesNeeded); } } } /** * Returns the next OMRaster image. When setProjection() is * called, the cache sets the projection parameters it needs, and * also resets this popping mechanism. When this mechanism is * reset, you can keep calling this method to get another subframe * image. When it returns a null value, it is done. It will * automatically skip over window frames it doesn't have, and * return the next one it does have. It traverses from the top * left to right frames, and top to bottom for each column of * frames. It handles all the subframes for a frame at one time. * * @return OMRaster image. */ public OMRaster getNextImage() { OMRaster subframe = null; // Subframe coordinates and height and width // upper left, lower right double sf_ullat, sf_ullon, sf_lrlat, sf_lrlon; long sf_width = SF_PIXEL_HW; long sf_height = SF_PIXEL_HW; if (Debug.debugging("dted")) Debug.output("--- DTEDCacheHandler: getNextImage:"); while (true) { if (firstImageReturned == true) { frameLon = frameLeft; frameLat = frameDown; subx = 0; suby = 0; newframe = true; firstImageReturned = false; } else { if (frame != null && subx < numXSubframes) { // update statics to look for next subframe if (suby < numYSubframes - 1) suby++; else { suby = 0; subx++; } } else if (frameLon < frameRight) { // update statics to look for next frame subx = 0; suby = 0; if (frameLat < frameUp) frameLat++; else { frameLat = frameDown; frameLon++; } newframe = true; } else { // bounds exceeded, all done return (OMRaster) null; } } if (newframe && frameLon < frameRight) { if (Debug.debugging("dted")) Debug.output(" gni: Getting new frame Lat = " + frameLat + " Lon = " + frameLon); frame = frameCache.get(frameLat, frameLon, dfsi.dtedLevel); } // Figure out subframe lat/lon and height/width if (frame != null) { newframe = false; if (subx == (numXSubframes - 1)) sf_width = lastSubframeWidth; if (suby == (numYSubframes - 1)) sf_height = lastSubframeHeight; // width/height degrees are spacers - degrees to // subframe within the frame. sf_height/width_degrees // are the lat/lon of the frame corner. double sf_width_degrees = (double) sf_width * xPixInterval; double sf_height_degrees = (double) sf_height * yPixInterval; double width_degrees = (double) SF_PIXEL_HW * xPixInterval; double height_degrees = (double) SF_PIXEL_HW * yPixInterval; sf_ullat = (double) (frameLat + 1.0) - ((double) suby * height_degrees); sf_ullon = (double) frameLon + ((double) subx * width_degrees); sf_lrlat = (double) (frameLat + 1.0) - ((double) suby * height_degrees) - sf_height_degrees; sf_lrlon = (double) frameLon + ((double) subx * width_degrees) + sf_width_degrees; if ((ulCoords.getLatitude() > sf_lrlat && lrCoords.getLatitude() < sf_ullat) && (ulCoords.getLongitude() < sf_lrlon && lrCoords.getLongitude() > sf_ullon) && subx < numXSubframes) { dfsi.height = (int) sf_height; dfsi.width = (int) sf_width; dfsi.lon = (float) sf_ullon; dfsi.lat = (float) sf_ullat; dfsi.subx = subx; dfsi.suby = suby; if (Debug.debugging("dteddetail")) { Debug.output(" gni: Looking for Subframe " + subx + ", " + suby); } subframe = frame.getSubframeOMRaster(dfsi, colortable); if (subframe != null) { if (Debug.debugging("dted")) { Debug.output(" gni: Subframe " + subx + ", " + suby + " found :)"); } return subframe; } } else if (Debug.debugging("dteddetail")) { Debug.output(" gni: Subframe " + subx + ", " + suby + " didn't meet screen criteria"); } } sf_width = SF_PIXEL_HW; sf_height = SF_PIXEL_HW; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -