~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to apps/bigtest.c

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <liblas.h>
 
2
#include <stdio.h>
 
3
#include <stdlib.h>
 
4
#include <string.h>
 
5
 
 
6
void dumperror (const char * appmsg)
 
7
{
 
8
   printf("\n%s.\n\tMessage:  %s\n\tMethod: %s",appmsg, LASError_GetLastErrorMsg(), LASError_GetLastErrorMethod());
 
9
}
 
10
int main()
 
11
{
 
12
 
 
13
    LASHeaderH header = NULL;
 
14
    LASWriterH writer = NULL;
 
15
    LASReaderH reader = NULL;
 
16
    LASPointH pt = NULL;
 
17
    LASError err;
 
18
    // Limitation about seeking past 4GB output size.  At 20 bytes / record, we
 
19
    // can successfully write 204 million records, but not 205.
 
20
    const unsigned long nMillionPoints = 205;
 
21
    const unsigned long NPOINTS = 1024*1024*nMillionPoints ;
 
22
    const char * OutputName = "Issue147.las";
 
23
    unsigned long i = 0;
 
24
    unsigned long npoints = 0;
 
25
 
 
26
    // Write a LAS file and after the points are in, update the header.
 
27
    header = LASHeader_Create();
 
28
    writer = LASWriter_Create(OutputName, header, LAS_MODE_WRITE);
 
29
    
 
30
    for (i = 0; i < NPOINTS; i++)
 
31
    {
 
32
      if (i % 1000 == 0)
 
33
         printf("\b\b\b\b\b\b\b%6.2f%%", ((double)i)/NPOINTS * 100.0);
 
34
      
 
35
      pt = LASPoint_Create();
 
36
      err = LASPoint_SetX(pt, 0);
 
37
      if (err) printf ("For point %lu, failed to set point value X\n", i);
 
38
      err = LASPoint_SetY(pt, 0);
 
39
      if (err) printf ("For point %lu, failed to set point value Y\n", i);
 
40
      err = LASPoint_SetZ(pt, 0);
 
41
      if (err) printf ("For point %lu, failed to set point value Z\n", i);
 
42
      err = LASWriter_WritePoint(writer, pt);  
 
43
      if (err) printf ("For point %lu, failed to WritePoint\n", i);
 
44
      LASPoint_Destroy(pt);
 
45
    }
 
46
   err = LASHeader_SetPointRecordsCount(header, NPOINTS);
 
47
   if (err) dumperror ("Failed to LASHeader_SetPointRecordsCount\n");
 
48
   err = LASWriter_WriteHeader(writer, header);
 
49
   if (err) dumperror ("Failed to LASWriter_WriteHeader");
 
50
   LASWriter_Destroy(writer);
 
51
   LASHeader_Destroy(header);
 
52
   
 
53
   // Read the file we just wrote and check the header data.
 
54
    reader = LASReader_Create(OutputName);
 
55
    header = LASReader_GetHeader(reader);
 
56
    npoints = LASHeader_GetPointRecordsCount(header);
 
57
    printf ("\n\nWrote %lu, Read %lu (testing %lu Million (1024 x 1024) Points)\n", NPOINTS, npoints, nMillionPoints);
 
58
}