CPD Results

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

Duplications

File Line
org/deegree/coverage/raster/RasterTransformer.java 238
org/deegree/coverage/raster/interpolation/RasterInterpolater.java 129
                            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;
            }
        }
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 336
org/deegree/coverage/raster/data/TiledRasterData.java 417
org/deegree/coverage/raster/data/TiledRasterData.java 501
org/deegree/coverage/raster/data/TiledRasterData.java 609
        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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 250
org/deegree/coverage/raster/data/TiledRasterData.java 340
org/deegree/coverage/raster/data/TiledRasterData.java 421
org/deegree/coverage/raster/data/TiledRasterData.java 505
org/deegree/coverage/raster/data/TiledRasterData.java 613
            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 );
File Line
org/deegree/coverage/raster/RasterTransformer.java 174
org/deegree/coverage/raster/interpolation/RasterInterpolater.java 105
    }

    /**
     * @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 )
File Line
org/deegree/coverage/raster/io/asc/ASCWriter.java 76
org/deegree/coverage/raster/io/xyz/XYZWriter.java 74
        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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 679
org/deegree/coverage/raster/data/TiledRasterData.java 745
org/deegree/coverage/raster/data/TiledRasterData.java 813
    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];
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 880
org/deegree/coverage/raster/data/TiledRasterData.java 976
    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];
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 697
org/deegree/coverage/raster/data/TiledRasterData.java 763
org/deegree/coverage/raster/data/TiledRasterData.java 831
org/deegree/coverage/raster/data/TiledRasterData.java 898
org/deegree/coverage/raster/data/TiledRasterData.java 994
                            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 );
File Line
org/deegree/coverage/raster/io/xyz/XYZWriter.java 146
org/deegree/coverage/raster/io/xyz/XYZWriter.java 174
    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 );
File Line
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java 499
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java 539
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java 581
org/deegree/coverage/raster/data/nio/ByteBufferRasterData.java 669
            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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 337
org/deegree/coverage/raster/data/TiledRasterData.java 418
org/deegree/coverage/raster/data/TiledRasterData.java 502
org/deegree/coverage/raster/data/TiledRasterData.java 610
org/deegree/coverage/raster/data/TiledRasterData.java 681
org/deegree/coverage/raster/data/TiledRasterData.java 747
org/deegree/coverage/raster/data/TiledRasterData.java 815
        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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 247
org/deegree/coverage/raster/data/TiledRasterData.java 882
        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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 247
org/deegree/coverage/raster/data/TiledRasterData.java 978
        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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 340
org/deegree/coverage/raster/data/TiledRasterData.java 421
org/deegree/coverage/raster/data/TiledRasterData.java 505
org/deegree/coverage/raster/data/TiledRasterData.java 613
org/deegree/coverage/raster/data/TiledRasterData.java 884
            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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 250
org/deegree/coverage/raster/data/TiledRasterData.java 683
org/deegree/coverage/raster/data/TiledRasterData.java 749
org/deegree/coverage/raster/data/TiledRasterData.java 817
org/deegree/coverage/raster/data/TiledRasterData.java 884
            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 );
File Line
org/deegree/coverage/raster/data/TiledRasterData.java 340
org/deegree/coverage/raster/data/TiledRasterData.java 421
org/deegree/coverage/raster/data/TiledRasterData.java 505
org/deegree/coverage/raster/data/TiledRasterData.java 613
org/deegree/coverage/raster/data/TiledRasterData.java 980
            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 );