public void doActionOnButton3() {
      //            Sector sector = Sector.fromDegrees( 44d, 46d, -123.3d, -123.2d );

      ArrayList<LatLon> latlons = new ArrayList<LatLon>();

      latlons.add(LatLon.fromDegrees(45.50d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.52d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.54d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.56d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.58d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.60d, -123.3d));

      ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel();

      StringBuffer sb = new StringBuffer();
      for (LatLon ll : latlons) {
        double e = model.getElevation(ll.getLatitude(), ll.getLongitude());
        sb.append("\n").append(e);
      }

      Logging.logger().info(sb.toString());
    }
  /**
   * Converts a point from pixel XY coordinates at a specified level of detail into
   * latitude/longitude WGS-84 coordinates (in degrees)
   *
   * @param pixelX X coordinate in pixels
   * @param pixelY Y coordinate in pixels
   * @param levelOfDetail Level of detail, from 1 (lowest detail) to 23 (highest detail)
   * @return LatLon Geodetic coordinates
   */
  public static LatLon PixelXYToLatLong(int pixelX, int pixelY, int levelOfDetail) {
    double mapSize = (double) calcMapSize(levelOfDetail);

    double x = (pixelX - 0.5) / mapSize;
    double y = (pixelY - 0.5) / mapSize;

    double lon = 360 * x - 180;

    double b = Math.pow(Math.E, -4 * Math.PI * (y - 0.5));
    double sinLatitude = (b - 1) / (1 + b);

    double lat = Math.asin(sinLatitude) * 180 / Math.PI;

    return LatLon.fromDegrees(lat, lon);
  }
    public void doActionOnButton1() {
      Logging.logger().info("Zooming to Matterhorn");

      View view = this.wwd.getView();

      Position matterhorn =
          new Position(LatLon.fromDegrees(45.9763888888889d, 7.65833333333333d), 0d);

      //            Position eyePos = new Position( LatLon.fromDegrees( 46.01066860997058d,
      // 7.633097536001656d ), 3363d );
      //
      //            view.setEyePosition( eyePos );
      //            view.setHeading( Angle.fromDegrees( 156d ));
      //            view.setPitch( Angle.fromDegrees( 89.9d ));

      view.goTo(matterhorn, 5000d);
    }
  protected static void legacyWmsRestoreStateToParams(
      RestorableSupport rs, RestorableSupport.StateObject context, AVList params) {
    // WMSTiledImageLayer has historically used a different format for storing LatLon and Sector
    // properties
    // in the restorable state XML documents. Although WMSTiledImageLayer no longer writes these
    // properties,
    // we must provide support for reading them here.
    Double lat = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Latitude");
    Double lon = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Longitude");
    if (lat != null && lon != null)
      params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, LatLon.fromDegrees(lat, lon));

    Double minLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLatitude");
    Double minLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLongitude");
    Double maxLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLatitude");
    Double maxLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLongitude");
    if (minLat != null && minLon != null && maxLat != null && maxLon != null)
      params.setValue(AVKey.SECTOR, Sector.fromDegrees(minLat, maxLat, minLon, maxLon));
  }
    public void doActionOnButton2() {
      ArrayList<LatLon> latlons = new ArrayList<LatLon>();

      latlons.add(LatLon.fromDegrees(45.50d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.52d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.54d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.56d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.58d, -123.3d));
      //            latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) );
      latlons.add(LatLon.fromDegrees(45.60d, -123.3d));

      Sector sector = Sector.fromDegrees(44d, 46d, -123d, -121d);
      //            Sector sector = Sector.boundingSector( latlons );

      double[] elevations = new double[latlons.size()];

      // request resolution of DTED2 (1degree / 3600 )
      double targetResolution = Angle.fromDegrees(1d).radians / 3600;

      double resolutionAchieved =
          this.wwd
              .getModel()
              .getGlobe()
              .getElevationModel()
              .getElevations(sector, latlons, targetResolution, elevations);

      StringBuffer sb = new StringBuffer();
      for (double e : elevations) {
        sb.append("\n").append(e);
      }
      sb.append("\nresolutionAchieved = ").append(resolutionAchieved);
      sb.append(", requested resolution = ").append(targetResolution);

      Logging.logger().info(sb.toString());
    }
    public void doActionOnButton4() {
      ArrayList<LatLon> locations = new ArrayList<LatLon>();

      locations.add(LatLon.fromDegrees(45.50d, -123.3d));
      locations.add(LatLon.fromDegrees(45.52d, -123.3d));
      locations.add(LatLon.fromDegrees(45.54d, -123.3d));
      locations.add(LatLon.fromDegrees(45.56d, -123.3d));
      locations.add(LatLon.fromDegrees(45.58d, -123.3d));
      locations.add(LatLon.fromDegrees(45.60d, -123.3d));

      locations.add(LatLon.fromDegrees(40.50d, -120.1d));
      locations.add(LatLon.fromDegrees(40.52d, -120.2d));
      locations.add(LatLon.fromDegrees(40.54d, -120.3d));
      locations.add(LatLon.fromDegrees(40.56d, -120.4d));
      locations.add(LatLon.fromDegrees(40.58d, -120.5d));
      locations.add(LatLon.fromDegrees(40.60d, -120.6d));

      // Now, let's find WMSBasicElevationModel
      WMSBasicElevationModel wmsbem = null;

      ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel();
      if (model instanceof CompoundElevationModel) {
        CompoundElevationModel cbem = (CompoundElevationModel) model;
        for (ElevationModel em : cbem.getElevationModels()) {
          // you can have additional checks if you know specific model name, etc.
          if (em instanceof WMSBasicElevationModel) {
            wmsbem = (WMSBasicElevationModel) em;
            break;
          }
        }
      } else if (model instanceof WMSBasicElevationModel) {
        wmsbem = (WMSBasicElevationModel) model;
      }

      if (null != wmsbem) {
        ElevationsRetriever retriever =
            new ElevationsRetriever(wmsbem, locations, 10000, 30000, new NotifyWhenReady());
        retriever.start();
      } else {
        String message =
            Logging.getMessage(
                "ElevationModel.ExceptionRequestingElevations",
                "No instance of WMSBasicElevationModel was found");
        Logging.logger().severe(message);
      }
    }