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

📄 linkboundingpoly.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/layer/link/LinkBoundingPoly.java,v $// $RCSfile: LinkBoundingPoly.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:27:07 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.link;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.util.Debug;import java.io.IOException;import java.io.DataOutput;import java.io.DataInput;/** * LinkBoundingPoly objects are used to describe simple polygons that * cover a certain area. If the area described is in coordinates, the * polygon should not be sued for areas covering a pole or straddling * the dateline. More than one LinkBoundingPolys should be used for * areas like that. */public class LinkBoundingPoly {    public float maxX;    public float maxY;    public float minX;    public float minY;    protected float[] points;    /**     * The constructor to use when reading the bounding polygon off an     * input stream.     *      * @param dis DataInputStream to read from.     */    public LinkBoundingPoly(DataInput dis) throws IOException {        read(dis);    }    /**     * The constructor to use to create a LinkBoundingPoly to write to     * an output stream.     *      * @param poly a series of alternating x, y points describing a     *        polygon.     */    public LinkBoundingPoly(float[] poly) {        points = poly;    }    /**     * Create a LinkBoundingPoly out of minimum and max x, y, values.     *      * @param minX minimum X value.     * @param minY minimum Y value.     * @param maxX maximum X value.     * @param maxY maximum Y value.     */    public LinkBoundingPoly(float minX, float minY, float maxX, float maxY) {        points = new float[10];        Debug.message("link",                "LinkBoundingPoly: Creating link bounding poly with " + minX                        + ", " + minY + ", " + maxX + ", " + maxY);        points[0] = minY;        points[1] = minX;        points[2] = maxY;        points[3] = minX;        points[4] = maxY;        points[5] = maxX;        points[6] = minY;        points[7] = maxX;        points[8] = minY;        points[9] = minX;    }    /**     * Write the polygon on the output stream. If the number of points     * is an odd number, the last number will be left off.     *      * @param dos the DataOutput to write to.     */    public void write(DataOutput dos) throws IOException {        // round down to a multiple of two.        int length = (points.length / 2) * 2;        dos.writeInt(length);        for (int i = 0; i < length; i++) {            dos.writeFloat(points[i]);        }    }    /**     * Read the bounding polygon off the input stream.     *      * @param dis DataInputStream to read from.     */    public void read(DataInput dis) throws IOException {        Debug.message("link", "LinkBoundingPoly: read()");        int polyLength = dis.readInt();        points = new float[polyLength];        float x, y;        for (int i = 0; i < points.length; i += 2) {            y = dis.readFloat();            x = dis.readFloat();            if (i == 0) {                minX = x;                minY = y;                maxX = x;                maxY = y;            }            points[i] = y;            points[i + 1] = x;            if (x < minX)                minX = x;            if (x > maxX)                maxX = x;            if (y < minY)                minY = y;            if (y > maxY)                maxY = y;        }    }    /**     * Return the polygon points, as a series of alternating x and y     * values.     *      * @return float[] of alternating x, y, points.     */    public float[] getPoints() {        return points;    }    /**     * Convert the points to Lat/Lon points. There is no guarantee     * that the points really translate into latitude and longitude     * points.     *      * @return LatLonPoints     */    public LatLonPoint[] getLatLonPoints() {        LatLonPoint[] boundingPoly = new LatLonPoint[points.length / 2];        float lat, lon;        for (int i = 0; i < points.length; i += 2) {            lat = points[i];            lon = points[i + 1];            boundingPoly[i] = new LatLonPoint(lat, lon);        }        return boundingPoly;    }    public String toString() {        StringBuffer s = new StringBuffer();        s.append("  LinkBoundingPoly has " + points.length / 2 + " points.");        for (int i = 0; i < points.length; i += 2) {            s.append("\n    |Lat = " + points[i] + ", Lon = " + points[i + 1]                    + "|");        }        return s.toString();    }}

⌨️ 快捷键说明

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