public void createRenderables() {
      this.gridElements = new ArrayList<GridElement>();
      double gridStep = this.size / 10;
      Position p1, p2;
      ArrayList<Position> positions = new ArrayList<Position>();

      // South-North lines
      for (int i = 1; i <= 9; i++) {
        double easting = this.SWEasting + gridStep * i;
        positions.clear();
        p1 = computePosition(this.UTMZone, this.hemisphere, easting, SWNorthing);
        p2 = computePosition(this.UTMZone, this.hemisphere, easting, SWNorthing + this.size);
        if (this.isTruncated) {
          computeTruncatedSegment(p1, p2, this.UTMZoneSector, positions);
        } else {
          positions.add(p1);
          positions.add(p2);
        }
        if (positions.size() > 0) {
          p1 = positions.get(0);
          p2 = positions.get(1);
          Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
          Sector lineSector = Sector.boundingSector(p1, p2);
          GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_EASTING);
          ge.setValue(easting);
          this.gridElements.add(ge);
        }
      }
      // West-East lines
      for (int i = 1; i <= 9; i++) {
        double northing = this.SWNorthing + gridStep * i;
        positions.clear();
        p1 = computePosition(this.UTMZone, this.hemisphere, SWEasting, northing);
        p2 = computePosition(this.UTMZone, this.hemisphere, SWEasting + this.size, northing);
        if (this.isTruncated) {
          computeTruncatedSegment(p1, p2, this.UTMZoneSector, positions);
        } else {
          positions.add(p1);
          positions.add(p2);
        }
        if (positions.size() > 0) {
          p1 = positions.get(0);
          p2 = positions.get(1);
          Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
          Sector lineSector = Sector.boundingSector(p1, p2);
          GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_NORTHING);
          ge.setValue(northing);
          this.gridElements.add(ge);
        }
      }
    }
  protected static ArrayList<Position> computeElevations(ArrayList<Position> locations) {
    Sector sector = Sector.boundingSector(locations);
    HighResolutionTerrain hrt = new HighResolutionTerrain(new Earth(), sector, null, 1.0);

    ArrayList<Position> computedPositions = new ArrayList<Position>();
    for (LatLon latLon : locations) {
      Double elevation = hrt.getElevation(latLon);
      computedPositions.add(new Position(latLon, Math.round(elevation * 10000.0) / 10000.0));
    }

    return computedPositions;
  }
Пример #3
0
  public void setPositions(ArrayList<? extends Position> positions) {
    if (positions == null) {
      String message = Logging.getMessage("nullValue.PositionsListIsNull");
      Logging.error(message);
      throw new IllegalArgumentException(message);
    }

    this.positions = positions;
    if (this.positions.size() > 2) this.sector = Sector.boundingSector(this.positions);
    else this.sector = null;

    clearCachedValues();
  }
  public boolean isSameSector(Iterable<? extends LatLon> corners) {
    if (corners == null) {
      throw new IllegalArgumentException("Locations List Is Null");
    }

    if (!isSector(corners)) {
      return false;
    }

    Sector s = Sector.boundingSector(corners);

    return s.equals(this);
  }
  public static VirtualEarthTile[] createTiles(
      Sector bbox /*int wwLevel, int wwRow, int wwCol*/, VirtualEarthLayer layer)
      throws WWRuntimeException {
    if (null == bbox) {
      String message = Logging.getMessage("nullValue.SectorIsNull");
      Logging.logger().severe(message);
      throw new WWRuntimeException(message);
    }

    if (null == layer) {
      String message = Logging.getMessage("nullValue.LayerIsNull");
      Logging.logger().severe(message);
      throw new WWRuntimeException(message);
    }

    int level = getZoomLevelByTrueViewRange(bbox.getDeltaLatDegrees());

    Point startPixel =
        LatLongToPixelXY(bbox.getMaxLatitude().degrees, bbox.getMinLongitude().degrees, level);
    Point endPixel =
        LatLongToPixelXY(bbox.getMinLatitude().degrees, bbox.getMaxLongitude().degrees, level);

    Point startTile = PixelXYToTileXY(startPixel.x, startPixel.y);
    Point endTile = PixelXYToTileXY(endPixel.x, endPixel.y);

    ArrayList<VirtualEarthTile> tileList = new ArrayList<VirtualEarthTile>();

    for (int y = startTile.y; y <= endTile.y; y++) {
      for (int x = startTile.x; x <= endTile.x; x++) {
        try {
          int ulPixelX = x * VE_MAX_TILE_SIZE;
          int ulPixelY = y * VE_MAX_TILE_SIZE;
          LatLon ul = PixelXYToLatLong(ulPixelX, ulPixelY, level);

          int lrPixelX = ulPixelX + VE_MAX_TILE_SIZE;
          int lrPixelY = ulPixelY + VE_MAX_TILE_SIZE;
          LatLon lr = PixelXYToLatLong(lrPixelX, lrPixelY, level);

          Sector tileSector = Sector.boundingSector(ul, lr);

          tileList.add(new VirtualEarthTile(x, y, level, layer, tileSector));
        } catch (Exception ex) {
          Logging.logger().log(Level.SEVERE, ex.getMessage(), ex);
        }
      }
    }

    VirtualEarthTile[] tiles = new VirtualEarthTile[tileList.size()];
    return tileList.toArray(tiles);
  }
