예제 #1
0
  /** {@inheritDoc } */
  @Override
  protected Map<String, String> toString(final Envelope env) {
    final Map<String, String> map = new HashMap<String, String>();
    final StringBuilder sb = new StringBuilder();
    final double minx = env.getMinimum(0);
    final double maxx = env.getMaximum(0);
    final double miny = env.getMinimum(1);
    final double maxy = env.getMaximum(1);
    sb.append(minx).append(',').append(miny).append(',').append(maxx).append(',').append(maxy);

    map.put("BBOX", sb.toString());

    try {
      String code = IdentifiedObjects.lookupIdentifier(env.getCoordinateReferenceSystem(), true);
      if (code == null) {
        code =
            IdentifiedObjects.lookupIdentifier(
                CRSUtilities.getCRS2D(env.getCoordinateReferenceSystem()), true);
      }
      map.put("CRS", code);
    } catch (FactoryException ex) {
      LOGGER.log(Level.WARNING, null, ex);
    } catch (TransformException ex) {
      LOGGER.log(Level.WARNING, null, ex);
    }

    encodeNDParameters(env, map);

    return map;
  }
  /** {@inheritDoc } */
  @Override
  public void setGraphicsCRS(CoordinateReferenceSystem crs) throws TransformException {

    if (crs == displayCRS) {
      switchToDisplayCRS();
    } else if (crs == objectiveCRS || crs == objectiveCRS2D) {
      switchToObjectiveCRS();
    } else
      try {
        crs = CRSUtilities.getCRS2D(crs);
        AffineTransform at = getAffineTransform(crs, displayCRS);
        at.preConcatenate(displayToDevice);
        current = OTHER_TRS;
        graphics.setTransform(at);
      } catch (FactoryException e) {
        throw new TransformException(
            Errors.format(Errors.Keys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM), e);
      }
  }
예제 #3
0
 private Map<String, String> toString(final Envelope envelope) {
   final Map<String, String> params = new HashMap<String, String>();
   final StringBuilder sb = new StringBuilder();
   final double minx = envelope.getMinimum(0);
   final double maxx = envelope.getMaximum(0);
   final double miny = envelope.getMinimum(1);
   final double maxy = envelope.getMaximum(1);
   sb.append(minx).append(',').append(miny).append(',').append(maxx).append(',').append(maxy);
   if (envelope.getDimension() > 2) {
     sb.append(',').append(envelope.getMinimum(2)).append(',').append(envelope.getMaximum(2));
   }
   params.put("BBOX", sb.toString());
   try {
     CoordinateReferenceSystem crs2d =
         CRSUtilities.getCRS2D(envelope.getCoordinateReferenceSystem());
     params.put("CRS", IdentifiedObjects.lookupIdentifier(crs2d, true));
   } catch (FactoryException ex) {
     LOGGER.log(Level.WARNING, null, ex);
   } catch (TransformException ex) {
     LOGGER.log(Level.WARNING, null, ex);
   }
   return params;
 }