/** * Add the projection background color to the base level of the Java 3D map. The MapHandler * provides the MapBean and therefore the projection. * * @param bg The feature to be added to the Sea attribute * @param mh The feature to be added to the Sea attribute */ protected void addSea(Group bg, MapHandler mh) { MapBean map = (MapBean) mh.get("com.bbn.openmap.MapBean"); if (map != null) { Debug.message("3d", "LayerMapContent: putting down sea."); Color seaColor = map.getBackground(); Projection proj = map.getProjection(); // Make the background strech a screen around the current // map, all directions. int width = proj.getWidth(); int height = proj.getHeight(); java.awt.geom.GeneralPath background = // OMGraphic.createBoxShape(0, 0, width, height); OMGraphicAdapter.createBoxShape(-width, -height, width * 3, height * 3); addTo(bg, OMGraphicUtil.createShape3D(background, 0, seaColor, true)); } }
/** Create the query to be sent to the server, based on current settings. */ public String createQueryString(Projection p) { if (queryHeader == null) { return null; } String bbox = "undefined"; String height = "undefined"; String width = "undefined"; String sCoordParamName = WMTConstants.SRS; if (p != null) { Point2D ul = p.getUpperLeft(); Point2D lr = p.getLowerRight(); if (wmsVersion.compareTo("1.3.0") == 0) { bbox = Double.toString(lr.getY()) + "," + Double.toString(ul.getX()) + "," + Double.toString(ul.getY()) + "," + Double.toString(lr.getX()); sCoordParamName = WMTConstants.CRS; errorHandling = "INIMAGE"; } else { bbox = Double.toString(ul.getX()) + "," + Double.toString(lr.getY()) + "," + Double.toString(lr.getX()) + "," + Double.toString(ul.getY()); } height = Integer.toString(p.getHeight()); width = Integer.toString(p.getWidth()); } StringBuffer buf = new StringBuffer(queryHeader); buf.append("?") .append(WMTConstants.VERSION) .append("=") .append(wmsVersion) .append("&") .append(WMTConstants.REQUEST) .append("=") .append(mapRequestName) .append("&") .append(sCoordParamName) .append("=") .append("EPSG:4326") .append("&") .append(WMTConstants.BBOX) .append("=") .append(bbox) .append("&") .append(WMTConstants.HEIGHT) .append("=") .append(height) .append("&") .append(WMTConstants.WIDTH) .append("=") .append(width) .append("&") .append(WMTConstants.EXCEPTIONS) .append("=") .append(errorHandling); if (imageFormat != null) { buf.append("&").append(WMTConstants.FORMAT).append("=").append(imageFormat); String baseImageFormat = imageFormat; if (baseImageFormat.indexOf('/') > 0) baseImageFormat = baseImageFormat.substring(baseImageFormat.indexOf('/')); if (baseImageFormat.equals(WMTConstants.IMAGEFORMAT_JPEG)) { buf.append("&quality=").append(imageQuality); } } if (transparent != null) { buf.append("&").append(WMTConstants.TRANSPARENT).append("=").append(transparent); } if (backgroundColor != null) { buf.append("&").append(WMTConstants.BGCOLOR).append("=").append(backgroundColor); } if (layers != null) { buf.append("&").append(WMTConstants.LAYERS).append("=").append(layers); } String cStyles = styles; if (cStyles == null) { cStyles = ""; } // if (styles != null) { buf.append("&").append(WMTConstants.STYLES).append("=").append(cStyles); // } if (Debug.debugging("wms")) { Debug.output("query string: " + buf); } /* * Included to allow for one or more vendor specific parameters to be * specified such as ESRI's ArcIMS's "ServiceName" parameter. */ if (vendorSpecificNames != null) { if (vendorSpecificValues != null) { StringTokenizer nameTokenizer = new StringTokenizer(vendorSpecificNames, ","); StringTokenizer valueTokenizer = new StringTokenizer(vendorSpecificValues, ","); String paramName = null; String paramValue = null; while (nameTokenizer.hasMoreTokens()) { try { paramName = nameTokenizer.nextToken(); paramValue = valueTokenizer.nextToken(); buf.append("&").append(paramName).append("=").append(paramValue); } catch (NoSuchElementException e) { if (Debug.debugging("wms")) { Debug.output( "WMSPlugIn.getRectangle(): " + "parameter \"" + paramName + "\" has no value"); } } } } } return buf.toString(); }
/** * Since the image doesn't necessarily need to be regenerated when it is merely moved, raster * objects have this function, called from generate() and when a placement attribute is changed. * * @return true if enough information is in the object for proper placement. * @param proj projection of window. */ protected boolean position(Projection proj) { if (proj == null) { logger.fine("OMRasterObject: null projection in position!"); return false; } projWidth = proj.getWidth(); projHeight = proj.getHeight(); switch (renderType) { case RENDERTYPE_LATLON: if (!proj.isPlotable(lat, lon)) { if (DEBUG) { logger.fine("OMRasterObject: point is not plotable!"); } setNeedToReposition(true); // so we don't render it! return false; } point1 = (Point) proj.forward(lat, lon, new Point()); break; case RENDERTYPE_XY: point1 = new Point(x, y); break; case RENDERTYPE_OFFSET: if (!proj.isPlotable(lat, lon)) { if (DEBUG) { logger.fine("OMRasterObject: point is not plotable!"); } setNeedToReposition(true); // so we don't render it! return false; } point1 = (Point) proj.forward(lat, lon, new Point()); point1.x += x; point1.y += y; break; case RENDERTYPE_UNKNOWN: if (DEBUG) { logger.fine("OMRasterObject.position(): ignoring unknown rendertype, wingin' it"); } if (lat == 0 && lon == 0) { if (x == 0 && y == 0) { if (DEBUG) { logger.fine( "OMRasterObject.position(): Not enough info in object to place it reasonably."); } point1 = new Point(-width, -height); point2 = new Point(0, 0); return false; } else { point1 = new Point(x, y); } } else { if (!proj.isPlotable(lat, lon)) { logger.fine("OMRasterObject: point is not plotable!"); return false; } point1 = (Point) proj.forward(lat, lon, new Point()); } break; } point2 = new Point(0, 0); point2.x = point1.x + width; point2.y = point1.y + height; setNeedToReposition(false); return true; }
/** * Get the map coverage * * @param ullat * @param ullon * @param lrlat * @param lrlon * @param proj projection for display * @param chartSeries the chart series to query for, may be null for all coverages * @param coverages The Map to be modified */ protected void getCatalogCoverage( double ullat, double ullon, double lrlat, double lrlon, Projection proj, String chartSeries, Map<RpfProductInfo, RpfCoverage.RpfCoverageControl> coverages) { Debug.message("rpfcov", "RpfCoverageManager: Getting catalog coverage from RpfFrameProvider"); if (proj == null || frameProvider == null) { return; } CADRG cadrg; if (proj instanceof CADRG) { cadrg = (CADRG) proj; } else { cadrg = new CADRG( (LatLonPoint) proj.getCenter(new LatLonPoint.Float()), proj.getScale(), proj.getWidth(), proj.getHeight()); } List<RpfCoverageBox> hemisphereData = new ArrayList<RpfCoverageBox>(); if (ProjMath.isCrossingDateline(ullon, lrlon, proj.getScale())) { hemisphereData.addAll( frameProvider.getCatalogCoverage(ullat, ullon, lrlat, 180f, cadrg, chartSeries)); hemisphereData.addAll( frameProvider.getCatalogCoverage(ullat, -180f, lrlat, lrlon, cadrg, chartSeries)); } else { hemisphereData.addAll( frameProvider.getCatalogCoverage(ullat, ullon, lrlat, lrlon, cadrg, chartSeries)); } boolean checkSeries = !(chartSeries == null || chartSeries.equals(RpfViewAttributes.ANY) || chartSeries.equals(RpfViewAttributes.ALL)); for (RpfCoverageBox box : hemisphereData) { OMRect rect = new OMRect(box.nw_lat, box.nw_lon, box.se_lat, box.se_lon, currentLineType); RpfProductInfo rpi = RpfProductInfo.get(box.chartCode); if (rpi != null) { if (checkSeries && !rpi.seriesCode.equalsIgnoreCase(chartSeries)) { continue; } RpfCoverage.RpfCoverageControl control = coverages.get(rpi); if (control != null) { control.add(rect); rect.generate(proj); } } } }