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

📄 esrigraphicfactory.java

📁 OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你就能够快速构建用于访问legacy数据库的应用程序与applets。OpenMap提供了允许用户查看和操作地理空间信息的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            coords[j * 2] = coords[0];            coords[j * 2 + 1] = coords[1];        }        return coords;    }    protected static float[] getFloatCoords(LittleEndianInputStream iStream,                                            int length, boolean isPolygon,                                            GeoCoordTransformation dataTrans,                                            ReadByteTracker bitTracker)            throws IOException, FormatException {        float[] coords = new float[isPolygon ? length * 2 + 2 : length * 2];        int j = 0;        // Create the llp here and reuse it for coordinate transformations.        LatLonPoint llp = null;        if (dataTrans != null) {            llp = new LatLonPoint();        }        for (j = 0; j < length; j++) {            double x = iStream.readLEDouble();            double y = iStream.readLEDouble();            bitTracker.addRead(2 * 8);            if (dataTrans != null) {                dataTrans.inverse(x, y, llp);                x = llp.radlon_;                y = llp.radlat_;            } else {                x = ProjMath.degToRad(x);                y = ProjMath.degToRad(y);            }            coords[j * 2] = (float) y;            coords[j * 2 + 1] = (float) x;        }        if (isPolygon) {            coords[j * 2] = coords[0];            coords[j * 2 + 1] = coords[1];        }        return coords;    }    protected static double[] getCoords(BinaryFile shpFile, int length,                                        boolean isPolygon,                                        GeoCoordTransformation dataTrans,                                        ReadByteTracker bitTracker)            throws IOException, FormatException {        double[] coords = new double[length * 2];        int j = 0;        // Create the llp here and reuse it for coordinate transformations.        LatLonPoint llp = null;        if (dataTrans != null) {            llp = new LatLonPoint();        }        for (j = 0; j < length; j++) {            double x = shpFile.readDouble();            double y = shpFile.readDouble();            bitTracker.addRead(2 * 8);            if (dataTrans != null) {                dataTrans.inverse(x, y, llp);                x = llp.radlon_;                y = llp.radlat_;            } else {                x = ProjMath.degToRad(x);                y = ProjMath.degToRad(y);            }            coords[j * 2] = y;            coords[j * 2 + 1] = x;        }        if (isPolygon) {            coords[j * 2] = coords[0];            coords[j * 2 + 1] = coords[1];        }        return coords;    }    protected static double[] getCoords(LittleEndianInputStream iStream,                                        int length, boolean isPolygon,                                        GeoCoordTransformation dataTrans,                                        ReadByteTracker bitTracker)            throws IOException, FormatException {        double[] coords = new double[length * 2];        int j = 0;        // Create the llp here and reuse it for coordinate transformations.        LatLonPoint llp = null;        if (dataTrans != null) {            llp = new LatLonPoint();        }        for (j = 0; j < length; j++) {            double x = iStream.readLEDouble();            double y = iStream.readLEDouble();            bitTracker.addRead(2 * 8);            if (dataTrans != null) {                dataTrans.inverse(x, y, llp);                x = llp.radlon_;                y = llp.radlat_;            } else {                x = ProjMath.degToRad(x);                y = ProjMath.degToRad(y);            }            coords[j * 2] = y;            coords[j * 2 + 1] = x;        }        if (isPolygon) {            coords[j * 2] = coords[0];            coords[j * 2 + 1] = coords[1];        }        return coords;    }    public static boolean isPolygon(int shapeType) {        return shapeType == SHAPE_TYPE_POLYGON                || shapeType == SHAPE_TYPE_POLYGONZ                || shapeType == SHAPE_TYPE_POLYGONM;    }    public static EsriGraphic createEsriPoly(int shapeType, float[] coords,                                             int lineType, DrawingAttributes da) {        if (da == null) {            da = DrawingAttributes.DEFAULT;        }        EsriGraphic ret = null;        switch (shapeType) {        case SHAPE_TYPE_POLYGON:            ret = new EsriPolygon(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            break;        case SHAPE_TYPE_POLYLINE:            ret = new EsriPolyline(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            ((OMGraphic) ret).setFillPaint(OMColor.clear);            break;        case SHAPE_TYPE_POLYGONM:            ret = new EsriPolygonM(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            break;        case SHAPE_TYPE_POLYGONZ:            ret = new EsriPolygonZ(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            break;        case SHAPE_TYPE_POLYLINEM:            ret = new EsriPolylineM(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            ((OMGraphic) ret).setFillPaint(OMColor.clear);            break;        case SHAPE_TYPE_POLYLINEZ:            ret = new EsriPolylineZ(coords, OMPoly.RADIANS, lineType);            da.setTo((OMGraphic) ret);            ((OMGraphic) ret).setFillPaint(OMColor.clear);            break;        }        return ret;    }    public static EsriGraphicList createEsriGraphicList(int shapeType) {        EsriGraphicList ret = null;        switch (shapeType) {        case SHAPE_TYPE_NULL:            break;        case SHAPE_TYPE_POINT:        case SHAPE_TYPE_MULTIPOINT:        case SHAPE_TYPE_POINTZ:        case SHAPE_TYPE_MULTIPOINTZ:        case SHAPE_TYPE_POINTM:        case SHAPE_TYPE_MULTIPOINTM:            ret = new EsriPointList();            ret.setType(shapeType);            break;        case SHAPE_TYPE_POLYGON:            ret = new EsriPolygonList();            break;        case SHAPE_TYPE_POLYLINE:            ret = new EsriPolylineList();            break;        case SHAPE_TYPE_POLYGONM:            ret = new EsriPolygonMList();            break;        case SHAPE_TYPE_POLYGONZ:            ret = new EsriPolygonZList();            break;        case SHAPE_TYPE_POLYLINEM:            ret = new EsriPolylineMList();            break;        case SHAPE_TYPE_POLYLINEZ:            ret = new EsriPolylineZList();            break;        }        return ret;    }    /**     * unimplemented until 4.7     *      * @param shapeType     * @param coords     * @param lineType     * @return     */    protected EsriGraphic createEsriPoly(int shapeType, double[] coords,                                         int lineType) {        // Not implemented until 4.7        EsriGraphic ret = null;        switch (shapeType) {        case SHAPE_TYPE_POLYGON:        case SHAPE_TYPE_POLYLINE:        case SHAPE_TYPE_POLYGONM:        case SHAPE_TYPE_POLYGONZ:        case SHAPE_TYPE_POLYLINEM:        case SHAPE_TYPE_POLYLINEZ:        }        return ret;    }    public GeoCoordTransformation getDataCoordTransformation() {        return dataTransformation;    }    public void setDataCoordTransformation(GeoCoordTransformation dataTrans) {        this.dataTransformation = dataTrans;    }    public int getLineType() {        return lineType;    }    public void setLineType(int lineType) {        this.lineType = lineType;    }    public Class getPrecision() {        return precision;    }    public void setPrecision(Class precision) {        this.precision = precision;    }    public static class ReadByteTracker {        int totalCount;        int currentCount;        public ReadByteTracker() {        }        public ReadByteTracker(int tc) {            totalCount = tc;        }        public int numLeft() {            return totalCount - currentCount;        }        public int addRead(int num) {            currentCount += num;            return currentCount;        }        public void reset(int newTotal) {            totalCount = newTotal;            currentCount = 0;        }        public String toString() {            return "ReadByteTracker has noted " + currentCount + " of "                    + totalCount + " bytes read";        }    }    public static class Header {        public int fileCode;        public int fileLength;        public int version;        public int shapeType;        public double xMin;        public double yMin;        public double xMax;        public double yMax;        public double zMin;        public double zMax;        public double mMin;        public double mMax;        public Header(BinaryFile shp) throws IOException, FormatException {            shp.byteOrder(true);            shp.seek(0);            fileCode = shp.readInteger();            shp.skipBytes(20); // unused            fileLength = shp.readInteger() * 2;            shp.byteOrder(false);            version = shp.readInteger();            shapeType = shp.readInteger();            xMin = shp.readDouble();            yMin = shp.readDouble();            xMax = shp.readDouble();            yMax = shp.readDouble();            zMin = shp.readDouble();            zMax = shp.readDouble();            mMin = shp.readDouble();            mMax = shp.readDouble();        }        public Header(LittleEndianInputStream iStream) throws IOException {            fileCode = iStream.readInt();            iStream.skipBytes(20); // unused            fileLength = iStream.readInt() * 2;            version = iStream.readLEInt();            shapeType = iStream.readLEInt();            xMin = iStream.readLEDouble();            yMin = iStream.readLEDouble();            xMax = iStream.readLEDouble();            yMax = iStream.readLEDouble();            zMin = iStream.readLEDouble();            zMax = iStream.readLEDouble();            mMin = iStream.readLEDouble();            mMax = iStream.readLEDouble();        }        public String toString() {            return "header[fc=" + fileCode + ",len=" + fileLength + ",ver="                    + version + ",type=" + shapeType + "]";        }    }}

⌨️ 快捷键说明

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