Пример #6
0
 @Override
 public Sector getExtent() {
   if (isEnabled()) {
     final List<Sphere> panoramicsBounds = new ArrayList<Sphere>();
     for (final GPanoramic panoramic : _panoramics) {
       panoramicsBounds.add(panoramic.getGlobalBounds());
     }
     final Globe globe = GGlobeApplication.instance().getGlobe();
     final Sphere totalbounds = Sphere.createBoundingSphere(panoramicsBounds);
     final Sector totalSector =
         Sector.boundingSector(
             globe,
             globe.computePositionFromPoint(totalbounds.getCenter()),
             totalbounds.getRadius());
     return totalSector;
   }
   return null;
 }
Пример #7
0
 // manages change of attributes for highlighting, annotation bubble toggle, event firing
 private void internalHighlight(SurfaceShape shape, boolean noDeselect) {
   if (!highlightingEnabled) {
     return;
   }
   String shpId = (String) shape.getValue(AVKey.HOVER_TEXT);
   // if annotation visible and same shape
   if (shape.equals(prevPopupShape) && shape.isHighlighted()) {
     if (!noDeselect) {
       // hide annotation and de-highlight
       popupAnnotation.getAttributes().setVisible(false);
       shape.setHighlighted(false);
       // forget previous highlighted shape and fire deselection event
       prevPopupShape = null;
       firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, shpId, null));
     }
   } else {
     if (showAnnotation) {
       // find shape centroid
       final Sector boundingSector =
           Sector.boundingSector(shape.getLocations(wwd.getModel().getGlobe()));
       Position centroid = new Position(boundingSector.getCentroid(), 0d);
       // prepare and show annotation
       popupAnnotation.setText(shpId);
       popupAnnotation.setPosition(centroid);
       popupAnnotation.getAttributes().setVisible(true);
     }
     // highlight shape
     shape.setHighlighted(true);
     if (prevPopupShape != null) {
       // de-highlight previous shape and fire deselection event
       prevPopupShape.setHighlighted(false);
       firePropertyChange(
           new PropertyChangeEvent(
               this, PROPERTY_SELECTION, prevPopupShape.getValue(AVKey.HOVER_TEXT), shpId));
     } else {
       // fire event only
       firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, null, shpId));
     }
     // remember shape
     prevPopupShape = shape;
   }
 }
