Changeset 532

Show
Ignore:
Timestamp:
03/16/08 17:08:53 (16 months ago)
Author:
hobu
Message:

mostly working txt2las

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/apps/txt2las.c

    r530 r532  
    9797    const char* l = line; 
    9898 
    99     point = LASPoint_Create(); 
     99 
    100100    while (p[0]) 
    101101    { 
     
    330330    LASHeaderH header = NULL; 
    331331    LASWriterH writer = NULL; 
     332    LASError err; 
    332333 
    333334    int xyz_min_quant[3] = {0, 0, 0}; 
     
    537538    while (fgets(line, sizeof(char) * MAX_CHARACTERS_PER_LINE, file_in)) 
    538539    { 
    539         if (parse(parse_less, line, xyz, &point, &gps_time)) 
     540        point = LASPoint_Create(); 
     541        if (parse(parse_less, line, xyz, point, &gps_time)) 
    540542        { 
    541543            /* init the bounding box */ 
     
    557559                    line,  
    558560                    parse_less); 
    559         } 
     561 
     562        } 
     563        LASPoint_Destroy(point); 
     564        point = NULL; 
    560565    } 
    561566 
     
    571576    while (fgets(line, sizeof(char) * MAX_CHARACTERS_PER_LINE, file_in)) 
    572577    { 
    573         if (parse(parse_less, line, xyz, &point, &gps_time)) 
     578        point = LASPoint_Create(); 
     579        if (parse(parse_less, line, xyz, point, &gps_time)) 
    574580        { 
    575581            /* update bounding box */ 
     
    587593            line,  
    588594            parse_less); 
    589         } 
     595 
     596        } 
     597        LASPoint_Destroy(point); 
     598        point = NULL; 
    590599    } 
    591600 
     
    672681    if (strstr(parse_string,"t")) 
    673682    { 
     683        fprintf(stderr, "Setting to LAS version 1.1!!!\n"); 
    674684        LASHeader_SetDataFormatId(header, 1); 
    675685    } 
     
    726736    while (fgets(line, sizeof(char) * MAX_CHARACTERS_PER_LINE, file_in)) 
    727737    { 
    728         if (parse(parse_string, line, xyz, &point, &gps_time)) 
     738        point = LASPoint_Create(); 
     739        if (parse(parse_string, line, xyz, point, &gps_time)) 
    729740        { 
    730741            /* init the bounding box */ 
     
    739750             
    740751            /* compute the quantized x, y, and z values */ 
    741             LASPoint_SetX(point, 0.5 + (xyz[0] - xyz_offset[0]) / xyz_scale[0]); 
    742             LASPoint_SetY(point, 0.5 + (xyz[1] - xyz_offset[1]) / xyz_scale[1]); 
    743             LASPoint_SetX(point, 0.5 + (xyz[2] - xyz_offset[2]) / xyz_scale[2]); 
     752            LASPoint_SetX(point, xyz[0]); 
     753            LASPoint_SetY(point, xyz[1]); 
     754            LASPoint_SetZ(point, xyz[2]); 
    744755 
    745756            /* write the first point */ 
    746             LASWriter_WritePoint(writer, point); 
    747             printf("Writing point..."); 
     757            err = LASWriter_WritePoint(writer, point); 
     758            if (err) { 
     759                LASError_Print("could not write point"); 
     760                exit(1); 
     761            } 
    748762               
    749763            /* we can stop this loop */ 
     
    756770                    parse_string); 
    757771        } 
     772        LASPoint_Destroy(point); 
     773        point = NULL; 
    758774    } 
    759775 
     
    769785    while (fgets(line, sizeof(char) * MAX_CHARACTERS_PER_LINE, file_in)) 
    770786    { 
     787        point = LASPoint_Create(); 
    771788        if (parse(parse_string, line, xyz, &point, &gps_time)) 
    772789        { 
     
    781798 
    782799            /* compute the quantized x, y, and z values */ 
    783             LASPoint_SetX(point, 0.5 + (xyz[0] - xyz_offset[0]) / xyz_scale[0]); 
    784             LASPoint_SetY(point, 0.5 + (xyz[1] - xyz_offset[1]) / xyz_scale[1]); 
    785             LASPoint_SetX(point, 0.5 + (xyz[2] - xyz_offset[2]) / xyz_scale[2]); 
     800            LASPoint_SetX(point, xyz[0]); 
     801            LASPoint_SetY(point, xyz[1]); 
     802            LASPoint_SetZ(point, xyz[2]); 
    786803 
    787804            /* write the first point */ 
    788             LASWriter_WritePoint(writer, point); 
     805            err = LASWriter_WritePoint(writer, point); 
     806            if (err) { 
     807                LASError_Print("could not write point"); 
     808                exit(1); 
     809            } 
     810 
    789811        } 
    790812        else 
     
    794816            parse_string); 
    795817        } 
     818        LASPoint_Destroy(point); 
     819        point = NULL; 
    796820    } 
    797821