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

📄 polylinegeometry.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/omGraphics/geom/PolylineGeometry.java,v $// $RCSfile: PolylineGeometry.java,v $// $Revision: 1.4.2.1 $// $Date: 2004/10/14 18:27:31 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.omGraphics.geom;import java.io.Serializable;import com.bbn.openmap.omGraphics.*;import com.bbn.openmap.proj.*;/** * Graphic object that represents a polygon. * <p> * All of the OMGraphics are moving to having their internal * representation as java.awt.Shape objects. Unfortunately, this has * the side effect of slowing OMPolys down, because the way that the * projection classes handle transformations cause more objects to be * allocated and more loops to be run through. So, by default, the * OMPoly does NOT use Shape objects internally, to keep layers that * throw down many, many polys running quickly. If you want to do some * spatial analysis on an OMPoly, call setDoShapes(true) on it, then * generate(Projection), and then call getShapes() to get the * java.awt.Shape objects for the poly. You can then run the different * Shape spatial analysis methods on the Shape objects. *  * <h3>NOTES:</h3> * <ul> * <li>See the <a * href="../../../../com.bbn.openmap.proj.Projection.html#poly_restrictions"> * RESTRICTIONS </a> on Lat/Lon polygons/polylines. Not following the * guidelines listed may result in ambiguous/undefined shapes! Similar * assumptions apply to the other vector graphics that we define: * circles, ellipses, rects, lines. * <li>LatLon OMPolys store latlon coordinates internally in radian * format for efficiency in projecting. Subclasses should follow this * model. * <li>Holes in the poly are not supported. If you want holes, use * multiple PolyGeometrys in a OMGeometryList. * <p> * </ul> * <h3>TODO:</h3> * <ul> * <li>Polar filled-polygon correction for Cylindrical projections * (like OMCircle). * </ul> */public abstract class PolylineGeometry extends PolygonGeometry implements        Serializable, OMGeometry {    /**     * Return the shortest distance from the graphic to an XY-point.     * This works if generate() has been successful.     *      * @param x horizontal pixel location.     * @param y vertical pixel location.     * @return the distance of the object to the location given.     */    public float distance(int x, int y) {        if (shape != null) {            return super.distance(x, y);        }        // If shape is null, then we have to do things the old way.        float temp, distance = Float.POSITIVE_INFINITY;        if (getNeedToRegenerate()) {            return distance;        }        // safety: grab local reference of projected points        int[][] xpts = xpoints;        int[][] ypts = ypoints;        int[] _x, _y;        int len = xpts.length;        for (int i = 0; i < len; i++) {            _x = xpts[i];            _y = ypts[i];            // get the closest point            temp = DrawUtil.closestPolyDistance(_x, _y, x, y, false);            if (temp < distance)                distance = temp;        }        return distance;    }    public static class LL extends PolygonGeometry.LL {        /**         * Create an LL PolygonGeometry from a list of float lat/lon         * pairs.         * <p>         * NOTES:         * <ul>         * <li>llPoints array is converted into radians IN PLACE for         * more efficient handling internally if it's not already in         * radians! For even better performance, you should send us an         * array already in radians format!         * <li>If you want the poly to be connected (as a polygon),         * you need to ensure that the first and last coordinate pairs         * are the same.         * </ul>         *          * @param llPoints array of lat/lon points, arranged lat, lon,         *        lat, lon, etc.         * @param units radians or decimal degrees. Use         *        OMGraphic.RADIANS or OMGraphic.DECIMAL_DEGREES         * @param lType line type, from a list defined in OMGraphic.         */        public LL(float[] llPoints, int units, int lType) {            this(llPoints, units, lType, -1);        }        /**         * Create an OMPoly from a list of float lat/lon pairs.         * <p>         * NOTES:         * <ul>         * <li>llPoints array is converted into radians IN PLACE for         * more efficient handling internally if it's not already in         * radians! For even better performance, you should send us an         * array already in radians format!         * <li>If you want the poly to be connected (as a polygon),         * you need to ensure that the first and last coordinate pairs         * are the same.         * </ul>         *          * @param llPoints array of lat/lon points, arranged lat, lon,         *        lat, lon, etc.         * @param units radians or decimal degrees. Use         *        OMGraphic.RADIANS or OMGraphic.DECIMAL_DEGREES         * @param lType line type, from a list defined in OMGraphic.         * @param nsegs number of segment points (only for         *        LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line types,         *        and if &lt; 1, this value is generated internally)         */        public LL(float[] llPoints, int units, int lType, int nsegs) {            super(llPoints, units, lType, nsegs);            setIsPolygon(false);        }    }    public static class XY extends PolygonGeometry.XY {        /**         * Create an OMPoly from a list of xy pairs. If you want the         * poly to be connected, you need to ensure that the first and         * last coordinate pairs are the same.         *          * @param xypoints array of x/y points, arranged x, y, x, y,         *        etc.         */        public XY(int[] xypoints) {            super(xypoints);            setIsPolygon(false);        }        /**         * Create an x/y OMPoly. If you want the poly to be connected,         * you need to ensure that the first and last coordinate pairs         * are the same.         *          * @param xPoints int[] of x coordinates         * @param yPoints int[] of y coordinates         */        public XY(int[] xPoints, int[] yPoints) {            super(xPoints, yPoints);            setIsPolygon(false);        }    }    public static class Offset extends PolygonGeometry.Offset {        /**         * Create an x/y OMPoly at an offset from lat/lon. If you want         * the poly to be connected, you need to ensure that the first         * and last coordinate pairs are the same.         *          * @param latPoint latitude in decimal degrees         * @param lonPoint longitude in decimal degrees         * @param xypoints int[] of x,y pairs         * @param cMode offset coordinate mode         */        public Offset(float latPoint, float lonPoint, int[] xypoints, int cMode) {            super(latPoint, lonPoint, xypoints, cMode);            setIsPolygon(false);        }        /**         * Create an x/y OMPoly at an offset from lat/lon. If you want         * the poly to be connected, you need to ensure that the first         * and last coordinate pairs are the same.         *          * @param latPoint latitude in decimal degrees         * @param lonPoint longitude in decimal degrees         * @param xPoints int[] of x coordinates         * @param yPoints int[] of y coordinates         * @param cMode offset coordinate mode         */        public Offset(float latPoint, float lonPoint, int[] xPoints,                int[] yPoints, int cMode) {            super(latPoint, lonPoint, xPoints, yPoints, cMode);            setIsPolygon(false);        }    }}

⌨️ 快捷键说明

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