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

📄 azimuth.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
字号:
// **********************************************************************// // <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/proj/Azimuth.java,v $// $RCSfile: Azimuth.java,v $// $Revision: 1.4.2.2 $// $Date: 2004/12/08 01:45:34 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.proj;import java.awt.Color;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Paint;import java.awt.Point;import java.util.ArrayList;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.MoreMath;import com.bbn.openmap.util.Debug;/** * Base of all azimuthal projections. * <p> *  * @see Orthographic * @see Gnomonic */public abstract class Azimuth extends Proj {    // encapsules extra variables to forward() method call    protected static class AzimuthVar {        // invalid_forward - flag value marks a forward() of a point        // which        // is not visible.        boolean invalid_forward = false; // last forward() was invalid        // current_azimuth - azimuth (direction from center) of last        // invalid        // forwarded point.        float current_azimuth = Float.NaN; // azimuth of last forward        // extra slot        int index;    }    // HACK    final static float ACCEPTABLE_AZ = ProjMath.degToRad(5);    protected Point world; // world width and height in pixels.    /**     * Traverse poly vertices in clockwise order.     */    protected boolean clockwise = true;    /**     * Construct an azimuthal projection.     * <p>     *      * @param center LatLonPoint center of projection     * @param scale float scale of projection     * @param width width of screen     * @param height height of screen     * @param type projection type     */    public Azimuth(LatLonPoint center, float scale, int width, int height,            int type) {        super(center, scale, width, height, type);    }    /**     * Return stringified description of this projection.     * <p>     *      * @return String     * @see Projection#getProjectionID     */    public String toString() {        return " world(" + world.x + "," + world.y + ") " + super.toString();    }    /**     * Called when some fundamental parameters change.     * <p>     * Each projection will decide how to respond to this change. For     * instance, they may need to recalculate "constant" parameters     * used in the forward() and inverse() calls.     * <p>     *       */    protected void computeParameters() {        planetPixelRadius = planetRadius * pixelsPerMeter;        planetPixelCircumference = MoreMath.TWO_PI * planetPixelRadius;        // minscale is the minimum scale allowable (before integer        // wrapping        // can occur)        minscale = (float) Math.ceil((2 * planetPixelRadius)                / (int) Integer.MAX_VALUE);        if (minscale < 1)            minscale = 1;        if (scale < minscale)            scale = minscale;        // maxscale = scale at which a world hemisphere fits in the        // window        maxscale = (width < height) ? (float) (planetPixelRadius * 2)                / (float) width : (float) (planetPixelRadius * 2)                / (float) height;        if (maxscale < minscale) {            maxscale = minscale;        }        if (scale > maxscale) {            scale = maxscale;        }        scaled_radius = planetPixelRadius / scale;        if (world == null)            world = new Point(0, 0);        // width of the world in pixels at current scale. We see only        // one hemisphere.        world.x = (int) ((planetPixelRadius * 2) / scale);        // calculate cutoff scale for XWindows workaround        XSCALE_THRESHOLD = (int) ((planetPixelRadius * 2) / 64000);//fudge                                                                   // it a                                                                   // little                                                                   // bit        if (Debug.debugging("proj")) {            Debug.output("Azimuth.computeParameters(): " + "world.x = "                    + world.x + " XSCALE_THRESHOLD = " + XSCALE_THRESHOLD);        }    }    /**     * Toggle clockwise traversal of poly vertices.     *      * @param value boolean     */    public void setClockwiseTraversal(boolean value) {        clockwise = value;    }    /**     * Get poly-traversal setting (clockwise or counter-clockwise).     *      * @return boolean     */    public boolean isClockwiseTraversal() {        return clockwise;    }    /**     * Forward project a point. Wrapper around Azimuth-specific     * forwarding.     */    public final Point forward(LatLonPoint llp, Point pt) {        return _forward(normalize_latitude(llp.radlat_),                wrap_longitude(llp.radlon_),                pt,                null);    }    /**     * Forward project a point. Wrapper around Azimuth-specific     * forwarding. Lat and lon assumed to be decimal degrees.     */    public final Point forward(float lat, float lon, Point pt) {        return _forward(normalize_latitude(ProjMath.degToRad(lat)),                wrap_longitude(ProjMath.degToRad(lon)),                pt,                null);    }    /**     * Forward project a point. Wrapper around Azimuth-specific     * forwarding. Lat/lon assumed to be radians. isRadian only used     * to create a different method signature - assumed to be true.     */    public final Point forward(float lat, float lon, Point pt, boolean isRadian) {        return _forward(normalize_latitude(lat), wrap_longitude(lon), pt, null);    }    /**     * Forward project a point. If the point is not within the     * viewable hemisphere, return flags in AzimuthVar variable if     * specified.     *      * @param lat latitude in radians     * @param lon longitude in radians     * @param pt Point     * @param azVar AzimuthVar or null     * @return Point pt     */    protected abstract Point _forward(float lat, float lon, Point pt,                                      AzimuthVar azVar);    /**     * Pan the map/projection.     * <ul>     * <li><code>pan(

⌨️ 快捷键说明

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