private Envelope mergeEnvelope( final Envelope existing, final Envelope additional ) { if ( existing == null ) { return additional; } if ( additional == null || additional.getCoordinateDimension() < 2 ) { return existing; } return existing.merge( additional ); }
/** * Create a Gird for the given pixel resolution and output envelope * * @param resx * resolution of a pixel (ie. the width of each grid cell in CRS units) * @param resy * resolution of a pixel (ie. the height of each grid cell in CRS units) * @param resz * resolution of a pixel (ie. the depth of each grid cell in CRS units) * @param targetEnvelope * the envelope of the output grid * @return a new grid */ public static Grid fromRes( double resx, double resy, double resz, Envelope targetEnvelope ) { int width = (int) Math.round( targetEnvelope.getSpan0() / resx ); int height = (int) Math.round( targetEnvelope.getSpan1() / resy ); int depth = Integer.MIN_VALUE; if ( !Double.isNaN( resz ) ) { if ( targetEnvelope.getCoordinateDimension() == 3 ) { double envDepth = getEnvDepth( targetEnvelope ); depth = (int) Math.round( envDepth / resz ); } } return new Grid( width, height, depth, targetEnvelope ); }
/** * Exports an {@link Envelope} as a <code>ows:BoundingBoxType</code>. * * @param writer * @param bbox * envelope to be exported * @throws XMLStreamException */ public static void exportBoundingBoxType( XMLStreamWriter writer, Envelope bbox ) throws XMLStreamException { // "crs" attribute (optional) if ( bbox.getCoordinateSystem() != null ) { writer.writeAttribute( "crs", bbox.getCoordinateSystem().getAlias() ); } // "dimensions" attribute (optional) writer.writeAttribute( "dimensions", "" + bbox.getCoordinateDimension() ); // "ows:LowerCorner" element (minOccurs="1", maxOccurs="1") writer.writeStartElement( OWS110_NS, "LowerCorner" ); exportPositionType( writer, bbox.getMin() ); writer.writeEndElement(); // "ows:UpperCorner" element (minOccurs="1", maxOccurs="1") writer.writeStartElement( OWS110_NS, "UpperCorner" ); exportPositionType( writer, bbox.getMax() ); writer.writeEndElement(); }
private static double getEnvDepth( Envelope env ) { double result = Double.NaN; if ( env.getCoordinateDimension() == 3 ) { result = env.getMax().get2() - env.getMin().get2(); } return result; }
/** * Creates float array out of an envelope (Geometry). * * @param validDomain * @return a float[] representation of the given envelope */ public static final float[] createEnvelope( Envelope validDomain ) { if ( validDomain == null ) { return null; } int dim = validDomain.getCoordinateDimension(); double[] env = validDomain.getMin().getAsArray(); if ( !( dim == 3 || dim == 2 ) ) { throw new IllegalArgumentException( "The envelope must be 2 or 3 dimensional." ); } float[] envelope = new float[dim * 2]; int index = 0; envelope[index++] = (float) env[0]; envelope[index++] = (float) env[1]; if ( dim == 3 ) { envelope[index++] = (float) env[2]; } env = validDomain.getMax().getAsArray(); envelope[index++] = (float) env[0]; envelope[index++] = (float) env[1]; if ( dim == 3 ) { envelope[index] = (float) env[2]; } return envelope; }
int height = KVPUtils.getRequiredInt( kvp, "HEIGHT" ); int depth = KVPUtils.getInt( kvp, "DEPTH", Integer.MIN_VALUE ); if ( depth != Integer.MIN_VALUE && targetEnvelope.getCoordinateDimension() != 3 ) { LOG.warn( "Depth is requested but the target envelope does not have 3 dimensions, only using width and height." ); depth = Integer.MIN_VALUE; double resy = KVPUtils.getRequiredDouble( kvp, "RESY" ); double resz = KVPUtils.getDefaultDouble( kvp, "RESZ", Double.MIN_VALUE ); if ( resz != Double.MIN_VALUE && targetEnvelope.getCoordinateDimension() != 3 ) { LOG.warn( "RESZ is requested but the target envelope does not have 3 dimensions, only using resx and resy." ); resz = Double.MIN_VALUE;
try { latlon = CRSManager.lookup( "CRS:84" ); if ( layerEnv != null && layerEnv.getCoordinateDimension() >= 2 ) { Envelope bbox = new GeometryTransformer( latlon ).transform( layerEnv ); writer.writeStartElement( "LatLonBoundingBox" );
int coordinateDimension = Math.min( getCoordinateDimension(), other.getCoordinateDimension() ); double[] min = new double[coordinateDimension]; double[] max = new double[coordinateDimension];
Envelope gEnv = g.getEnvelope(); if ( gEnv.getCoordinateDimension() > 1 ) { if ( env != null ) { env = env.merge( gEnv );
try { latlon = lookup( "CRS:84" ); if ( layerEnv != null && layerEnv.getCoordinateDimension() >= 2 ) { Envelope bbox = new GeometryTransformer( latlon ).transform( layerEnv ); writer.writeStartElement( WMSNS, "EX_GeographicBoundingBox" );
if ( datasetEnvelope.getCoordinateDimension() == 2 ) { double[] min = datasetEnvelope.getMin().getAsArray(); double[] max = datasetEnvelope.getMax().getAsArray();
return fac.createPoint( null, min.getAsArray(), crs ); if ( env.getCoordinateDimension() == 2 ) { if ( min.get0() == max.get0() || min.get1() == max.get1() ) { Points points = new PointsArray( min, max );