Example #1
0
  /**
   * Convert to a geocentric frame using a LatLonPoint.
   *
   * @param llpt
   * @return a vector of ecef values
   */
  public double[] toGeocentricFrame(LatLonPoint llpt) {
    // All calculations are done using radians!
    double ecef[] = new double[3];
    double ned[] = new double[3];
    double lat_ = (double) llpt.getLatitude();
    double lon_ = (double) llpt.getLongitude();
    double latitude = ProjMath.degToRad(lat_);
    double longitude = ProjMath.degToRad(lon_);

    ned2ecef(ned, latitude, longitude, ecef);

    return ecef;
  }
Example #2
0
  public void actionPerformed(ActionEvent ae) {
    if (map != null) {
      Proj proj = (Proj) map.getProjection();
      DataBounds bounds = provider.getDataBounds();

      if (bounds != null) {
        java.awt.geom.Point2D center = bounds.getCenter();
        if (center != null) {
          proj.setCenter((float) center.getY(), (float) center.getX());
          LatLonPoint llp1 = new LatLonPoint(bounds.getMax().getY(), bounds.getMin().getX());

          LatLonPoint llp2 = new LatLonPoint(bounds.getMin().getY(), bounds.getMax().getX());

          // 1.1 buffers the edges for viewing a little, a
          // little zommed out.
          proj.setScale(ProjMath.getScale(llp1, llp2, proj) * 1.1f);
          map.setProjection(proj);
        }
      } else {
        String complaint =
            "Can't move map over data: " + provider.getName() + " isn't ready.  Add to map?";
        if (infoDelegator != null) {
          infoDelegator.displayMessage("Go Over Data", complaint);
        } else {
          Debug.error(complaint);
        }
      }
    }
  }
Example #3
0
  public void createLabels() {
    labels.clear();
    points.clear();

    if (rawllpts == null) {
      return;
    }
    if (rawllpts.length < 4) {
      return;
    }

    Geo lastGeo = new Geo(rawllpts[0], rawllpts[1], units == DECIMAL_DEGREES);
    double latpnt = rawllpts[0];
    double lonpnt = rawllpts[1];
    if (units == RADIANS) {
      latpnt = ProjMath.radToDeg(latpnt);
      lonpnt = ProjMath.radToDeg(lonpnt);
    }
    points.add(new OMPoint(latpnt, lonpnt, 1));
    Geo curGeo = null;
    double cumulativeDist = 0.0;
    for (int p = 2; p < rawllpts.length; p += 2) {
      if (curGeo == null) {
        curGeo = new Geo(rawllpts[p], rawllpts[p + 1], units == DECIMAL_DEGREES);
      } else {
        if (units == DECIMAL_DEGREES) {
          curGeo.initialize(rawllpts[p], rawllpts[p + 1]);
        } else {
          curGeo.initializeRadians(rawllpts[p], rawllpts[p + 1]);
        }
      }

      double dist = getDist(lastGeo, curGeo);
      cumulativeDist += dist;

      labels.add(createLabel(lastGeo, curGeo, dist, cumulativeDist, distUnits));
      latpnt = rawllpts[p];
      lonpnt = rawllpts[p + 1];
      if (units == RADIANS) {
        latpnt = ProjMath.radToDeg(latpnt);
        lonpnt = ProjMath.radToDeg(lonpnt);
      }

      points.add(new OMPoint(latpnt, lonpnt, 1));
      lastGeo.initialize(curGeo);
    }
  }
Example #4
0
 public void setLocation(double[] llPoints, int units) {
   this.units = OMGraphic.RADIANS;
   if (units == OMGraphic.DECIMAL_DEGREES) {
     ProjMath.arrayDegToRad(llPoints);
   }
   rawllpts = llPoints;
   setNeedToRegenerate(true);
   setRenderType(RENDERTYPE_LATLON);
 }
