protected static boolean isTileVisible( DrawContext dc, Tile tile, double minDistanceSquared, double maxDistanceSquared) { if (!tile.getSector().intersects(dc.getVisibleSector())) return false; View view = dc.getView(); Position eyePos = view.getEyePosition(); if (eyePos == null) return false; Angle lat = clampAngle( eyePos.getLatitude(), tile.getSector().getMinLatitude(), tile.getSector().getMaxLatitude()); Angle lon = clampAngle( eyePos.getLongitude(), tile.getSector().getMinLongitude(), tile.getSector().getMaxLongitude()); Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d); double distSquared = dc.getView().getEyePoint().distanceToSquared3(p); //noinspection RedundantIfStatement if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false; return true; }
protected void requestTile(DrawContext dc, Tile tile) { Vec4 centroid = dc.getGlobe().computePointFromPosition(tile.getSector().getCentroid(), 0); if (this.getReferencePoint() != null) tile.setPriority(centroid.distanceTo3(this.getReferencePoint())); RequestTask task = new RequestTask(tile, this); this.getRequestQ().add(task); }
public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException { StringBuffer sb; if (this.URLTemplate == null) { sb = new StringBuffer(WWXML.fixGetMapString(tile.getLevel().getService())); if (!sb.toString().toLowerCase().contains("service=wms")) sb.append("service=WMS"); sb.append("&request=GetMap"); sb.append("&version=").append(this.wmsVersion); sb.append(this.crs); sb.append("&layers=").append(this.layerNames); sb.append("&styles=").append(this.styleNames != null ? this.styleNames : ""); sb.append("&transparent=TRUE"); if (this.backgroundColor != null) sb.append("&bgcolor=").append(this.backgroundColor); this.URLTemplate = sb.toString(); } else { sb = new StringBuffer(this.URLTemplate); } String format = (altImageFormat != null) ? altImageFormat : this.imageFormat; if (null != format) sb.append("&format=").append(format); sb.append("&width=").append(tile.getWidth()); sb.append("&height=").append(tile.getHeight()); Sector s = tile.getSector(); sb.append("&bbox="); sb.append(s.getMinLongitude().getDegrees()); sb.append(","); sb.append(s.getMinLatitude().getDegrees()); sb.append(","); sb.append(s.getMaxLongitude().getDegrees()); sb.append(","); sb.append(s.getMaxLatitude().getDegrees()); // sb.append("&"); // terminate the query string return new java.net.URL(sb.toString().replace(" ", "%20")); }