/** * @param ps * @param b * @param index * @throws SQLException */ private Envelope getEnvelope( float[] location, float width, float height, float depth ) { return geomFac.createEnvelope( new double[] { location[0], location[1], location[2] }, new double[] { location[0] + width, location[1] + depth, location[2] + height }, null ); }
/** * @param translationVector * @param coordinateSystem * @return a default 3d envelope at 0,0 from the scene. */ private static Envelope createDefaultEnvelope( double[] translationVector, ICRS coordinateSystem ) { return geomFac.createEnvelope( new double[] { 0, 0, 0 }, new double[] { DEFAULT_SPAN, DEFAULT_SPAN, DEFAULT_SPAN }, coordinateSystem ); }
/** * @param env * @param crs * @return reverse of the other createEnvelope method */ public static final Envelope createEnvelope( float[] env, CRS crs ) { if ( env.length == 4 ) { return fac.createEnvelope( env[0], env[1], env[2], env[3], crs ); } if ( env.length == 6 ) { return fac.createEnvelope( new double[] { env[0], env[1], env[2] }, new double[] { env[3], env[4], env[5] }, crs ); } throw new IllegalArgumentException( "The envelope must be 2 or 3 dimensional." ); }
private Envelope getDefaultBBox() { return new GeometryFactory().createEnvelope( new double[] { -sphereSize, -sphereSize, -sphereSize }, new double[] { sphereSize, sphereSize, sphereSize }, null ); }
/** * @param buffer * @return * @throws IOException */ private Envelope readEnvelope( DataInputStream in ) throws IOException { double[] min = new double[3]; double[] max = new double[3]; min[0] = in.readDouble(); min[1] = in.readDouble(); min[2] = in.readDouble(); max[0] = in.readDouble(); max[1] = in.readDouble(); max[2] = in.readDouble(); return geomFac.createEnvelope( min, max, null ); }
@SuppressWarnings("boxing") protected static Envelope createEnvelope( String bboxStr, ICRS srs ) { String[] coordList = bboxStr.split( "," ); int n = coordList.length / 2; List<Double> lowerCorner = new ArrayList<Double>(); for ( int i = 0; i < n; i++ ) { lowerCorner.add( Double.parseDouble( coordList[i] ) ); } List<Double> upperCorner = new ArrayList<Double>(); for ( int i = n; i < 2 * n; i++ ) { upperCorner.add( Double.parseDouble( coordList[i] ) ); } GeometryFactory gf = new GeometryFactory(); return gf.createEnvelope( lowerCorner, upperCorner, srs ); }
private Envelope readEnvelope( ByteBuffer bb ) { Envelope result = null; if ( ( bb.position() + ( 6 * ( AllocatedHeapMemory.DOUBLE_SIZE ) ) ) < bb.capacity() ) { double[] min = new double[] { bb.getDouble(), bb.getDouble(), bb.getDouble() }; double[] max = new double[] { bb.getDouble(), bb.getDouble(), bb.getDouble() }; String crs = ObjectSerializer.readString( bb ); result = new GeometryFactory().createEnvelope( min, max, CRSManager.getCRSRef( crs ) ); } return result; }
@Override public SimpleRaster getSubRaster( double x, double y, double x2, double y2 ) { // what about the precision model? Formerly: getRasterReference().getDelta() was used Envelope env = getGeometryFactory().createEnvelope( new double[] { x, y }, new double[] { x2, y2 }, null ); return getSubRaster( env ); }
@Override public MultiRangedRaster getSubRaster( double x, double y, double x2, double y2 ) { // what about the precision model? Formerly: getRasterReference().getDelta() was used Envelope env = getGeometryFactory().createEnvelope( new double[] { x, y }, new double[] { x2, y2 }, null ); return getSubRaster( env ); }
@Override public void setValue( double[] lower, double[] upper, String crsName ) { setValue( geomFac.createEnvelope( lower, upper, CRSManager.getCRSRef( crsName ) ) ); }
private void getAndSetSubImage( BufferedImage targetImage, List<LayerRef> layers, int xMin, int width, int yMin, int height, RasterGeoReference rasterEnv, ICRS crs, String format, boolean transparent, boolean errorsInImage ) throws IOException { double[] min = rasterEnv.getWorldCoordinate( xMin, yMin + height ); double[] max = rasterEnv.getWorldCoordinate( xMin + width, yMin ); Envelope env = new GeometryFactory().createEnvelope( min, max, crs ); Pair<BufferedImage, String> response = getMap( layers, styles, width, height, env, crs, format, transparent, errorsInImage, false, null ); if ( response.second != null ) { throw new IOException( response.second ); } targetImage.getGraphics().drawImage( response.first, xMin, yMin, null ); } }
private Envelope calculateMainBBox( List<BoundingBox> bbox ) { if ( bbox == null || bbox.isEmpty() ) return null; double west = bbox.get( 0 ).getWestBoundLongitude(); double east = bbox.get( 0 ).getEastBoundLongitude(); double south = bbox.get( 0 ).getSouthBoundLatitude(); double north = bbox.get( 0 ).getNorthBoundLatitude(); for ( BoundingBox b : bbox ) { west = Math.min( west, b.getWestBoundLongitude() ); east = Math.max( east, b.getEastBoundLongitude() ); south = Math.min( south, b.getSouthBoundLatitude() ); north = Math.max( north, b.getNorthBoundLatitude() ); } GeometryFactory gf = new GeometryFactory(); return gf.createEnvelope( west, south, east, north, CRSUtils.EPSG_4326 ); }
private TypedObjectNode[] getResultBBox( List<BoundingBox> bbox ) { if ( bbox == null || bbox.isEmpty() ) return new TypedObjectNode[0]; double west = bbox.get( 0 ).getWestBoundLongitude(); double east = bbox.get( 0 ).getEastBoundLongitude(); double south = bbox.get( 0 ).getSouthBoundLatitude(); double north = bbox.get( 0 ).getNorthBoundLatitude(); for ( BoundingBox b : bbox ) { west = Math.min( west, b.getWestBoundLongitude() ); east = Math.max( east, b.getEastBoundLongitude() ); south = Math.min( south, b.getSouthBoundLatitude() ); north = Math.max( north, b.getNorthBoundLatitude() ); } GeometryFactory gf = new GeometryFactory(); return new TypedObjectNode[] { gf.createEnvelope( west, south, east, north, CRSUtils.EPSG_4326 ) }; }
/** * @param ps * @param b * @param index * @throws SQLException */ private Envelope getEnvelope( BillBoard b ) { float[] location = b.getLocation(); float width = b.getWidth() * 0.5f; float height = b.getHeight(); return geomFac.createEnvelope( new double[] { location[0] - width, location[1] - width, location[2] }, new double[] { location[0] + width, location[1] + width, location[2] + height }, null ); }
/** * @param crs */ public void setCoordinateSystem( ICRS crs ) { this.crs = crs; bbox = fac.createEnvelope( bbox.getMin().getAsArray(), bbox.getMax().getAsArray(), crs ); }
/** * @param crs */ public void setCoordinateSystem( ICRS crs ) { this.crs = crs; if ( envelope != null ) { // rb: this is not correct, the values of the envelope should be converted to the given crs, shouldn't they. this.envelope = geomFactory.createEnvelope( envelope.getMin().getAsArray(), envelope.getMax().getAsArray(), crs ); } }
private static RenderablePrototype createBoxPrototype() { RenderableQualityModel rqm = new RenderableQualityModel(); RenderableGeometry rg = new BOXGeometry(); rqm.addQualityModelPart( rg ); Envelope env = new GeometryFactory().createEnvelope( 0, 0, 1, 1, null ); return new RenderablePrototype( "box", "yeah", env, rqm ); }
private Envelope parseEnvelope() throws OWSException { // get the values from a spatial subset OMElement envelope = parseEnvelopeElement(); String srsName = parseSRSName( envelope, "EPSG:4326" ); List<OMElement> posElems = getElements( envelope, new XPath( "gml:pos", wcsNSContext ) ); if ( posElems.size() != 2 ) { throw new OWSException( "invalid envelope, need two gml:pos", OWSException.INVALID_PARAMETER_VALUE, "spatialSubset" ); } double[] min = parseNums( "gml:pos", posElems.get( 0 ) ); double[] max = parseNums( "gml:pos", posElems.get( 1 ) ); ICRS crs = CRSManager.getCRSRef( srsName ); GeometryFactory geomFactory = new GeometryFactory(); return geomFactory.createEnvelope( min, max, crs ); }
List<LegendItem> prepareLegend( Style style, Graphics2D g, int width, int height ) { Pair<Integer, Integer> p = getLegendSize( style ); Envelope box = geofac.createEnvelope( 0, 0, p.first, p.second, null ); Java2DRenderer renderer = new Java2DRenderer( g, width, height, box ); Java2DTextRenderer textRenderer = new Java2DTextRenderer( renderer ); Java2DRasterRenderer rasterRenderer = new Java2DRasterRenderer( g, width, height, box ); return LegendItemBuilder.prepareLegend( style, renderer, textRenderer, rasterRenderer ); }
public Envelope calcClickBox( int radius ) { radius = parameters.get( "RADIUS" ) == null ? radius : parseInt( parameters.get( "RADIUS" ) ); GeometryFactory fac = new GeometryFactory(); double dw = envelope.getSpan0() / width; double dh = envelope.getSpan1() / height; int r2 = radius / 2; r2 = r2 <= 0 ? 1 : r2; return fac.createEnvelope( new double[] { envelope.getMin().get0() + ( x - r2 ) * dw, envelope.getMax().get1() - ( y + r2 ) * dh }, new double[] { envelope.getMin().get0() + ( x + r2 ) * dw, envelope.getMax().get1() - ( y - r2 ) * dh }, envelope.getCoordinateSystem() ); } }