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 ); } }
/** * @param target * the location the new origin, may be <code>null</code> * @return the world coordinate of the origin of the geo referenced raster. */ public double[] getOrigin( OriginLocation target ) { double[] result = new double[2]; if ( target != null && target != location ) { if ( location == CENTER ) { result = getWorldCoordinate( 0, 0 ); } else { result = getWorldCoordinate( +0.5, +0.5 ); } } else { result[0] = transform.getTranslateX(); result[1] = transform.getTranslateY(); } return result; }
/** * @param data * @param bw * @param separator * @throws IOException */ private void writeDoubles( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { double sample = data.getDoubleSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + sample + newLine ); } bw.write( sb.toString() ); } }
/** * @param data * @param bw * @param newLine * @param origin * @param resX * @param resY * @param separator */ private void writeUShorts( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { short sample = data.getShortSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + ( sample & 0xFFFF ) + newLine ); } bw.write( sb.toString() ); } }
/** * @param data * @param bw * @param newLine * @param origin * @param resX * @param resY * @param separator */ private void writeFloats( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { float sample = data.getFloatSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + sample + newLine ); } bw.write( sb.toString() ); } }
/** * @param data * @param bw * @param newLine * @param origin * @param resX * @param resY * @param separator */ private void writeShorts( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { short sample = data.getShortSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + sample + newLine ); } bw.write( sb.toString() ); } }
/** * @param data * @param bw * @param newLine * @param origin * @param resX * @param resY * @param separator */ private void writeInts( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { int sample = data.getIntSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + sample + newLine ); } bw.write( sb.toString() ); } }
/** * @param data * @param bw * @param newLine * @param origin * @param resX * @param resY * @param separator */ private void writeBytes( RasterData data, BufferedWriter bw, String newLine, RasterGeoReference geoRef, String separator ) throws IOException { StringBuilder sb = null; int height = data.getRows() - 1; int width = data.getColumns(); for ( int x = 0; x < width; ++x ) { // 30, assuming the values are 10 characters long sb = new StringBuilder( ( height + 1 ) * 30 ); for ( int y = height; y >= 0; --y ) { byte sample = data.getByteSample( x, y, 0 ); double[] worldCoords = geoRef.getWorldCoordinate( x + 0.5, y + 0.5 ); sb.append( worldCoords[0] + separator + worldCoords[1] + separator + ( sample & 0xFF ) + newLine ); } bw.write( sb.toString() ); } }
dstCoords[k] = i * dx; dstCoords[k + 1] = j * dy; double[] dstWCoords = dstREnv.getWorldCoordinate( (int) dstCoords[k], (int) dstCoords[k + 1] ); points.add( new Point3d( dstWCoords[0], dstWCoords[1], Double.NaN ) ); k += 2;
double[] widthHeightPos = getWorldCoordinate( tw, th ); double[] origin = getWorldCoordinate( nullX, nullY );
dstCoords[k] = i * dx; dstCoords[k + 1] = j * dy; double[] dstWCoords = dstREnv.getWorldCoordinate( (int) dstCoords[k], (int) dstCoords[k + 1] ); points.add( new Point3d( dstWCoords[0], dstWCoords[1], Double.NaN ) ); k += 2;
writer.write( "ncols " + simpleRaster.getColumns() + newLine ); writer.write( "nrows " + simpleRaster.getRows() + newLine ); double[] worldCoordinate = rasterReference.getWorldCoordinate( 0, simpleRaster.getRows() ); ICRS crs = simpleRaster.getCoordinateSystem(); int axis = 0;
world1Max += 0.5; double[] worldMinCoordinate = getWorldCoordinate( world0Min, world1Min ); double[] worldMaxCoordinate = getWorldCoordinate( world0Max, world1Max );
double[] worldCoordinate = getWorldCoordinate( raster0, raster1 );