protected Double [ ] [ ] formatUnboundedResults ( TileMatrix tileMatrix , Map < Long , Map < Long , Double [ ] [ ] > > rowsMap , int tileCount , long minRow , long maxRow , long minColumn , long maxColumn ) { // Handle formatting the results Double [ ] [ ] values = null ; if ( ! rowsMap . isEmpty ( ) ) { // If only one tile result, use the coverage data as the result if ( tileCount == 1 ) { values = rowsMap . get ( minRow ) . get ( minColumn ) ; } else { // Else, combine all results into a single coverage data result // Get the top left and bottom right coverage data values Double [ ] [ ] topLeft = rowsMap . get ( minRow ) . get ( minColumn ) ; Double [ ] [ ] bottomRight = rowsMap . get ( maxRow ) . get ( maxColumn ) ; // Determine the width and height of the top left coverage data // results int firstWidth = topLeft [ 0 ] . length ; int firstHeight = topLeft . length ; // Determine the final result width and height int width = firstWidth ; int height = firstHeight ; if ( minColumn < maxColumn ) { width += bottomRight [ 0 ] . length ; long middleColumns = maxColumn - minColumn - 1 ; if ( middleColumns > 0 ) { width += ( middleColumns * tileMatrix . getTileWidth ( ) ) ; } } if ( minRow < maxRow ) { height += bottomRight . length ; long middleRows = maxRow - minRow - 1 ; if ( middleRows > 0 ) { height += ( middleRows * tileMatrix . getTileHeight ( ) ) ; } } // Create the coverage data result array values = new Double [ height ] [ width ] ; // Copy the coverage data values from each tile results into the // final result arrays for ( Map . Entry < Long , Map < Long , Double [ ] [ ] > > rows : rowsMap . entrySet ( ) ) { // Determine the starting base row for this tile long row = rows . getKey ( ) ; int baseRow = 0 ; if ( minRow < row ) { baseRow = firstHeight + ( int ) ( ( row - minRow - 1 ) * tileMatrix . getTileHeight ( ) ) ; } // Get the row's columns map Map < Long , Double [ ] [ ] > columnsMap = rows . getValue ( ) ; for ( Map . Entry < Long , Double [ ] [ ] > columns : columnsMap . entrySet ( ) ) { // Determine the starting base column for this tile long column = columns . getKey ( ) ; int baseColumn = 0 ; if ( minColumn < column ) { baseColumn = firstWidth + ( int ) ( ( column - minColumn - 1 ) * tileMatrix . getTileWidth ( ) ) ; } // Get the tiles coverage data values Double [ ] [ ] localValues = columns . getValue ( ) ; // Copy the columns array at each local coverage data // row to the global row and column result location for ( int localRow = 0 ; localRow < localValues . length ; localRow ++ ) { int globalRow = baseRow + localRow ; System . arraycopy ( localValues [ localRow ] , 0 , values [ globalRow ] , baseColumn , localValues [ localRow ] . length ) ; } } } } } return values ; }
Format the unbounded results from coverage data tiles into a single double array of coverage data