/**
  * @param node
  * @return minimum x coordinate
  * @throws GeometryException
  */
 public static String getXMin(Node node) throws GeometryException {
   if (node == null) {
     return "";
   }
   Geometry geometry = GMLGeometryAdapter.wrap((Element) node, null);
   Envelope envelope = geometry.getEnvelope();
   return Double.toString(envelope.getMin().getX());
 }
 /**
  * @param node
  * @return minimum z coordinate
  * @throws GeometryException
  */
 public static String getZMax(Node node) throws GeometryException {
   if (node == null) {
     return "";
   }
   Geometry geometry = GMLGeometryAdapter.wrap((Element) node, null);
   Envelope envelope = geometry.getEnvelope();
   if (geometry.getCoordinateDimension() > 2) {
     return "";
   }
   return Double.toString(envelope.getMax().getZ());
 }
  /**
   * @param pointNode the point node from which the x or y value will be extracted. For example,
   *     node is <gml:Point srsName="EPSG:31466"> <gml:coordinates cs="," decimal="." ts="
   *     ">0.0,0.0</gml:coordinates> </gml:Point>
   * @param coordIndex the coordenate index indicated whether to extract from x (index = 0)
   *     otherwise from y
   * @return the String representation of the x or y value
   * @throws GeometryException
   */
  private static String getPointXorY(Node pointNode, int coordIndex) throws GeometryException {
    String value = "";

    if (pointNode != null) {

      Geometry geometry = GMLGeometryAdapter.wrap((Element) pointNode, null);
      if (geometry instanceof Point) {
        Point p = (Point) geometry;
        double d = coordIndex == 0 ? p.getX() : p.getY();
        value = Double.toString(d);
      }
    }

    return value;
  }
  /**
   * returns the minimum coordinate of the envelope of the geometry encoded by the passed node as a
   * double array
   *
   * @param node
   * @return the minimum coordinate of the envelope of the geometry encoded by the passed node as a
   *     double array
   * @throws GeometryException
   */
  public static String getMaxAsArray(Node node) throws GeometryException {
    if (node == null) {
      return "";
    }
    Geometry geometry = GMLGeometryAdapter.wrap((Element) node, null);
    if (geometry instanceof Point) {
      return "";
    }
    Envelope env = geometry.getEnvelope();
    StringBuffer sb = new StringBuffer(100);

    Position pos = env.getMax();
    int dim = pos.getCoordinateDimension();
    double[] d = pos.getAsArray();
    for (int i = 0; i < dim - 1; i++) {
      sb.append(Double.toString(d[i])).append(' ');
    }
    sb.append(Double.toString(d[dim - 1]));

    return sb.toString();
  }