/** * @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()); }
/** * 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(); }
private boolean isTargetCRS(Feature feature, CoordinateSystem targetCRS) throws CRSTransformationException, GeometryException { FeatureProperty[] fp = feature.getProperties(); for (int i = 0; i < fp.length; i++) { if (fp[i].getValue() instanceof Geometry) { Geometry geom = (Geometry) fp[i].getValue(); if (!targetCRS.equals(geom.getCoordinateSystem())) { LOG.logInfo(geom.getCoordinateSystem().getIdentifier()); LOG.logInfo(" - " + targetCRS.getIdentifier()); return false; } } else if (fp[i].getValue() instanceof Feature) { if (!isTargetCRS((Feature) fp[i].getValue(), targetCRS)) { return false; } } } return true; }