📄 layergraphicwarehousesupport.java
字号:
} else if (token.equalsIgnoreCase(VPFUtil.Edge)) { setEdgeFeatures(true); } else if (token.equalsIgnoreCase(VPFUtil.EPoint)) { setEPointFeatures(true); } else if (token.equalsIgnoreCase(VPFUtil.CPoint)) { setCPointFeatures(true); } else if (token.equalsIgnoreCase(VPFUtil.Text)) { setTextFeatures(true); } else { Debug.output("LayerGraphicsWarehouseSupport: ignoring feature: " + token); } } } public String getFeatureString() { StringBuffer features = new StringBuffer(); if (drawAreaFeatures) features.append(VPFUtil.Area.toLowerCase() + " "); if (drawEdgeFeatures) features.append(VPFUtil.Edge.toLowerCase() + " "); if (drawEPointFeatures) features.append(VPFUtil.EPoint.toLowerCase() + " "); if (drawCPointFeatures) features.append(VPFUtil.CPoint.toLowerCase() + " "); if (drawTextFeatures) features.append(VPFUtil.Text.toLowerCase() + " "); return features.toString(); } /** * set drawing attribute properties * * @param prefix the prefix for our properties * @param props the Properties object we use to look up valuse */ public void setProperties(String prefix, Properties props) { String features; String realPrefix = PropUtils.getScopedPropertyPrefix(prefix); features = props.getProperty(realPrefix + VPFLayer.featureTypesProperty); drawingAttributes.setProperties(prefix, props); if (features != null) { setFeatures(features); } } /** * set drawing attribute properties * * @param props the Properties object. */ public Properties getProperties(Properties props) { if (props == null) { props = new Properties(); } String realPrefix = PropUtils.getScopedPropertyPrefix(drawingAttributes); props.put(realPrefix + VPFLayer.featureTypesProperty, getFeatureString()); drawingAttributes.getProperties(props); return props; } /** * create a filled polygon * * @param ipts a list of CoordFloatString objects * @param totalSize the total number of points * @param dpplat threshold for latitude thinning (passed to * warehouse) * @param dpplon threshold for longitude thinngin (passed to * warehouse) * @param ll1 upperleft of selection region (passed to warehouse) * @param ll2 lowerright of selection region (passed to warehouse) * @param doAntarcticaWorkaround hack for funny DCW antarctica * data (passed to warehouse) */ public static OMPoly createAreaOMPoly(List ipts, int totalSize, LatLonPoint ll1, LatLonPoint ll2, float dpplat, float dpplon, boolean doAntarcticaWorkaround) { int i, j, size = ipts.size(); int npts = 0; // thin the data // if (doThinning) { // totalSize = doThinning(ipts); // } // *2 for pairs float[] llpts = new float[totalSize * 2]; // only do it if we're in the vicinity if (doAntarcticaWorkaround) { doAntarcticaWorkaround = (ll2.getLatitude() < -62f); } for (j = 0; j < size; j++) { CoordFloatString cfs = (CoordFloatString) ipts.get(j); int cfscnt = cfs.tcount; int cfssz = cfs.tsize; float cfsvals[] = cfs.vals; if (cfscnt > 0) { // normal for (i = 0; i < cfscnt; i++) { llpts[npts++] = ProjMath.degToRad(cfsvals[i * cfssz + 1]);//lat llpts[npts++] = ProjMath.degToRad(cfsvals[i * cfssz]);//lon } } else { // reverse cfscnt *= -1; for (i = cfscnt - 1; i >= 0; i--) { llpts[npts++] = ProjMath.degToRad(cfsvals[i * cfssz + 1]);//lat llpts[npts++] = ProjMath.degToRad(cfsvals[i * cfssz]);//lon } } } // HACK: we will rewrite the data for the Antarctica polygon // so that // it will display "correctly" in the cylindrical projections. //only check if bottom edge of screen below a certain // latitude if (doAntarcticaWorkaround) { float[] newllpts = new float[llpts.length]; for (i = 0; i < newllpts.length; i += 2) { newllpts[i] = llpts[i]; newllpts[i + 1] = llpts[i + 1]; if (newllpts[i] < antarcticaThreshold) { Debug.message("vpf", "AreaTable.generateOMPoly(): Antarctica!"); //HACK: we're assuming data is going from west to // east, //so we wrap the other way newllpts[i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(179.99f); newllpts[++i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(90f); newllpts[++i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(0f); newllpts[++i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(-90f); newllpts[++i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(-179.99f); ++i;//lat //HACK: advance to western hemisphere where we //pick up the real data again while (llpts[i + 1] > 0) {//lon newllpts[i] = ProjMath.degToRad(-89.99f); newllpts[++i] = ProjMath.degToRad(-179.99f); ++i;//lat } i -= 2; } } llpts = newllpts; } // create polygon - change to OMPoly for jdk 1.1.x compliance. OMPoly py = new OMPoly(llpts, OMGraphic.RADIANS, OMGraphic.LINETYPE_STRAIGHT); return py; } /** * Create an OMPoly corresponding to a VPF edge feature * * @param coords the coordinates to use for the poly * @param ll1 upper left, used for clipping * @param ll2 lower right, used for clipping * @param dpplat used for latitude thinning * @param dpplon used for longitude thinning */ public static OMPoly createEdgeOMPoly(CoordFloatString coords, LatLonPoint ll1, LatLonPoint ll2, float dpplat, float dpplon) { // thin the data // if (doThinning) { // List ipts = new ArrayList(1); // ipts.add(coords); // doThinning(ipts); // } float[] llpts = coords.vals; //NOTE: lon,lat order! // handle larger tuples (do extra O(n) loop to extract only // lon/lats. if (coords.tsize > 2) {// assume 3 /* * if (Debug.debugging("vpf")) { * Debug.output("EdgeTable.drawTile: big tuple size: " + * coords.tsize); } */ float[] newllpts = new float[coords.tcount * 2];//*2 for // pairs int len = newllpts.length; for (int i = 0, j = 0; i < len; i += 2, j += 3) { newllpts[i] = ProjMath.degToRad(llpts[j + 1]);//lat newllpts[i + 1] = ProjMath.degToRad(llpts[j]);//lon } llpts = newllpts; } else { float lon; int len = llpts.length; for (int i = 0; i < len; i += 2) { lon = ProjMath.degToRad(llpts[i]); llpts[i] = ProjMath.degToRad(llpts[i + 1]);//lat llpts[i + 1] = lon;//lon } } // create polyline - change to OMPoly for jdk 1.1.x // compliance. OMPoly py = new OMPoly(llpts, OMGraphic.RADIANS, OMGraphic.LINETYPE_STRAIGHT); return py; } /** * Set doThinning. * * @param value boolean */ public static void setDoThinning(boolean value) { doThinning = value; } /** * Are we thinning?. * * @return boolean */ public static boolean isDoThinning() { return doThinning; } /** * Set fan compression epsilon. * * @param value double */ public static void setFanEpsilon(double value) { fan_eps = value; } /** * Get fan compression epsilon. * * @return double */ public static double getFanEpsilon() { return fan_eps; } /** * do fan compression of raw edge points */ protected static int doThinning(List ipts) { int size = ipts.size(); int totalSize = 0; for (int j = 0; j < size; j++) { // get poly CoordFloatString cfs = (CoordFloatString) ipts.get(j); int cfscnt = cfs.tcount; int cfssz = cfs.tsize; float[] cfsvals = cfs.vals; int npts = 0; // handle reverse boolean rev = (cfscnt < 0); if (rev) { cfscnt = -cfscnt; } // copy points float[] llpts = new float[cfscnt << 1]; for (int i = 0; i < cfscnt; i++) { llpts[npts++] = cfsvals[i * cfssz];//lon llpts[npts++] = cfsvals[i * cfssz + 1];//lat } // thin points FanCompress.FloatCompress fan = new FanCompress.FloatCompress(llpts); FanCompress.fan_compress(fan, fan_eps); // install new points cfs.vals = fan.getArray(); // install thinned 2-tuple // array cfs.tcount = cfs.vals.length >>> 1;// num pairs cfs.tsize = 2;// HACK lossy... totalSize += cfs.tcount; if (rev) { cfs.tcount *= -1; } } return totalSize; } /** * Create an OMText object corresponding to a VPF text feature * * @param text the text * @param latitude the latitude of where to place the text * @param longitude the longitude of where to place the text */ public static OMText createOMText(String text, float latitude, float longitude) { OMText txt = new OMText(latitude, longitude, text, OMText.JUSTIFY_LEFT); return txt; } /** * Create an OMPoint object corresponding to a VPF node feature * * @param latitude the latitude of where to place the text * @param longitude the longitude of where to place the text */ public static OMPoint createOMPoint(float latitude, float longitude) { return new OMPoint(latitude, longitude); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -