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

📄 orthographic.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            Debug.message("proj", "Orthographic.inverse: center!");            llp.setLatLon(ProjMath.radToDeg(ctrLat), ProjMath.radToDeg(ctrLon));            return llp;        }        //float c = (float)Math.asin(rho/scaled_radius);        //float cosC = (float)Math.cos(c);        //float sinC = (float)Math.sin(c);        float sinC = rho / scaled_radius;        float cosC = (float) Math.sqrt(1 - sinC * sinC);        // calculate latitude        float lat = (float) Math.asin(cosC * sinCtrLat                + (y * sinC * (cosCtrLat / rho)));        // calculate longitude        float lon;        if (ctrLat == NORTH_POLE) {            lon = ctrLon + (float) Math.atan2(x, -y);        } else if (ctrLat == SOUTH_POLE) {            lon = ctrLon + (float) Math.atan2(x, y);        } else {            lon = ctrLon                    + (float) Math.atan2((x * sinC),                            (rho * cosCtrLat * cosC - y * sinCtrLat * sinC));        }        //      Debug.output("Orthographic.inverse: lat,lon=" +        //                         ProjMath.radToDeg(lat) + "," +        //                         ProjMath.radToDeg(lon));        // check if point in outer space        //      if (MoreMath.approximately_equal(lat, ctrLat) &&        //             MoreMath.approximately_equal(lon, ctrLon) &&        //             (Math.abs(x-(width/2))<2) &&        //             (Math.abs(y-(height/2))<2))        if (Float.isNaN(lat) || Float.isNaN(lon)) {            //          Debug.message("proj", "Orthographic.inverse(): outer            // space!");            lat = ctrLat;            lon = ctrLon;        }        llp.setLatLon(ProjMath.radToDeg(lat), ProjMath.radToDeg(lon));        return llp;    }    /**     * Inverse project a Point.     *      * @param pt x,y Point     * @param llp resulting LatLonPoint     * @return LatLonPoint llp     */    public LatLonPoint inverse(Point pt, LatLonPoint llp) {        return inverse(pt.x, pt.y, llp);    }    /**     * Get the upper left (northernmost and westernmost) point of the     * projection.     * <p>     * Returns the upper left point (or closest equivalent) of the     * projection based on the center point and height and width of     * screen.     *      * @return LatLonPoint     */    public LatLonPoint getUpperLeft() {        LatLonPoint tmp = new LatLonPoint();        float lat, lon;        // over north pole        if (overNorthPole()) {            lat = NORTH_POLE;            lon = -DATELINE;        }        // over south pole        else if (overSouthPole()) {            lon = -DATELINE;            // get the left top corner            tmp = inverse(0, 0, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = ctrLat + MoreMath.HALF_PI;            } else {                // northernmost coord is left top                lat = tmp.radlat_;            }        }        // view in northern hemisphere        else if (ctrLat >= 0f) {            // get the left top corner            tmp = inverse(0, 0, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = inverse(width / 2, 0, tmp).radlat_;                lon = -DATELINE;            } else {                // westernmost coord is left top                lon = tmp.radlon_;                // northernmost coord is center top                lat = inverse(width / 2, 0, tmp).radlat_;            }        }        // view in southern hemisphere        else {            // get the left top corner            tmp = inverse(0, 0, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = ctrLat + MoreMath.HALF_PI;                lon = -DATELINE;            } else {                // northernmost coord is left top                lat = tmp.radlat_;                // westernmost coord is left bottom                lon = inverse(0, height - 1, tmp).radlon_;            }        }        tmp.setLatLon(lat, lon, true);        //      Debug.output("ul="+tmp);        return tmp;    }    /**     * Get the lower right (southeast) point of the projection.     * <p>     * Returns the lower right point (or closest equivalent) of the     * projection based on the center point and height and width of     * screen.     * <p>     * This is trivial for most cylindrical projections, but much more     * complicated for azimuthal projections.     *      * @return LatLonPoint     */    public LatLonPoint getLowerRight() {        LatLonPoint tmp = new LatLonPoint();        float lat, lon;        // over north pole        if (overNorthPole()) {            lon = DATELINE;            // get the right bottom corner            tmp = inverse(width - 1, height - 1, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = ctrLat - MoreMath.HALF_PI;            } else {                // southernmost coord is right bottom                lat = tmp.radlat_;            }        }        // over south pole        else if (overSouthPole()) {            lat = SOUTH_POLE;            lon = DATELINE;        }        // view in northern hemisphere        else if (ctrLat >= 0f) {            // get the right bottom corner            tmp = inverse(width - 1, height - 1, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = ctrLat - MoreMath.HALF_PI;                lon = DATELINE;            } else {                // southernmost coord is right bottom                lat = tmp.radlat_;                // easternmost coord is right top                lon = inverse(width - 1, 0, tmp).radlon_;            }        }        // view in southern hemisphere        else {            // get the right bottom corner            tmp = inverse(width - 1, height - 1, tmp);            // check for invalid            if (MoreMath.approximately_equal(tmp.radlon_, ctrLon, 0.0001f)) {                lat = inverse(width / 2, height - 1, tmp).radlat_;                lon = DATELINE;            } else {                // easternmost coord is right bottom                lon = tmp.radlon_;                // southernmost coord is center bottom                lat = inverse(width / 2, height - 1, tmp).radlat_;            }        }        tmp.setLatLon(lat, lon, true);        //      Debug.output("lr="+tmp);        return tmp;    }    /**     * Get the name string of the projection.     */    public String getName() {        return OrthographicName;    }    /*     * public void testPoint(float lat, float lon) { float x, y; lon =     * wrap_longitude(ProjMath.degToRad(lon)); lat =     * normalize_latitude(ProjMath.degToRad(lat)); x = forward_x(lat,     * lon); y = forward_y(lat, lon);     *      * Debug.output("(lon="+ProjMath.radToDeg(lon)+",lat="+     * ProjMath.radToDeg(lat)+ ") = (x="+x+",y="+y+")"); lat =     * inverse_lat(x, y); lon = wrap_longitude(inverse_lon(x, y));     * Debug.output("(x="+x+",y="+y+") = (lon="+     * ProjMath.radToDeg(lon)+",lat="+ ProjMath.radToDeg(lat)+")"); }     *      * public static void main (String argv[]) { Orthographic     * proj=null; proj = new Orthographic(new LatLonPoint(40.0f,     * 0.0f), 1.0f, 620, 480);     *      * Debug.output("testing"); proj.setEarthRadius(1.0f);     * Debug.output("setEarthRadius("+proj.getEarthRadius()+")");     * proj.setPPM(1); Debug.output("setPPM("+proj.getPPM()+")");     * proj.setMinScale(1.0f);     * Debug.output("setMinScale("+proj.getMinScale()+")"); try {     * proj.setScale(1.0f); } catch (java.beans.PropertyVetoException     * e) { } Debug.output("setScale("+proj.getScale()+")");     * Debug.output(proj); Debug.output();     *      * Debug.output("---testing latitude"); proj.testPoint(0.0f,     * 0.0f); proj.testPoint(10.0f, 0.0f); proj.testPoint(40.0f,     * 0.0f); proj.testPoint(-80.0f, 0.0f); proj.testPoint(-90.0f,     * 0.0f); proj.testPoint(100.0f, 0.0f); proj.testPoint(-3272.0f,     * 0.0f); Debug.output("---testing longitude");     * proj.testPoint(0.0f, 10.0f); proj.testPoint(0.0f, -10.0f);     * proj.testPoint(0.0f, 90.0f); proj.testPoint(0.0f, -90.0f);     * proj.testPoint(0.0f, 170.0f); proj.testPoint(0.0f, -170.0f);     * proj.testPoint(0.0f, 180.0f); proj.testPoint(0.0f, -180.0f);     * proj.testPoint(0.0f, 190.0f); proj.testPoint(0.0f, -190.0f);     * Debug.output("---testing lat&lon"); proj.testPoint(100.0f,     * 370.0f); proj.testPoint(-30.0f, -370.0f);     * proj.testPoint(-80.0f, 550.0f); proj.testPoint(0.0f, -550.0f); }     */}

⌨️ 快捷键说明

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