Пример #1
0
    private Info[] buildSurfaceShapes() {
      LatLon position = new LatLon(Angle.fromDegrees(38), Angle.fromDegrees(-105));

      ArrayList<LatLon> surfaceLinePositions = new ArrayList<LatLon>();
      //            surfaceLinePositions.add(LatLon.fromDegrees(37.8484, -119.9754));
      //            surfaceLinePositions.add(LatLon.fromDegrees(38.3540, -119.1526));

      //            surfaceLinePositions.add(new LatLon(Angle.fromDegrees(0),
      // Angle.fromDegrees(-150)));
      //            surfaceLinePositions.add(new LatLon(Angle.fromDegrees(60),
      // Angle.fromDegrees(0)));

      surfaceLinePositions.add(position);
      surfaceLinePositions.add(LatLon.fromDegrees(39, -104));
      surfaceLinePositions.add(LatLon.fromDegrees(39, -105));
      surfaceLinePositions.add(position);

      return new Info[] {
        new Info("Circle", new SurfaceCircle(position, 100e3)),
        new Info("Ellipse", new SurfaceEllipse(position, 100e3, 90e3, Angle.ZERO)),
        new Info("Square", new SurfaceSquare(position, 100e3)),
        new Info("Quad", new SurfaceQuad(position, 100e3, 60e3, Angle.ZERO)),
        new Info("Sector", new SurfaceSector(Sector.fromDegrees(38, 40, -105, -103))),
        new Info("Polygon", new SurfacePolygon(surfaceLinePositions)),
      };
    }
    protected void performIntersectionTests(final Position curPos) throws InterruptedException {
      // Clear the results lists when the user selects a new location.
      this.firstIntersectionPositions.clear();
      this.sightLines.clear();

      // Raise the selected location and the grid points a little above ground just to show we can.
      final double height = 5; // meters

      // Form the grid.
      double gridRadius = GRID_RADIUS.degrees;
      Sector sector =
          Sector.fromDegrees(
              curPos.getLatitude().degrees - gridRadius, curPos.getLatitude().degrees + gridRadius,
              curPos.getLongitude().degrees - gridRadius,
                  curPos.getLongitude().degrees + gridRadius);

      this.grid = buildGrid(sector, height, GRID_DIMENSION, GRID_DIMENSION);
      this.numGridPoints = grid.size();

      // Compute the position of the selected location (incorporate its height).
      this.referencePosition = new Position(curPos.getLatitude(), curPos.getLongitude(), height);
      this.referencePoint =
          terrain.getSurfacePoint(curPos.getLatitude(), curPos.getLongitude(), height);

      //            // Pre-caching is unnecessary and is useful only when it occurs before the
      // intersection
      //            // calculations. It will incur extra overhead otherwise. The normal intersection
      // calculations
      //            // cause the same caching, making subsequent calculations on the same area
      // faster.
      //            this.preCache(grid, this.referencePosition);

      // On the EDT, show the grid.
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              progressBar.setValue(0);
              progressBar.setString(null);
              clearLayers();
              showGrid(grid, referencePosition);
              getWwd().redraw();
            }
          });

      // Perform the intersection calculations.
      this.startTime = System.currentTimeMillis();
      for (Position gridPos : this.grid) // for each grid point.
      {
        //noinspection ConstantConditions
        if (NUM_THREADS > 0) this.threadPool.execute(new Intersector(gridPos));
        else performIntersection(gridPos);
      }
    }
/**
 * Illustrates rotating a {@link gov.nasa.worldwind.geom.Sector} from standard position. A <code>
 * Sector</code> is created, its width and height computed, and a {@link
 * gov.nasa.worldwind.render.SurfaceQuad} created from the <code>sector's</code> centroid and the
 * computed width and height. The <code>SurfaceQuad's</code> heading is then set to the desired
 * rotation angle.
 *
 * @author tag
 * @version $Id$
 */
