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

« back to all changes in this revision

Viewing changes to test/sample/write.cpp

  • 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
// $Id$
 
2
//
 
3
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
 
4
// Distributed under the BSD License
 
5
// (See accompanying file LICENSE.txt or copy at
 
6
// http://www.opensource.org/licenses/bsd-license.php)
 
7
//
 
8
#if defined(_MSC_VER) && defined(USE_VLD)
 
9
#include <vld.h>
 
10
#endif
 
11
// liblas
 
12
#include <liblas/liblas.hpp>
 
13
#include <liblas/lasheader.hpp>
 
14
#include <liblas/laspoint.hpp>
 
15
#include <liblas/laswriter.hpp>
 
16
#include <liblas/guid.hpp>
 
17
// std
 
18
#include <algorithm>
 
19
#include <exception>
 
20
#include <stdexcept>
 
21
#include <iomanip>
 
22
#include <iostream>
 
23
#include <fstream>
 
24
#include <string>
 
25
#include <utility>
 
26
#include <cstdlib>
 
27
#include <cassert>
 
28
// sample
 
29
#include "utility.hpp"
 
30
using namespace std;
 
31
 
 
32
int main()
 
33
{
 
34
    using liblas::LASHeader;
 
35
 
 
36
    try
 
37
    {
 
38
        char const* name = "test.las";
 
39
 
 
40
        std::ofstream ofs;
 
41
        if (!liblas::Create(ofs, name))
 
42
        {
 
43
            throw std::runtime_error(std::string("Can not create ") + name);
 
44
        }
 
45
 
 
46
        liblas::LASHeader hdr;
 
47
        hdr.SetVersionMajor(1);
 
48
        hdr.SetVersionMinor(1);
 
49
        hdr.SetDataFormatId(LASHeader::ePointFormat1);
 
50
        hdr.SetPointRecordsCount(1000); // should be corrected automatically by writer
 
51
        liblas::LASWriter writer(ofs, hdr);
 
52
 
 
53
        liblas::LASPoint p;
 
54
        p.SetCoordinates(10, 20, 30);
 
55
 
 
56
        writer.WritePoint(p);
 
57
    }
 
58
    catch (std::exception const& e)
 
59
    {
 
60
        std::cerr << "Error: " << e.what() << std::endl;
 
61
    }
 
62
    catch (...)
 
63
    {
 
64
        std::cerr << "Unknown error\n";
 
65
    }
 
66
 
 
67
    return 0;
 
68
}