~ubuntu-branches/ubuntu/utopic/liblas/utopic

« back to all changes in this revision

Viewing changes to src/writer.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2013-11-26 16:03:56 UTC
  • mto: (2.1.1 experimental) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: package-import@ubuntu.com-20131126160356-r94gc8jmp4lm0yix
Tags: upstream-1.7.0
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id$
 
3
 *
 
4
 * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
 
5
 * Purpose:  LAS writer class 
 
6
 * Author:   Mateusz Loskot, mateusz@loskot.net
 
7
 *
 
8
 ******************************************************************************
 
9
 * Copyright (c) 2008, Mateusz Loskot
 
10
 *
 
11
 * All rights reserved.
 
12
 * 
 
13
 * Redistribution and use in source and binary forms, with or without 
 
14
 * modification, are permitted provided that the following 
 
15
 * conditions are met:
 
16
 * 
 
17
 *     * Redistributions of source code must retain the above copyright 
 
18
 *       notice, this list of conditions and the following disclaimer.
 
19
 *     * Redistributions in binary form must reproduce the above copyright 
 
20
 *       notice, this list of conditions and the following disclaimer in 
 
21
 *       the documentation and/or other materials provided 
 
22
 *       with the distribution.
 
23
 *     * Neither the name of the Martin Isenburg or Iowa Department 
 
24
 *       of Natural Resources nor the names of its contributors may be 
 
25
 *       used to endorse or promote products derived from this software 
 
26
 *       without specific prior written permission.
 
27
 * 
 
28
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
29
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
30
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
31
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
32
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 
33
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 
34
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
 
35
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 
36
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 
37
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 
38
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
39
 * OF SUCH DAMAGE.
 
40
 ****************************************************************************/
 
41
 
 
42
#include <liblas/version.hpp>
 
43
#include <liblas/writer.hpp>
 
44
#include <liblas/detail/writer/writer.hpp>
 
45
#include <liblas/detail/writer/zipwriter.hpp>
 
46
#include <liblas/factory.hpp>
 
47
 
 
48
// std
 
49
#include <stdexcept>
 
50
#include <fstream>
 
51
#include <string>
 
52
#include <cstring> // std::memset
 
53
#include <cassert>
 
54
 
 
55
namespace liblas
 
56
{
 
57
 
 
58
Writer::Writer(std::ostream& ofs, Header const& header) :
 
59
#ifdef HAVE_LASZIP
 
60
    m_pimpl(WriterIPtr( WriterFactory::CreateWithStream(ofs, header) ) )
 
61
#else
 
62
    m_pimpl(WriterIPtr(new detail::WriterImpl(ofs)))
 
63
#endif
 
64
 
 
65
{
 
66
    m_pimpl->SetHeader(header);
 
67
    m_pimpl->WriteHeader();
 
68
}
 
69
 
 
70
 
 
71
Writer::Writer(Writer const& other) 
 
72
    : m_pimpl(other.m_pimpl)
 
73
{
 
74
}
 
75
 
 
76
Writer& Writer::operator=(Writer const& rhs)
 
77
{
 
78
    if (&rhs != this)
 
79
    {
 
80
        m_pimpl = rhs.m_pimpl;
 
81
    }
 
82
    return *this;
 
83
}
 
84
 
 
85
Writer::Writer(WriterIPtr ptr) :
 
86
    m_pimpl(ptr)
 
87
 
 
88
{
 
89
}
 
90
 
 
91
Writer::~Writer()
 
92
{
 
93
 
 
94
}
 
95
 
 
96
Header const& Writer::GetHeader() const
 
97
{
 
98
    return m_pimpl->GetHeader();
 
99
}
 
100
 
 
101
void Writer::SetHeader(Header const& header)
 
102
{
 
103
    return m_pimpl->SetHeader(header);
 
104
}
 
105
 
 
106
bool Writer::WritePoint(Point const& point)
 
107
{
 
108
    m_pimpl->WritePoint(point);
 
109
    return true;
 
110
}
 
111
 
 
112
void Writer::WriteHeader()
 
113
{
 
114
    // The writer may update our header as part of its 
 
115
    // writing process (change VLRs for SRS's, for instance).
 
116
    m_pimpl->WriteHeader();
 
117
}
 
118
 
 
119
void Writer::SetTransforms(std::vector<liblas::TransformPtr> const& transforms)
 
120
{
 
121
    m_pimpl->SetTransforms(transforms);
 
122
}
 
123
std::vector<liblas::FilterPtr>  Writer::GetFilters() const
 
124
{
 
125
    return m_pimpl->GetFilters();
 
126
}
 
127
 
 
128
void Writer::SetFilters(std::vector<liblas::FilterPtr> const& filters)
 
129
{
 
130
    m_pimpl->SetFilters(filters);
 
131
}    
 
132
std::vector<liblas::TransformPtr>  Writer::GetTransforms() const
 
133
{
 
134
    return m_pimpl->GetTransforms();
 
135
}
 
136
} // namespace liblas
 
137