⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtedcachehandler.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// // <copyright>// //  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/dted/DTEDCacheHandler.java,v $// $RCSfile: DTEDCacheHandler.java,v $// $Revision: 1.3.2.2 $// $Date: 2004/10/14 18:27:03 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.dted;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.proj.EqualArc;import com.bbn.openmap.omGraphics.OMRaster;import com.bbn.openmap.util.Debug;/** * The DTEDCacheHandler controls the real cache of DTED frames. It is * managed by the DTEDCacheManager, and the manager asks it for * frames. The DTEDCacheHandler goes to its cache for the images, but * it also manages the configuration of the frames, and figures out * what frames are needed, given a projection. */public class DTEDCacheHandler {    /** Default frame cache size. */    public final static int FRAME_CACHE_SIZE = 20;    /** Subframe pixel height and width. */    public final static int SF_PIXEL_HW = 200;    /** The DTED level 0, 1 directory paths. */    protected String[] paths;    /** The DTED level 2 directory paths. */    protected String[] paths2;    /** The real frame cache. */    protected DTEDFrameCache frameCache;    protected int frameCacheSize = -1; // No limit.    /** The colors used by the frames to create the images. */    protected DTEDFrameColorTable colortable; // numColors, reduced                                              // colortable    // Setting up the screen...    protected LatLonPoint ulCoords, lrCoords;    protected double frameUp, frameDown, frameLeft, frameRight;    protected double xPixInterval, yPixInterval; // degrees/pixel    protected int numXSubframes, numYSubframes;    protected int lastSubframeWidth, lastSubframeHeight;    protected int currentFrameCacheSize = -10; // guarantees that it                                               // will changed first                                               // time.    // Returning the images...    protected boolean firstImageReturned = true;    protected double frameLon = 0.0;    protected double frameLat = 0.0;    protected int subx = 0;    protected int suby = 0;    protected boolean newframe = false;    protected DTEDFrame frame = null;    /** A description of the drawing attributes of the images. */    protected DTEDFrameSubframeInfo dfsi = new DTEDFrameSubframeInfo(DTEDFrameSubframe.NOSHADING, DTEDFrameSubframe.DEFAULT_BANDHEIGHT, DTEDFrameSubframe.LEVEL_0, DTEDFrameSubframe.DEFAULT_SLOPE_ADJUST);    public DTEDCacheHandler() {        this(null,             DTEDFrameColorTable.DTED_COLORS,             DTEDFrameColorTable.DEFAULT_OPAQUENESS,             FRAME_CACHE_SIZE);    }    public DTEDCacheHandler(String[] dataPaths, int numColors, int opaque) {        this(dataPaths, null, numColors, opaque, -1);    }    public DTEDCacheHandler(String[] dataPaths, String[] data2Paths,            int numColors, int opaque) {        this(dataPaths, data2Paths, numColors, opaque, -1);    }    public DTEDCacheHandler(String[] dataPaths, int numColors, int opaqueness,            int subframe_cache_size) {        this(dataPaths, null, numColors, opaqueness, subframe_cache_size);    }    public DTEDCacheHandler(String[] dataPaths, String[] data2Paths,            int numColors, int opaqueness, int subframe_cache_size) {        colortable = new DTEDFrameColorTable(numColors, opaqueness, true);        setFrameCacheSize(subframe_cache_size);        paths = dataPaths;        paths2 = data2Paths;        frameCache = new DTEDFrameCache(dataPaths, data2Paths, frameCacheSize);        if (Debug.debugging("dted")) {            Debug.output("DTEDCacheHandler: Created with cache size of "                    + frameCacheSize);        }    }    /**     * Normally, the cache grows and shrinks as appropriate according     * to the number of frames needed to cover the screen. If you want     * to limit the size it can grow, set the size. If it's negative,     * then there will be no limit.     */    public void setFrameCacheSize(int size) {        if (size <= 0) {            frameCacheSize = FRAME_CACHE_SIZE;        } else {            frameCacheSize = size;        }    }    /**     * Get the limit imposed on the number of frames used in the     * cache.     */    public int getFrameCacheSize() {        return frameCacheSize;    }    /**     * Get an elevation at a point. Always uses the cache to load the     * frame and get the data.     */    public int getElevation(float lat, float lon) {        return frameCache.getElevation(lat, lon);    }    /** Setting the subframe attributes. */    public void setSubframeInfo(DTEDFrameSubframeInfo new_dfsi) {        dfsi = new_dfsi;        if (dfsi.viewType == DTEDFrameSubframe.COLOREDSHADING)            colortable.setGreyScale(false);        else            colortable.setGreyScale(true);    }    /**     * The method to call to let the cache handler know what the     * projection looks like so it can figure out which frames (and     * subframes) will be needed.     *      * @param proj the EqualArc projection of the screen.     */    public void setProjection(EqualArc proj) {        setProjection(proj,                proj.getUpperLeft().getLatitude(),                proj.getUpperLeft().getLongitude(),                proj.getLowerRight().getLatitude(),                proj.getLowerRight().getLongitude());    }    /**     * The method to call to let the cache handler know what the     * projection looks like so it can figure out which frames (and     * subframes) will be needed. Should be called when the     * CacheHandler is dealing with just a part of the map, such as     * when the map covers the dateline or equator.     *      * @param proj the EqualArc projection of the screen.     * @param lat1 latitude of the upper left corner of the window, in     *        decimal degrees.     * @param lon1 longitude of the upper left corner of the window,     *        in decimal degrees.     * @param lat2 latitude of the lower right corner of the window,     *        in decimal degrees.     * @param lon2 longitude of the lower right corner of the window,     *        in decimal degrees.     */    public void setProjection(EqualArc proj, float lat1, float lon1,                              float lat2, float lon2) {        ulCoords = new LatLonPoint(lat1, lon1);        lrCoords = new LatLonPoint(lat2, lon2);        double xpi = 360 / proj.getXPixConstant();        double ypi = 90 / proj.getYPixConstant();        int numFramesNeeded;        firstImageReturned = true;        // upper lat of top frame of the screen        // lower lat of bottom frame of the screen        // left lon of left frame of the screen        // upper lon of right frame of the screen        frameUp = Math.floor((double) lat1);        frameDown = Math.floor((double) lat2);        frameLeft = Math.floor((double) lon1);        frameRight = Math.ceil((double) lon2);        if (Debug.debugging("dted"))            Debug.output("frameUp = " + frameUp + ", frameDown = " + frameDown                    + ", frameLeft = " + frameLeft + ", frameRight = "                    + frameRight);        // Limit the size of the cache, if desired.        if (frameCacheSize > 0) {            numFramesNeeded = frameCacheSize;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -