CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileLine
org/deegree/coverage/raster/RasterTransformer.java238
org/deegree/coverage/raster/interpolation/RasterInterpolater.java129
                            throws TransformationException {
        int k = 0;
        // create/calculate reference points
        float dx = ( dstWidth - 1 ) / (float) ( refPointsGridSize - 1 );
        float dy = ( dstHeight - 1 ) / (float) ( refPointsGridSize - 1 );
        float[] srcCoords = new float[refPointsGridSize * refPointsGridSize * 2];
        float[] dstCoords = new float[refPointsGridSize * refPointsGridSize * 2];
        List<Point3d> points = new ArrayList<Point3d>( refPointsGridSize * refPointsGridSize );
        for ( int j = 0; j < refPointsGridSize; j++ ) {
            for ( int i = 0; i < refPointsGridSize; i++ ) {
                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;
            }
        }
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java336
org/deegree/coverage/raster/data/TiledRasterData.java417
org/deegree/coverage/raster/data/TiledRasterData.java501
org/deegree/coverage/raster/data/TiledRasterData.java609
        double noData = dataInfo.getDoubleNoDataForBand( band );
        Arrays.fill( resultValues, noData );

        if ( interSectingTiles != null ) {
            final RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
                            final int heightOffset = ( intersectionWithTile.y / tileHeight );
                            // map to the given tile coordinate system.
                            final RasterRect tReq = new RasterRect( ( intersectionWithTile.x - widthOffset ),
                                                                    ( intersectionWithTile.y - heightOffset ),
                                                                    intersectionWithTile.width,
                                                                    intersectionWithTile.height );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java250
org/deegree/coverage/raster/data/TiledRasterData.java340
org/deegree/coverage/raster/data/TiledRasterData.java421
org/deegree/coverage/raster/data/TiledRasterData.java505
org/deegree/coverage/raster/data/TiledRasterData.java613
            RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
                            final int heightOffset = ( intersectionWithTile.y / tileHeight );
                            // map to the given tile coordinate system.
                            final RasterRect tReq = new RasterRect( ( intersectionWithTile.x - widthOffset ),
                                                                    ( intersectionWithTile.y - heightOffset ),
                                                                    intersectionWithTile.width,
                                                                    intersectionWithTile.height );
FileLine
org/deegree/coverage/raster/RasterTransformer.java174
org/deegree/coverage/raster/interpolation/RasterInterpolater.java105
    }

    /**
     * @param warp
     * @param interpolation
     * @param dstData
     */
    private void warpTransform( WarpPolynomial warp, Interpolation interpolation, RasterData dstData ) {
        byte[] pixel = new byte[dstData.getBands() * dstData.getDataType().getSize()];
        float[] srcCoords = new float[dstData.getColumns() * 2];
        for ( int y = 0; y < dstData.getRows(); y++ ) {
            // look-up the pixel positions in the source raster for every pixel in this row, the srcCoords will contain
            // the x,y ([2n],[2n+1]) values in the source raster (defined in the native CRS) for this row of pixels.
            warp.warpRect( 0, y, dstData.getColumns(), 1, srcCoords );
            for ( int x = 0; x < dstData.getColumns(); x++ ) {
                // get the interpolated pixel and set the value into the result raster
                interpolation.getPixel( srcCoords[x * 2], srcCoords[x * 2 + 1], pixel );
                dstData.setPixel( x, y, pixel );
            }
        }

    }

    /**
     * Create a new raster that contains all data we need for the transformation.
     * 
     * @throws IllegalArgumentException
     */
    private AbstractRaster getSubRaster( ICRS srcCRS, AbstractRaster sourceRaster, Envelope dstEnvelope )
FileLine
org/deegree/coverage/raster/io/asc/ASCWriter.java76
org/deegree/coverage/raster/io/xyz/XYZWriter.java74
        outputFormat.addAll( ASCRasterIOProvider.FORMATS );
    }

    @Override
    public boolean canWrite( AbstractRaster raster, RasterIOOptions options ) {
        // only return true if the raster has one band.
        return raster != null && raster.getRasterDataInfo() != null && raster.getRasterDataInfo().bands == 1;
    }

    @Override
    public Set<String> getSupportedFormats() {
        return outputFormat;
    }

    @Override
    public void write( AbstractRaster raster, File file, RasterIOOptions options )
                            throws IOException {
        BufferedWriter bw = new BufferedWriter( new FileWriter( file ) );
        write( raster, bw, options );
        bw.close();
    }

    private void write( AbstractRaster raster, BufferedWriter writer, RasterIOOptions options )
                            throws IOException {
        if ( canWrite( raster, options ) ) {
            SimpleRaster simpleRaster = raster.getAsSimpleRaster();
            // convert to outer, because we iterate of x,y as whole values and not (0.5,0.5);
            RasterGeoReference rasterReference = simpleRaster.getRasterReference().createRelocatedReference( OriginLocation.OUTER );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java679
org/deegree/coverage/raster/data/TiledRasterData.java745
org/deegree/coverage/raster/data/TiledRasterData.java813
    public void setBytes( int x, int y, int width, int height, int band, byte[] values ) {
        RasterRect requestedRect = new RasterRect( x, y, width, height );
        int[] interSectingTiles = getIntersectingTiles( requestedRect );
        if ( interSectingTiles != null ) {
            final RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {
                            // make sure it exists.
                            // get the result
                            final byte[] tileValues = new byte[intersectionWithTile.width * intersectionWithTile.height];
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java880
org/deegree/coverage/raster/data/TiledRasterData.java976
    public void setInts( int x, int y, int width, int height, int band, int[] values ) {
        RasterRect requestedRect = new RasterRect( x, y, width, height );
        int[] interSectingTiles = getIntersectingTiles( requestedRect );
        if ( interSectingTiles != null ) {
            RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {
                            // make sure it exists.
                            // get the result
                            final int[] tileValues = new int[intersectionWithTile.width * intersectionWithTile.height];
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java697
org/deegree/coverage/raster/data/TiledRasterData.java763
org/deegree/coverage/raster/data/TiledRasterData.java831
org/deegree/coverage/raster/data/TiledRasterData.java898
org/deegree/coverage/raster/data/TiledRasterData.java994
                            final byte[] tileValues = new byte[intersectionWithTile.width * intersectionWithTile.height];

                            // calculate the offset in the given array.
                            final int offsetInResult = ( intersectionWithTile.y * requestedRect.width )
                                                       + intersectionWithTile.x;
                            // copy the result with the data from the tile.
                            for ( int yResult = 0; yResult < intersectionWithTile.height; ++yResult ) {
                                // one band, so row copying is available
                                System.arraycopy( values, ( yResult * requestedRect.width ) + offsetInResult,
                                                  tileValues, yResult * intersectionWithTile.width,
                                                  intersectionWithTile.width );
                            }

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
                            final int heightOffset = ( intersectionWithTile.y / tileHeight );
                            // map to the given tile coordinate system.
                            final RasterRect tReq = new RasterRect( ( intersectionWithTile.x - widthOffset ),
                                                                    ( intersectionWithTile.y - heightOffset ),
                                                                    intersectionWithTile.width,
                                                                    intersectionWithTile.height );
                            synchronized ( tiles ) {
                                tile.setBytes( tReq.x, tReq.y, tileRect.width, tileRect.height, band, tileValues );
FileLine
org/deegree/coverage/raster/io/xyz/XYZWriter.java146
org/deegree/coverage/raster/io/xyz/XYZWriter.java174
    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 );
FileLine
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java499
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java539
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java581
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java669
            result = new double[width * height];
        }
        for ( int h = 0; h < height; h++ ) {
            for ( int w = 0; w < width; w++ ) {
                int pos = calculatePos( x + w, y + h, band );
                int rOffset = ( 2 * h ) + w;
                if ( pos == -1 ) {// the position is outside the databuffer.
                    System.arraycopy( getView().dataInfo.noDataPixel, getView().getBandOffset( band )
                                                                      * getView().dataInfo.dataSize, result, rOffset,
                                      getView().dataInfo.dataSize );
                } else {
                    result[rOffset] = getByteBuffer().getDouble( pos );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java337
org/deegree/coverage/raster/data/TiledRasterData.java418
org/deegree/coverage/raster/data/TiledRasterData.java502
org/deegree/coverage/raster/data/TiledRasterData.java610
org/deegree/coverage/raster/data/TiledRasterData.java681
org/deegree/coverage/raster/data/TiledRasterData.java747
org/deegree/coverage/raster/data/TiledRasterData.java815
        Arrays.fill( resultValues, noData );

        if ( interSectingTiles != null ) {
            final RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java247
org/deegree/coverage/raster/data/TiledRasterData.java882
        Arrays.fill( resultValues, noData );

        if ( interSectingTiles != null ) {
            RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java247
org/deegree/coverage/raster/data/TiledRasterData.java978
        Arrays.fill( resultValues, noData );

        if ( interSectingTiles != null ) {
            RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java340
org/deegree/coverage/raster/data/TiledRasterData.java421
org/deegree/coverage/raster/data/TiledRasterData.java505
org/deegree/coverage/raster/data/TiledRasterData.java613
org/deegree/coverage/raster/data/TiledRasterData.java884
            final RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java250
org/deegree/coverage/raster/data/TiledRasterData.java683
org/deegree/coverage/raster/data/TiledRasterData.java749
org/deegree/coverage/raster/data/TiledRasterData.java817
org/deegree/coverage/raster/data/TiledRasterData.java884
            RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );
FileLine
org/deegree/coverage/raster/data/TiledRasterData.java340
org/deegree/coverage/raster/data/TiledRasterData.java421
org/deegree/coverage/raster/data/TiledRasterData.java505
org/deegree/coverage/raster/data/TiledRasterData.java613
org/deegree/coverage/raster/data/TiledRasterData.java980
            final RasterRect tileRect = new RasterRect( 0, 0, tileWidth, tileHeight );
            for ( int row = interSectingTiles[1]; row < interSectingTiles[3]; ++row ) {
                for ( int col = interSectingTiles[0]; col < interSectingTiles[2]; ++col ) {
                    // rect of tile
                    tileRect.x = col * tileWidth;
                    tileRect.y = row * tileHeight;
                    // intersection of request with given tile
                    final RasterRect intersectionWithTile = RasterRect.intersection( tileRect, requestedRect );
                    if ( intersectionWithTile != null ) {
                        // an intersection, get the raster tile
                        final RasterData tile = tiles[row * columns + col];
                        if ( tile != null ) {

                            final int widthOffset = ( intersectionWithTile.x / tileWidth );