public void calcCorners() { ////////////////////////////////////////////////// calcCorners() // // Calculate the latlon coordinates of the top left and bottom right // // corners of the icon assuming that the icon centre is placed // // at the latlon position in this point. We use either the real world // // width or height (whichever was last set) and set the other in // // proportion. This preserves the aspect ratio of the icon when it // // has been rescaled. // // // // This method assumes a circular earth and uses Great Circles to // // calculate angles and distances for latitude distances (hieights). // // It does the same for longitude distances (widths) but then applies // // a factor to compensate for the fact that lines of longitude get // // closer together on the ground as they approach the poles. // // The factor is cos(latitude). // // if (icon == null) return; // No icon = bale out // float hDegs = 0.0f; // Height (lat) adjustment float wDegs = 0.0f; // Width (lon) adjustment // if (useWorldWidth && (worldWidth > 0.0)) { // If have usable width wDegs = ProjMath.sphericalUnitsToDeg(worldWidth, CIRCUM); // Convert width to degrees worldHeight = icon.getIconHeight() * // Pix height -> world height (worldWidth / icon.getIconWidth()); // hDegs = ProjMath.sphericalUnitsToDeg(worldHeight, CIRCUM); // Convert height to degrees } // else if (useWorldHeight && (worldHeight > 0.0)) { // Else if have useable height hDegs = ProjMath.sphericalUnitsToDeg(worldHeight, CIRCUM); // Convert height to degrees worldWidth = icon.getIconWidth() * // Pix width -> world width (worldHeight/ icon.getIconHeight()); // wDegs = ProjMath.sphericalUnitsToDeg(worldWidth, CIRCUM); // Convert width to degrees } // // wDegs /= Math.cos(ProjMath.degToRad(getLat())); // Adjust for latitude // nwCorner.setLatLon(this); // Start from centre nwCorner.translate(hDegs / 2.0f, -wDegs / 2.0f); // Translate NW corner by half seCorner.setLatLon(this); // Start from centre seCorner.translate(-hDegs / 2.0f, wDegs / 2.0f); // Translate SE corner by half // } //////////////////////////////////////////////////////////////////////// End of calcCorners()