Пример #8
0
    @Override
    public void render(DrawContext dc) {
      if (dc.isPickingMode() && this.isResizeable()) return;

      // This is called twice: once during normal rendering, then again during ordered surface
      // rendering. During
      // normal renering we render both the interior and border shapes. During ordered surface
      // rendering, both
      // shapes are already added to the DrawContext and both will be individually processed.
      // Therefore we just
      // call our superclass behavior
      if (dc.isOrderedRenderingMode()) {
        super.render(dc);
        return;
      }

      if (!this.isResizeable()) {
        if (this.hasSelection()) {
          this.doRender(dc);
        }
        return;
      }

      PickedObjectList pos = dc.getPickedObjects();
      PickedObject terrainObject = pos != null ? pos.getTerrainObject() : null;

      if (terrainObject == null) return;

      if (this.getStartPosition() != null) {
        Position end = terrainObject.getPosition();
        if (!this.getStartPosition().equals(end)) {
          this.setEndPosition(end);
          this.setSector(Sector.boundingSector(this.getStartPosition(), this.getEndPosition()));
          this.doRender(dc);
        }
      } else {
        this.setStartPosition(pos.getTerrainObject().getPosition());
      }
    }
    public SquareSector(
        int UTMZone,
        String hemisphere,
        Sector UTMZoneSector,
        double SWEasting,
        double SWNorthing,
        double size) {
      this.UTMZone = UTMZone;
      this.hemisphere = hemisphere;
      this.UTMZoneSector = UTMZoneSector;
      this.SWEasting = SWEasting;
      this.SWNorthing = SWNorthing;
      this.size = size;

      // Compute corners positions
      this.sw = computePosition(this.UTMZone, this.hemisphere, SWEasting, SWNorthing);
      this.se = computePosition(this.UTMZone, this.hemisphere, SWEasting + size, SWNorthing);
      this.nw = computePosition(this.UTMZone, this.hemisphere, SWEasting, SWNorthing + size);
      this.ne = computePosition(this.UTMZone, this.hemisphere, SWEasting + size, SWNorthing + size);
      this.squareCenter =
          computePosition(
              this.UTMZone, this.hemisphere, SWEasting + size / 2, SWNorthing + size / 2);

      // Compute approximate bounding sector and center point
      if (this.sw != null && this.se != null && this.nw != null && this.ne != null) {
        adjustDateLineCrossingPoints();
        this.boundingSector = Sector.boundingSector(Arrays.asList(sw, se, nw, ne));
        if (!isInsideGridZone())
          this.boundingSector = this.UTMZoneSector.intersection(this.boundingSector);

        this.centroid =
            this.boundingSector != null ? this.boundingSector.getCentroid() : this.squareCenter;
        // this.squareCenter = this.boundingSector.getCentroid();
      }

      // Check whether this square is truncated by the grid zone boundary
      this.isTruncated = !isInsideGridZone();
    }
