Пример #1
0
  /** Get all the graphics from the shapefile, colored appropriately. */
  public OMGraphicList getGraphics() {
    if (omgraphics == null) {
      omgraphics = new OMGraphicList();
      try {
        spatialIndex.getOMGraphics(
            -180, -90, 180, 90, omgraphics, drawingAttributes, (Projection) null, coordTransform);

        updateDrawingParameters(omgraphics);

      } catch (IOException ioe) {
        Debug.error(ioe.getMessage());
      } catch (FormatException fe) {
        Debug.error(fe.getMessage());
      }
    }
    return omgraphics;
  }
Пример #2
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;
  }