public class RotatedSector extends ApplicationTemplate {
  private static final Sector sector = Sector.fromDegrees(45, 47, -123, -122);

  public static class AppFrame extends ApplicationTemplate.AppFrame {
    public AppFrame() {
      super(true, true, false);

      try {
        // Create the Quad from a Sector
        Globe globe = this.getWwd().getModel().getGlobe();
        double radius = globe.getRadiusAt(sector.getCentroid());
        double quadWidth = sector.getDeltaLonRadians() * radius;
        double quadHeight = sector.getDeltaLatRadians() * radius;
        final SurfaceQuad quad =
            new SurfaceQuad(sector.getCentroid(), quadWidth, quadHeight, Angle.ZERO);

        // Create the layer to hold it
        final RenderableLayer layer = new RenderableLayer();
        layer.setName("Rotating Sector");
        layer.addRenderable(quad);

        // Add the layer to the model and update the ApplicationTemplate's layer manager
        insertBeforeCompass(this.getWwd(), layer);
        this.getLayerPanel().update(this.getWwd());

        // Rotate the quad continuously
        Timer timer =
            new Timer(
                50,
                new ActionListener() {
                  public void actionPerformed(ActionEvent actionEvent) {
                    // Increment the current heading if the layer is visible
                    if (layer.isEnabled()) {
                      quad.setHeading(
                          Angle.fromDegrees((quad.getHeading().getDegrees() + 1) % 360));
                      getWwd().redraw();
                    }
                  }
                });
        timer.start();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }

  public static void main(String[] args) {
    ApplicationTemplate.start("Rotated Sector", AppFrame.class);
  }
}
Пример #4
0
    private Info[] buildFreeShapes() {
      double elevation = 10e3;
      ArrayList<Position> positions = new ArrayList<Position>();
      positions.add(
          new Position(Angle.fromDegrees(37.8484), Angle.fromDegrees(-119.9754), elevation));
      positions.add(
          new Position(Angle.fromDegrees(39.3540), Angle.fromDegrees(-110.1526), elevation));
      positions.add(
          new Position(Angle.fromDegrees(38.3540), Angle.fromDegrees(-100.1526), elevation));

      ArrayList<Position> positions2 = new ArrayList<Position>();
      positions2.add(new Position(Angle.fromDegrees(0), Angle.fromDegrees(-150), elevation));
      positions2.add(new Position(Angle.fromDegrees(25), Angle.fromDegrees(-75), elevation));
      positions2.add(new Position(Angle.fromDegrees(50), Angle.fromDegrees(0), elevation));

      ArrayList<Position> positions3 = new ArrayList<Position>();
      for (double lat = 42, lon = -100; lat <= 45; lat += .1, lon += .1) {
        positions3.add(new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lon), elevation));
      }

      ArrayList<Position> positions4 = new ArrayList<Position>();
      positions4.add(new Position(Angle.fromDegrees(90), Angle.fromDegrees(-110), elevation));
      positions4.add(new Position(Angle.fromDegrees(-90), Angle.fromDegrees(-110), elevation));

      ArrayList<Position> positions5 = new ArrayList<Position>();
      for (int i = 0; i < 100; i++) {
        positions5.add(
            Position.fromDegrees(38.0 + i * 0.0001, 30.0 + i * 0.0001, 1000.0 + i * 5.0));
      }

      @SuppressWarnings({"UnnecessaryLocalVariable"})
      Info[] infos =
          new Info[] {
            new Info("Short Path", new Polyline(positions)),
            new Info("Long Path", new Polyline(positions2)),
            new Info("Incremental Path", new Polyline(positions3)),
            new Info("Vertical Path", new Polyline(positions4)),
            new Info("Small-segment Path", new Polyline(positions5)),
            new Info("Quad", new Quadrilateral(Sector.fromDegrees(38, 40, -104, -105), elevation)),
            new Info("None", null)
          };

      return infos;
    }
    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());
    }