Exemplo n.º 1
0
  public Map<String, Object> grid() throws Exception {
    Element gridElement = ReaderUtils.getChildElement(coverage, "grid");
    if (gridElement == null) {
      return null;
    }

    HashMap<String, Object> grid = new HashMap<String, Object>();

    grid.put(
        "dimension", Integer.parseInt(ReaderUtils.getAttribute(gridElement, "dimension", true)));

    Element lowElement = ReaderUtils.getChildElement(gridElement, "low");
    String[] lows = lowElement.getFirstChild().getTextContent().trim().split(" ");
    int[] low = new int[lows.length];
    for (int i = 0; i < low.length; i++) {
      low[i] = Integer.parseInt(lows[i]);
    }
    grid.put("low", low);

    Element highElement = ReaderUtils.getChildElement(gridElement, "high");
    String[] highs = highElement.getFirstChild().getTextContent().trim().split(" ");
    int[] high = new int[highs.length];
    for (int i = 0; i < high.length; i++) {
      high[i] = Integer.parseInt(highs[i]);
    }
    grid.put("high", high);

    Element[] axisNameElements = ReaderUtils.getChildElements(gridElement, "axisName");
    String[] axisName = new String[axisNameElements.length];
    for (int i = 0; i < axisName.length; i++) {
      axisName[i] = axisNameElements[i].getFirstChild().getTextContent();
    }
    grid.put("axisName", axisName);

    Element geoTransformElement = ReaderUtils.getChildElement(gridElement, "geoTransform");
    if (geoTransformElement != null) {
      Map<String, Double> geoTransform = new HashMap<String, Double>();
      String scaleX = ReaderUtils.getChildText(geoTransformElement, "scaleX");
      String scaleY = ReaderUtils.getChildText(geoTransformElement, "scaleY");
      String shearX = ReaderUtils.getChildText(geoTransformElement, "shearX");
      String shearY = ReaderUtils.getChildText(geoTransformElement, "shearY");
      String translateX = ReaderUtils.getChildText(geoTransformElement, "translateX");
      String translateY = ReaderUtils.getChildText(geoTransformElement, "translateY");

      geoTransform.put("scaleX", scaleX != null ? new Double(scaleX) : null);
      geoTransform.put("scaleY", scaleY != null ? new Double(scaleY) : null);
      geoTransform.put("shearX", shearX != null ? new Double(shearX) : null);
      geoTransform.put("shearY", shearY != null ? new Double(shearY) : null);
      geoTransform.put("translateX", translateX != null ? new Double(translateX) : null);
      geoTransform.put("translateY", translateY != null ? new Double(translateY) : null);

      grid.put("geoTransform", geoTransform);
    }
    return grid;
  }
Exemplo n.º 2
0
 public List<String> styles() throws Exception {
   Element styleRoot = ReaderUtils.getChildElement(coverage, "styles");
   if (styleRoot != null) {
     List<String> styleNames = new ArrayList<String>();
     Element[] styles = ReaderUtils.getChildElements(styleRoot, "style");
     for (Element style : styles) {
       styleNames.add(style.getTextContent().trim());
     }
     return styleNames;
   } else {
     return Collections.emptyList();
   }
 }
Exemplo n.º 3
0
  public Map<String, Serializable> parameters() {
    Element parameters = ReaderUtils.getChildElement(coverage, "parameters");
    if (parameters == null) {
      return Collections.EMPTY_MAP;
    }

    HashMap<String, Serializable> map = new HashMap<String, Serializable>();
    Element[] parameter = ReaderUtils.getChildElements(parameters, "parameter");
    for (int i = 0; i < parameter.length; i++) {
      String name = parameter[i].getAttribute("name");
      String value = parameter[i].getAttribute("value");

      map.put(name, value);
    }

    return map;
  }
Exemplo n.º 4
0
  public List<Map> coverageDimensions() throws Exception {
    Element[] cdElements = ReaderUtils.getChildElements(coverage, "CoverageDimension");
    List<Map> cds = new ArrayList<Map>();
    for (int i = 0; i < cdElements.length; i++) {
      HashMap cd = new HashMap();
      cd.put("name", ReaderUtils.getChildText(cdElements[i], "name"));
      cd.put("description", ReaderUtils.getChildText(cdElements[i], "description"));

      Element intervalElement = ReaderUtils.getChildElement(cdElements[i], "interval");
      double min = Double.parseDouble(ReaderUtils.getChildText(intervalElement, "min"));
      double max = Double.parseDouble(ReaderUtils.getChildText(intervalElement, "max"));

      cd.put("min", min);
      cd.put("max", max);
      cds.add(cd);
    }

    return cds;
  }
Exemplo n.º 5
0
  public Map<String, Object> envelope() throws Exception {
    Element envelopeElement = ReaderUtils.getChildElement(coverage, "envelope");
    HashMap<String, Object> e = new HashMap<String, Object>();

    String nativeCrsWkt = ReaderUtils.getAttribute(envelopeElement, "crs", false);
    nativeCrsWkt = nativeCrsWkt.replaceAll("'", "\"");

    e.put("crs", nativeCrsWkt);
    e.put("srsName", ReaderUtils.getAttribute(envelopeElement, "srsName", false));

    Element[] posElements = ReaderUtils.getChildElements(envelopeElement, "pos");
    String[] pos1 = posElements[0].getFirstChild().getTextContent().split(" ");
    String[] pos2 = posElements[1].getFirstChild().getTextContent().split(" ");

    e.put("x1", Double.parseDouble(pos1[0]));
    e.put("y1", Double.parseDouble(pos1[1]));
    e.put("x2", Double.parseDouble(pos2[0]));
    e.put("y2", Double.parseDouble(pos2[1]));

    return e;
  }
Exemplo n.º 6
0
 public String defaultStyle() throws Exception {
   Element styles = ReaderUtils.getChildElement(coverage, "styles");
   return ReaderUtils.getAttribute(styles, "default", true);
 }
Exemplo n.º 7
0
 public List<String> supportedInterpolations() throws Exception {
   Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedInterpolations");
   String[] interpolations =
       ReaderUtils.getChildText(supportedFormats, "interpolationMethods").split(",");
   return Arrays.asList(interpolations);
 }
Exemplo n.º 8
0
 public String defaultInterpolation() throws Exception {
   Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedInterpolations");
   return ReaderUtils.getAttribute(supportedFormats, "default", true);
 }
Exemplo n.º 9
0
 public List<String> supportedFormats() throws Exception {
   Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedFormats");
   String[] formats = ReaderUtils.getChildText(supportedFormats, "formats").split(",");
   return Arrays.asList(formats);
 }
Exemplo n.º 10
0
 public String nativeFormat() throws Exception {
   Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedFormats");
   return ReaderUtils.getAttribute(supportedFormats, "nativeFormat", true);
 }
Exemplo n.º 11
0
 public List<String> responseCRSs() throws Exception {
   Element supportedCRS = ReaderUtils.getChildElement(coverage, "supportedCRSs");
   String[] responseCRS = ReaderUtils.getChildText(supportedCRS, "responseCRSs").trim().split(",");
   return Arrays.asList(responseCRS);
 }