Example #5
0
  /**
   * Construct a NedFrame from ECEF vector and latitude and longitude.
   *
   * @param x ecef x.
   * @param y ecef y.
   * @param z ecef z.
   * @param lat = latitude in degrees.
   * @param lon = longitude in degrees.
   */
  public NedFrame(float x, float y, float z, double lat, double lon) {
    // All calculations are done using radians!

    double ecef[] = new double[3];
    double ned[] = new double[3];

    double latitude = ProjMath.degToRad(lat);
    double longitude = ProjMath.degToRad(lon);

    ecef[0] = x;
    ecef[1] = y;
    ecef[2] = z;

    ecef2ned(ned, latitude, longitude, ecef);

    this.x = (float) ned[0];
    this.y = (float) ned[1];
    this.z = (float) ned[2];
  }
Example #6
0
  /**
   * Construct a NedFrame from a ECEF vector and a LatLonPoint.
   *
   * @param ecefVector
   */
  public NedFrame(double[] ecefVector, LatLonPoint llpt) {
    // All calculations are done using radians!

    double ecef[] = new double[3];
    double ned[] = new double[3];
    double lat_ = (double) llpt.getLatitude();
    double lon_ = (double) llpt.getLongitude();
    double latitude = ProjMath.degToRad(lat_);
    double longitude = ProjMath.degToRad(lon_);

    ecef[0] = ecefVector[0];
    ecef[1] = ecefVector[1];
    ecef[2] = ecefVector[2];

    ecef2ned(ned, latitude, longitude, ecef);

    this.x = (float) ned[0];
    this.y = (float) ned[1];
    this.z = (float) ned[2];
  }
Example #7
0
  /**
   * Return the distance between that lat/lons defined in radians. The returned value is in radians
   * and LINETYPE is taken into consideration. LINETYPE_STRAIGHT returns same as
   * LINETYPE_GREATCIRCLE, the ground distance between all nodes and not the degree distance of the
   * lines.
   */
  public double getDist(Geo g1, Geo g2) {
    switch (getLineType()) {
      case LINETYPE_RHUMB:
        double[] coords =
            new double[] {
              g1.getLatitudeRadians(),
              g1.getLongitudeRadians(),
              g2.getLatitudeRadians(),
              g2.getLongitudeRadians()
            };
        return ProjMath.distance(LineCoordinateGenerator.fromRadians(coords).rhumbLineDoubles());

      case LINETYPE_STRAIGHT:
      case LINETYPE_GREATCIRCLE:
      case LINETYPE_UNKNOWN:
      default:
        return g1.distance(g2);
    }
  }
