Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
0
  /**
   * 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);
        }
      }
    }
  }