コード例 #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;
  }
コード例 #2
0
 /** {@inheritDoc } */
 @Override
 public URL getURL() throws MalformedURLException {
   if (coverage == null) {
     throw new IllegalArgumentException("Coverage is not defined");
   }
   if (envelope == null) {
     throw new IllegalArgumentException("An envelope must be defined");
   }
   if (format == null) {
     throw new IllegalArgumentException("Format is not defined");
   }
   requestParameters.put("SERVICE", "WCS");
   requestParameters.put("REQUEST", "GetCoverage");
   requestParameters.put("VERSION", version);
   requestParameters.put("COVERAGE", coverage);
   requestParameters.putAll(toString(envelope));
   requestParameters.put("FORMAT", format);
   if (time != null) {
     requestParameters.put("TIME", time);
   }
   if (dimension != null) {
     requestParameters.put("WIDTH", String.valueOf(dimension.width));
     requestParameters.put("HEIGHT", String.valueOf(dimension.height));
     if (depth != null) {
       requestParameters.put("DEPTH", String.valueOf(depth));
     }
   }
   if (resX != null && resY != null) {
     requestParameters.put("RESX", String.valueOf(resX));
     requestParameters.put("RESY", String.valueOf(resY));
     if (resZ != null) {
       requestParameters.put("RESZ", String.valueOf(resZ));
     }
   }
   if (exceptions != null) {
     requestParameters.put("EXCEPTIONS", exceptions);
   }
   if (responseCRS != null) {
     try {
       requestParameters.put(
           "RESPONSECRS", IdentifiedObjects.lookupIdentifier(responseCRS, false));
     } catch (FactoryException ex) {
       LOGGER.log(Level.WARNING, null, ex);
     }
   }
   return super.getURL();
 }
コード例 #3
0
  private Element writeBounds(final Envelope bounds, final Document document) {
    if (bounds != null) {

      String srsName = null;
      if (bounds.getCoordinateReferenceSystem() != null) {
        try {
          srsName =
              IdentifiedObjects.lookupIdentifier(
                  Citations.URN_OGC, bounds.getCoordinateReferenceSystem(), true);
        } catch (FactoryException ex) {
          LOGGER.log(Level.WARNING, null, ex);
        }
      }
      final Element boundElement = document.createElementNS(Namespaces.GML, "boundedBy");
      boundElement.setPrefix("gml");
      final Element envElement = document.createElementNS(Namespaces.GML, "Envelope");
      envElement.setPrefix("gml");
      if (srsName != null) {
        envElement.setAttribute("srsName", srsName);
      } else {
        envElement.setAttribute("srsName", "");
      }

      // lower corner
      final Element lower = document.createElementNS(Namespaces.GML, "lowerCorner");
      String lowValue =
          bounds.getLowerCorner().getOrdinate(0) + " " + bounds.getLowerCorner().getOrdinate(1);
      lower.setTextContent(lowValue);
      lower.setPrefix("gml");
      envElement.appendChild(lower);

      // upper corner
      final Element upper = document.createElementNS(Namespaces.GML, "upperCorner");
      String uppValue =
          bounds.getUpperCorner().getOrdinate(0) + " " + bounds.getUpperCorner().getOrdinate(1);
      upper.setTextContent(uppValue);
      upper.setPrefix("gml");
      envElement.appendChild(upper);

      boundElement.appendChild(envElement);
      return boundElement;
    }
    return null;
  }
コード例 #4
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 {
      map.put("CRS", IdentifiedObjects.lookupIdentifier(env.getCoordinateReferenceSystem(), true));
    } catch (FactoryException ex) {
      LOGGER.log(Level.WARNING, null, ex);
    }

    encodeTimeAndElevation(env, map);

    return map;
  }
コード例 #5
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;
 }