Пример #10
0
  protected List<Sector> computeSectors(DrawContext dc) {
    if (this.locations == null || !this.locations.iterator().hasNext()) return null;

    // Compute all locations bounding sector, then add some padding for the icon half diagonal
    // extent
    Sector sector = Sector.boundingSector(this.locations);
    // Compute padding
    double minCosLat = Math.min(sector.getMinLatitude().cos(), sector.getMaxLatitude().cos());
    minCosLat = Math.max(minCosLat, .01); // avoids division by zero at the poles
    Rectangle2D iconDimension = this.computeDrawDimension(dc, sector.getCentroid());
    double diagonalLength =
        Math.sqrt(
            iconDimension.getWidth() * iconDimension.getWidth()
                + iconDimension.getHeight() * iconDimension.getHeight());
    double padLatRadians = diagonalLength / 2 / dc.getGlobe().getRadius();
    double padLonRadians = diagonalLength / 2 / dc.getGlobe().getRadius() / minCosLat;
    // Apply padding to sector
    Angle minLat = sector.getMinLatitude().subtractRadians(padLatRadians);
    Angle maxLat = sector.getMaxLatitude().addRadians(padLatRadians);
    Angle minLon = sector.getMinLongitude().subtractRadians(padLonRadians);
    Angle maxLon = sector.getMaxLongitude().addRadians(padLatRadians);

    return this.computeNormalizedSectors(new Sector(minLat, maxLat, minLon, maxLon));
  }
    public void createRenderables() {
      this.gridElements = new ArrayList<GridElement>();

      ArrayList<Position> positions = new ArrayList<Position>();
      Position p1, p2;
      Object polyline;
      Sector lineSector;

      // left segment
      positions.clear();
      if (this.isTruncated) {
        computeTruncatedSegment(sw, nw, this.UTMZoneSector, positions);
      } else {
        positions.add(sw);
        positions.add(nw);
      }
      if (positions.size() > 0) {
        p1 = positions.get(0);
        p2 = positions.get(1);
        polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
        lineSector = Sector.boundingSector(p1, p2);
        GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_WEST);
        ge.setValue(this.SWEasting);
        this.gridElements.add(ge);
      }

      // right segment
      positions.clear();
      if (this.isTruncated) {
        computeTruncatedSegment(se, ne, this.UTMZoneSector, positions);
      } else {
        positions.add(se);
        positions.add(ne);
      }
      if (positions.size() > 0) {
        p1 = positions.get(0);
        p2 = positions.get(1);
        polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
        lineSector = Sector.boundingSector(p1, p2);
        GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_EAST);
        ge.setValue(this.SWEasting + this.size);
        this.gridElements.add(ge);
      }

      // bottom segment
      positions.clear();
      if (this.isTruncated) {
        computeTruncatedSegment(sw, se, this.UTMZoneSector, positions);
      } else {
        positions.add(sw);
        positions.add(se);
      }
      if (positions.size() > 0) {
        p1 = positions.get(0);
        p2 = positions.get(1);
        polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
        lineSector = Sector.boundingSector(p1, p2);
        GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_SOUTH);
        ge.setValue(this.SWNorthing);
        this.gridElements.add(ge);
      }

      // top segment
      positions.clear();
      if (this.isTruncated) {
        computeTruncatedSegment(nw, ne, this.UTMZoneSector, positions);
      } else {
        positions.add(nw);
        positions.add(ne);
      }
      if (positions.size() > 0) {
        p1 = positions.get(0);
        p2 = positions.get(1);
        polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
        lineSector = Sector.boundingSector(p1, p2);
        GridElement ge = new GridElement(lineSector, polyline, GridElement.TYPE_LINE_NORTH);
        ge.setValue(this.SWNorthing + this.size);
        this.gridElements.add(ge);
      }

      // Label
      if (this.name != null) {
        // Only add a label to squares above some dimension
        if (this.boundingSector.getDeltaLon().degrees
                    * Math.cos(this.centroid.getLatitude().radians)
                > .2
            && this.boundingSector.getDeltaLat().degrees > .2) {
          LatLon labelPos = null;
          if (this.UTMZone != 0) // Not at poles
          {
            labelPos = this.centroid;
          } else if (this.isPositionInside(new Position(this.squareCenter, 0))) {
            labelPos = this.squareCenter;
          } else if (this.squareCenter.getLatitude().degrees
                  <= this.UTMZoneSector.getMaxLatitude().degrees
              && this.squareCenter.getLatitude().degrees
                  >= this.UTMZoneSector.getMinLatitude().degrees) {
            labelPos = this.centroid;
          }
          if (labelPos != null) {
            GeographicText text = new UserFacingText(this.name, new Position(labelPos, 0));
            text.setPriority(this.size * 10);
            this.gridElements.add(
                new GridElement(this.boundingSector, text, GridElement.TYPE_GRIDZONE_LABEL));
          }
        }
      }
    }
Пример #12
0
  public Sector getBoundingSector() {
    if (this.sector == null && this.positions != null && this.positions.size() > 2)
      this.sector = Sector.boundingSector(this.positions);

    return this.sector;
  }