Example #8
0
  /**
   * Get the graphics for a particular lat/lon area.
   *
   * @param ulLat upper left latitude, in decimal degrees.
   * @param ulLon upper left longitude, in decimal degrees.
   * @param lrLat lower right latitude, in decimal degrees.
   * @param lrLon lower right longitude, in decimal degrees.
   * @param proj the current map projection.
   * @return OMGraphicList
   */
  public OMGraphicList getGraphics(
      double ulLat, double ulLon, double lrLat, double lrLon, Projection proj) {

    if (cacheURL != null) {
      return omgraphics;
    }

    if (spatialIndex == null) {
      return new OMGraphicList();
    }

    if (politicalAreas == null) {
      initialize(originalPrefix, originalProperties);
    }

    OMGraphicList list = new OMGraphicList();

    // check for dateline anomaly on the screen. we check for
    // ulLon >= lrLon, but we need to be careful of the check for
    // equality because of floating point arguments...
    if (ProjMath.isCrossingDateline(ulLon, lrLon, proj.getScale())) {
      if (Debug.debugging("areas")) {
        Debug.output("AreaHander.getGraphics(): Dateline is on screen");
      }

      double ymin = Math.min(ulLat, lrLat);
      double ymax = Math.max(ulLat, lrLat);

      try {

        list =
            spatialIndex.getOMGraphics(
                ulLon, ymin, 180.0d, ymax, list, drawingAttributes, proj, coordTransform);
        list =
            spatialIndex.getOMGraphics(
                -180.0d, ymin, lrLon, ymax, list, drawingAttributes, proj, coordTransform);

      } catch (InterruptedIOException iioe) {
        // This means that the thread has been interrupted,
        // probably due to a projection change. Not a big
        // deal, just return, don't do any more work, and let
        // the next thread solve all problems.
        list = null;
      } catch (IOException ex) {
        ex.printStackTrace();
      } catch (FormatException fe) {
        fe.printStackTrace();
      }

    } else {

      double xmin = (double) Math.min(ulLon, lrLon);
      double xmax = (double) Math.max(ulLon, lrLon);
      double ymin = (double) Math.min(ulLat, lrLat);
      double ymax = (double) Math.max(ulLat, lrLat);
      try {
        list =
            spatialIndex.getOMGraphics(
                xmin, ymin, xmax, ymax, list, drawingAttributes, proj, coordTransform);
      } catch (InterruptedIOException iioe) {
        // This means that the thread has been interrupted,
        // probably due to a projection change. Not a big
        // deal, just return, don't do any more work, and let
        // the next thread solve all problems.
        list = null;
      } catch (java.io.IOException ex) {
        ex.printStackTrace();
      } catch (FormatException fe) {
        fe.printStackTrace();
      }
    }

    updateDrawingParameters(list);
    return list;
  }
  /**
   * Get the map coverage
   *
   * @param ullat
   * @param ullon
   * @param lrlat
   * @param lrlon
   * @param proj projection for display
   * @param chartSeries the chart series to query for, may be null for all coverages
   * @param coverages The Map to be modified
   */
  protected void getCatalogCoverage(
      double ullat,
      double ullon,
      double lrlat,
      double lrlon,
      Projection proj,
      String chartSeries,
      Map<RpfProductInfo, RpfCoverage.RpfCoverageControl> coverages) {

    Debug.message("rpfcov", "RpfCoverageManager: Getting catalog coverage from RpfFrameProvider");
    if (proj == null || frameProvider == null) {
      return;
    }

    CADRG cadrg;
    if (proj instanceof CADRG) {
      cadrg = (CADRG) proj;
    } else {
      cadrg =
          new CADRG(
              (LatLonPoint) proj.getCenter(new LatLonPoint.Float()),
              proj.getScale(),
              proj.getWidth(),
              proj.getHeight());
    }

    List<RpfCoverageBox> hemisphereData = new ArrayList<RpfCoverageBox>();

    if (ProjMath.isCrossingDateline(ullon, lrlon, proj.getScale())) {

      hemisphereData.addAll(
          frameProvider.getCatalogCoverage(ullat, ullon, lrlat, 180f, cadrg, chartSeries));
      hemisphereData.addAll(
          frameProvider.getCatalogCoverage(ullat, -180f, lrlat, lrlon, cadrg, chartSeries));
    } else {
      hemisphereData.addAll(
          frameProvider.getCatalogCoverage(ullat, ullon, lrlat, lrlon, cadrg, chartSeries));
    }

    boolean checkSeries =
        !(chartSeries == null
            || chartSeries.equals(RpfViewAttributes.ANY)
            || chartSeries.equals(RpfViewAttributes.ALL));

    for (RpfCoverageBox box : hemisphereData) {

      OMRect rect = new OMRect(box.nw_lat, box.nw_lon, box.se_lat, box.se_lon, currentLineType);

      RpfProductInfo rpi = RpfProductInfo.get(box.chartCode);

      if (rpi != null) {

        if (checkSeries && !rpi.seriesCode.equalsIgnoreCase(chartSeries)) {
          continue;
        }

        RpfCoverage.RpfCoverageControl control = coverages.get(rpi);
        if (control != null) {
          control.add(rect);
          rect.generate(proj);
        }
      }
    }
  }