forked from ExternalVendorCode/Signal-Server
Change data to short to restrain memory usage
This commit is contained in:
10
inputs.cc
10
inputs.cc
@@ -228,7 +228,7 @@ int loadLIDAR(char *filenames, int resample)
|
|||||||
|
|
||||||
/* Now we need to rescale all tiles the the lowest resolution or the requested resolution. ie if we have
|
/* Now we need to rescale all tiles the the lowest resolution or the requested resolution. ie if we have
|
||||||
* one 1m lidar and one 2m lidar, resize the 2m to fake 1m */
|
* one 1m lidar and one 2m lidar, resize the 2m to fake 1m */
|
||||||
int desired_resolution = smallest_res < resample ? resample : smallest_res;
|
int desired_resolution = resample != 0 && smallest_res < resample ? resample : smallest_res;
|
||||||
if (desired_resolution > resample && debug )
|
if (desired_resolution > resample && debug )
|
||||||
fprintf(stderr, "Warning: Unable to rescale to requested resolution\n");
|
fprintf(stderr, "Warning: Unable to rescale to requested resolution\n");
|
||||||
for (size_t i = 0; i< fc; i++) {
|
for (size_t i = 0; i< fc; i++) {
|
||||||
@@ -270,7 +270,7 @@ int loadLIDAR(char *filenames, int resample)
|
|||||||
}
|
}
|
||||||
size_t new_tile_alloc = new_width * new_height;
|
size_t new_tile_alloc = new_width * new_height;
|
||||||
|
|
||||||
int * new_tile = (int*) calloc( new_tile_alloc, sizeof(int) );
|
short * new_tile = (short*) calloc( new_tile_alloc, sizeof(int) );
|
||||||
if ( new_tile == NULL ){
|
if ( new_tile == NULL ){
|
||||||
free(tiles);
|
free(tiles);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
@@ -296,8 +296,8 @@ int loadLIDAR(char *filenames, int resample)
|
|||||||
|
|
||||||
/* Copy it row-by-row from the tile */
|
/* Copy it row-by-row from the tile */
|
||||||
for (size_t h = 0; h < tiles[i].height; h++) {
|
for (size_t h = 0; h < tiles[i].height; h++) {
|
||||||
register int *dest_addr = &new_tile[ (north_pixel_offset+h)*new_width + west_pixel_offset];
|
register short *dest_addr = &new_tile[ (north_pixel_offset+h)*new_width + west_pixel_offset];
|
||||||
register int *src_addr = &tiles[i].data[h*tiles[i].width];
|
register short *src_addr = &tiles[i].data[h*tiles[i].width];
|
||||||
// Check if we might overflow
|
// Check if we might overflow
|
||||||
if ( dest_addr + tiles[i].width > new_tile + new_tile_alloc || dest_addr < new_tile ){
|
if ( dest_addr + tiles[i].width > new_tile + new_tile_alloc || dest_addr < new_tile ){
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -305,7 +305,7 @@ int loadLIDAR(char *filenames, int resample)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// fprintf(stderr,"dest:%p src:%p\n", dest_addr, src_addr);
|
// fprintf(stderr,"dest:%p src:%p\n", dest_addr, src_addr);
|
||||||
memcpy( dest_addr, src_addr, tiles[i].width * sizeof(int) );
|
memcpy( dest_addr, src_addr, tiles[i].width * sizeof(short) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
main.cc
2
main.cc
@@ -1146,7 +1146,7 @@ int main(int argc, char *argv[])
|
|||||||
max_txsites = 30;
|
max_txsites = 30;
|
||||||
fzone_clearance = 0.6;
|
fzone_clearance = 0.6;
|
||||||
contour_threshold = 0;
|
contour_threshold = 0;
|
||||||
resample = -1;
|
resample = 0;
|
||||||
|
|
||||||
ano_filename[0] = 0;
|
ano_filename[0] = 0;
|
||||||
earthradius = EARTHRADIUS;
|
earthradius = EARTHRADIUS;
|
||||||
|
10
tiles.cc
10
tiles.cc
@@ -26,11 +26,11 @@ double haversine_formula(double th1, double ph1, double th2, double ph2)
|
|||||||
int tile_load_lidar(tile_t *tile, char *filename){
|
int tile_load_lidar(tile_t *tile, char *filename){
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
char line[MAX_LINE];
|
char line[MAX_LINE];
|
||||||
int nextval;
|
short nextval;
|
||||||
char *pch;
|
char *pch;
|
||||||
|
|
||||||
/* Clear the tile data */
|
/* Clear the tile data */
|
||||||
memset(tile,0x00,sizeof(tile_t));
|
memset(tile, 0x00, sizeof(tile_t));
|
||||||
|
|
||||||
/* Open the file handle and return on error */
|
/* Open the file handle and return on error */
|
||||||
if ( (fd = fopen(filename,"r")) == NULL )
|
if ( (fd = fopen(filename,"r")) == NULL )
|
||||||
@@ -88,7 +88,7 @@ int tile_load_lidar(tile_t *tile, char *filename){
|
|||||||
|
|
||||||
/* Read the actual tile data */
|
/* Read the actual tile data */
|
||||||
/* Allocate the array for the lidar data */
|
/* Allocate the array for the lidar data */
|
||||||
if ( (tile->data = (int*) calloc(tile->width * tile->height, sizeof(int))) == NULL ) {
|
if ( (tile->data = (short*) calloc(tile->width * tile->height, sizeof(short))) == NULL ) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
free(tile->filename);
|
free(tile->filename);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
@@ -144,7 +144,7 @@ int tile_load_lidar(tile_t *tile, char *filename){
|
|||||||
* (ie 2m LIDAR can be 4/6/8/... and 20m can be 40/60)
|
* (ie 2m LIDAR can be 4/6/8/... and 20m can be 40/60)
|
||||||
*/
|
*/
|
||||||
int tile_rescale(tile_t *tile, float scale){
|
int tile_rescale(tile_t *tile, float scale){
|
||||||
int *new_data;
|
short *new_data;
|
||||||
size_t skip_count = 1;
|
size_t skip_count = 1;
|
||||||
size_t copy_count = 1;
|
size_t copy_count = 1;
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ int tile_rescale(tile_t *tile, float scale){
|
|||||||
size_t new_width = tile->width * scale;
|
size_t new_width = tile->width * scale;
|
||||||
|
|
||||||
/* Allocate the array for the lidar data */
|
/* Allocate the array for the lidar data */
|
||||||
if ( (new_data = (int*) calloc(new_height * new_width, sizeof(int))) == NULL ) {
|
if ( (new_data = (short*) calloc(new_height * new_width, sizeof(short))) == NULL ) {
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
tiles.hh
8
tiles.hh
@@ -29,10 +29,10 @@ typedef struct _tile_t{
|
|||||||
};
|
};
|
||||||
double cellsize;
|
double cellsize;
|
||||||
long long datastart;
|
long long datastart;
|
||||||
int nodata;
|
short nodata;
|
||||||
int max_el;
|
short max_el;
|
||||||
int min_el;
|
short min_el;
|
||||||
int *data;
|
short *data;
|
||||||
int resolution;
|
int resolution;
|
||||||
double width_deg;
|
double width_deg;
|
||||||
double height_deg;
|
double height_deg;
|
||||||
|
Reference in New Issue
Block a user