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

📄 proj.java

📁 OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你就能够快速构建用于访问legacy数据库的应用程序与applets。OpenMap提供了允许用户查看和操作地理空间信息的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// **********************************************************************// // <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/Proj.java,v $// $RCSfile: Proj.java,v $// $Revision: 1.8.2.3 $// $Date: 2006/02/15 22:26:04 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.proj;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Image;import java.awt.Paint;import java.awt.Point;import java.awt.geom.Arc2D;import java.util.ArrayList;import com.bbn.openmap.Environment;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.MoreMath;import com.bbn.openmap.util.Debug;/** * Proj is the base class of all Projections. * <p> * You probably don't want to use this class unless you are hacking your own * projections, or need extended functionality. To be safe you will want to use * the Projection interface. *  * <h3>Notes:</h3> *  * <ul> *  * <li>We deal in radians internally. The outside world usually deals in * decimal degrees. If you have data in radians, DON'T bother converting it into * DD's since we'll convert it right back into radians for the projection step. * For more optimization tips, see the OMPoly class. *  * <li>We default to projecting our data using the WGS84 datum. You can change * the appropriate parameters of the projection after construction if you need * to use a different datum. And of course you can derive your own projections * from this class as you see fit. *  * <li>The forward() and inverse() methods are currently implemented using the * algorithms given in John Synder's <i>Map Projections --A Working Manual </i> * for the sphere. This is sufficient for display purposes, but you should use * ellipsoidal algorithms in the GreatCircle class to calculate distance and * azimuths on the ellipsoid. See each projection individually for more * information. *  * <li>This class is not thread safe. If two or more threads are using the same * Proj, then they could disrupt each other. Occasionally you may need to call a * <code>set</code> method of this class. This might interfere with another * thread that's using the same projection for <code>forwardPoly</code> or * another Projection interface method. In general, you should not need to call * any of the <code>set</code> methods directly, but let the MapBean do it for * you. *  * <li>All the various <code>forwardOBJ()</code> methods for ArrayList * graphics ultimately go through <code>forwardPoly()</code>. *  * </ul> *  * @see Projection * @see Cylindrical * @see Mercator * @see CADRG * @see Azimuth * @see Orthographic * @see Planet * @see GreatCircle * @see com.bbn.openmap.omGraphics.OMPoly *  */public abstract class Proj implements Projection, Cloneable {    // SOUTH_POLE <= phi <= NORTH_POLE (radians)    // -DATELINE <= lambda <= DATELINE (radians)    /**     * North pole latitude in radians.     */    public final static transient float NORTH_POLE = ProjMath.NORTH_POLE_F;    /**     * South pole latitude in radians.     */    public final static transient float SOUTH_POLE = ProjMath.SOUTH_POLE_F;    /**     * Dateline longitude in radians.     */    public final static transient float DATELINE = ProjMath.DATELINE_F;    /**     * Minimum width of projection.     */    public final static transient int MIN_WIDTH = 10; // pixels    /**     * Minimum height of projection.     */    public final static transient int MIN_HEIGHT = 10; // pixels    // Used for generating segments of ArrayList objects    protected static transient int NUM_DEFAULT_CIRCLE_VERTS = 64;    protected static transient int NUM_DEFAULT_GREAT_SEGS = 512;    // pixels per meter (an extra scaling factor).    protected int pixelsPerMeter = Planet.defaultPixelsPerMeter; // PPM    protected float planetRadius = Planet.wgs84_earthEquatorialRadiusMeters;// EARTH_RADIUS    protected float planetPixelRadius = planetRadius * pixelsPerMeter; // EARTH_PIX_RADIUS    protected float planetPixelCircumference = MoreMath.TWO_PI            * planetPixelRadius; // EARTH_PIX_CIRCUMFERENCE    protected int width = 640, height = 480;    protected float minscale = 1.0f; // 1:minscale    protected float maxscale = (float) planetPixelCircumference / (float) width;// good    // for    // cylindrical    protected float scale = maxscale;    protected float scaled_radius = planetPixelRadius / scale;    protected float ctrLat = 0.0f; // center latitude in radians    protected float ctrLon = 0.0f; // center longitude in radians    protected int type = Mercator.MercatorType; // Mercator is default    protected String projID = null; // identifies this projection    protected Mercator mercator = null; // for rhumbline calculations    // (if needed)    /**     * Construct a projection.     *      * @param center LatLonPoint center of projection     * @param s float scale of projection     * @param w width of screen     * @param h height of screen     * @param type projection type     * @see ProjectionFactory     */    public Proj(LatLonPoint center, float s, int w, int h, int type) {        if (Debug.debugging("proj")) {            Debug.output("Proj()");        }        this.type = type;        setParms(center, s, w, h);        projID = null;        // for rhumbline projecting        if (!(this instanceof Mercator)) {            mercator = new Mercator(center, scale, width, height);        }    }    /**     * Moved the initialization of constants to this method so they would be set     * by the time computeParams gets called the first time.     */    protected void init() {        // pixels per meter (an extra scaling factor).        pixelsPerMeter = Planet.defaultPixelsPerMeter; // PPM        planetRadius = Planet.wgs84_earthEquatorialRadiusMeters;// EARTH_RADIUS        planetPixelRadius = planetRadius * pixelsPerMeter; // EARTH_PIX_RADIUS        planetPixelCircumference = MoreMath.TWO_PI * planetPixelRadius; // EARTH_PIX_CIRCUMFERENCE        minscale = 1.0f; // 1:minscale        maxscale = (float) planetPixelCircumference / (float) width;// good        // This should also be set in computeParameters after scale is compared        // to min/max scale.        scaled_radius = planetPixelRadius / scale;    }    /**     * Set the pixels per meter constant.     *      * @param ppm int Pixels Per Meter scale-factor constant     */    public void setPPM(int ppm) {        pixelsPerMeter = ppm;        if (pixelsPerMeter < 1) {            pixelsPerMeter = 1;        }        computeParameters();    }    /**     * Get the pixels-per-meter constant.     *      * @return int Pixels Per Meter scale-factor constant     */    public int getPPM() {        return pixelsPerMeter;    }    /**     * Set the planet radius.     *      * @param radius float planet radius in meters     */    public void setPlanetRadius(float radius) {        planetRadius = radius;        if (planetRadius < 1.0f) {            planetRadius = 1.0f;        }        computeParameters();    }    /**     * Get the planet radius.     *      * @return float radius of planet in meters     */    public float getPlanetRadius() {        return planetRadius;    }    /**     * Get the planet pixel radius.     *      * @return float radius of planet in pixels     */    public float getPlanetPixelRadius() {        return planetPixelRadius;    }    /**     * Get the planet pixel circumference.     *      * @return float circumference of planet in pixels     */    public float getPlanetPixelCircumference() {        return planetPixelCircumference;    }    /**     * Set the scale of the projection.     * <p>     * Sets the projection to the scale 1:s iff minscale &lt; s &lt; maxscale.     * <br>     * If s &lt; minscale, sets the projection to minscale. <br>     * If s &gt; maxscale, sets the projection to maxscale. <br>     *      * @param s float scale     */    public void setScale(float s) {        scale = s;        if (scale < minscale) {            scale = minscale;            computeParameters();        } else if (scale > maxscale) {            scale = maxscale;            computeParameters();        }        computeParameters();        projID = null;    }    /**     * Set the minscale of the projection.     * <p>     * Usually you will not need to do this.     *      * @param s float minscale     */    public void setMinScale(float s) {        if (s > maxscale)            return;        minscale = s;        if (scale < minscale) {            scale = minscale;        }        computeParameters();        projID = null;    }    /**     * Set the maximum scale of the projection.     * <p>     * Usually you will not need to do this.     *      * @param s float minscale     */    public void setMaxScale(float s) {        if (s < minscale)            return;        maxscale = s;        if (scale > maxscale) {            scale = maxscale;        }        computeParameters();        projID = null;    }    /**     * Get the scale of the projection.     *      * @return float scale value     */    public float getScale() {        return scale;    }    /**     * Get the maximum scale of the projection.     *      * @return float max scale value     */    public float getMaxScale() {        return maxscale;    }    /**     * Get minimum scale of the projection.     *      * @return float min scale value     */    public float getMinScale() {        return minscale;    }    /**     * Set center point of projection.     *      * @param lat float latitude in decimal degrees     * @param lon float longitude in decimal degrees     */    public void setCenter(float lat, float lon) {        ctrLat = normalize_latitude(ProjMath.degToRad(lat));        ctrLon = wrap_longitude(ProjMath.degToRad(lon));        computeParameters();        projID = null;    }    /**     * Set center point of projection.     *      * @param pt LatLonPoint     */    public void setCenter(LatLonPoint pt) {        setCenter(pt.getLatitude(), pt.getLongitude());    }    /**     * Get center point of projection.     *      * @return LatLonPoint center of projection     */    public LatLonPoint getCenter() {        return new LatLonPoint(ctrLat, ctrLon, true);    }    /**     * Set projection width.     *      * @param width width of projection screen     */    public void setWidth(int width) {        this.width = width;        if (this.width < MIN_WIDTH) {            Debug.message("proj", "Proj.setWidth: width too small!");            this.width = MIN_WIDTH;        }        computeParameters();        projID = null;    }    /**     * Set projection height.     *      * @param height height of projection screen     */    public void setHeight(int height) {        this.height = height;        if (this.height < MIN_HEIGHT) {            Debug.message("proj", "Proj.setHeight: height too small!");            this.height = MIN_HEIGHT;        }        computeParameters();        projID = null;    }    /**     * Get projection width.     *      * @return width of projection screen     */    public int getWidth() {        return width;    }

⌨️ 快捷键说明

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