From 0501863ac356583dbac21d29e9eb816d073b9e53 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 25 Sep 2018 22:49:38 +0100 Subject: [PATCH] Regression tested with 2m,30m tile permutations --- inputs.cc | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/inputs.cc b/inputs.cc index 1edbdb0..fef73c3 100644 --- a/inputs.cc +++ b/inputs.cc @@ -226,7 +226,7 @@ int loadLIDAR(char *filenames, int resample) if (tiles[indx].max_west < max_west) max_west = tiles[indx].max_west; } - if (fabs(tiles[indx].min_west - min_west) < 180.0) { + if (fabs(tiles[indx].min_west - min_west) < 180.0 || tiles[indx].min_west < 360) { if (tiles[indx].min_west < min_west) min_west = tiles[indx].min_west; } else { @@ -279,6 +279,52 @@ int loadLIDAR(char *filenames, int resample) fprintf(stderr,"totalh: %.7f - %.7f = %.7f totalw: %.7f - %.7f = %.7f fc: %d\n", max_north, min_north, total_height, max_west, min_west, total_width,fc); } + //detect problematic layouts eg. vertical rectangles + // 1x2 + if(fc >= 2 && desired_resolution < 28 && total_height > total_width*1.5){ + tiles[fc].max_north=max_north; + tiles[fc].min_north=min_north; + westoffset=westoffset-(total_height-total_width); // WGS84 for stdout only + max_west=max_west+(total_height-total_width); // Positive westing + tiles[fc].max_west=max_west; // Positive westing + tiles[fc].min_west=max_west; + tiles[fc].ppdy=tiles[fc-1].ppdy; + tiles[fc].ppdy=tiles[fc-1].ppdx; + tiles[fc].width=(total_height-total_width); + tiles[fc].height=total_height; + tiles[fc].data=tiles[fc-1].data; + fc++; + + //calculate deficit + + if (debug) { + fprintf(stderr,"deficit: %.4f cellsize: %.9f tiles needed to square: %.1f, desired_resolution %d\n", total_width-total_height,avgCellsize,(total_width-total_height)/avgCellsize,desired_resolution); + } + } + // 2x1 + if(fc >= 2 && desired_resolution < 28 && total_width > total_height*1.5){ + tiles[fc].max_north=max_north+(total_width-total_height); + tiles[fc].min_north=max_north; + tiles[fc].max_west=max_west; // Positive westing + max_north=max_north+(total_width-total_height); // Positive westing + tiles[fc].min_west=min_west; + tiles[fc].ppdy=tiles[fc-1].ppdy; + tiles[fc].ppdy=tiles[fc-1].ppdx; + tiles[fc].width=total_width; + tiles[fc].height=(total_width-total_height); + tiles[fc].data=tiles[fc-1].data; + fc++; + + //calculate deficit + + if (debug) { + fprintf(stderr,"deficit: %.4f cellsize: %.9f tiles needed to square: %.1f\n", total_width-total_height,avgCellsize,(total_width-total_height)/avgCellsize); + } + +} + + + size_t new_height = 0; size_t new_width = 0; for ( size_t i = 0; i < fc; i++ ) {