1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5
* Purpose: C API for libLAS
6
* Author: Howard Butler, hobu.inc@gmail.com, but I'm not proud of it.
7
* I also swiped a lot of it from GDAL.
9
******************************************************************************
10
* Copyright (c) 2008, Mateusz Loskot
11
* Copyright (c) 2008, Howard Butler
13
* All rights reserved.
15
* Redistribution and use in source and binary forms, with or without
16
* modification, are permitted provided that the following
19
* * Redistributions of source code must retain the above copyright
20
* notice, this list of conditions and the following disclaimer.
21
* * Redistributions in binary form must reproduce the above copyright
22
* notice, this list of conditions and the following disclaimer in
23
* the documentation and/or other materials provided
24
* with the distribution.
25
* * Neither the name of the Martin Isenburg or Iowa Department
26
* of Natural Resources nor the names of its contributors may be
27
* used to endorse or promote products derived from this software
28
* without specific prior written permission.
30
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
36
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
37
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
38
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
40
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
42
****************************************************************************/
44
#ifdef HAVE_LIBGEOTIFF
45
// Supress inclusion of cpl_serv.h per #194, perhaps remove one day
46
// when libgeotiff 1.4.0+ is widely used
47
#define CPL_SERV_H_INCLUDED
50
#include <geo_simpletags.h>
51
#include <geo_normalize.h>
54
#include <liblas/liblas.hpp>
55
#include <liblas/detail/reader/reader.hpp>
56
#include <liblas/detail/reader/zipreader.hpp>
57
#include <liblas/detail/reader/cachedreader.hpp>
58
#include <liblas/external/property_tree/xml_parser.hpp>
60
typedef struct LASWriterHS *LASWriterH;
61
typedef struct LASReaderHS *LASReaderH;
62
typedef struct LASPointHS *LASPointH;
63
typedef liblas::HeaderPtr* LASHeaderH;
64
typedef struct LASGuidHS *LASGuidH;
65
typedef struct LASVLRHS *LASVLRH;
66
typedef struct LASColorHS *LASColorH;
67
typedef struct LASSRSHS *LASSRSH;
68
typedef struct LASSchemaHS *LASSchemaH;
69
typedef struct LASFilterHS *LASFilterH;
72
#include <boost/cstdint.hpp>
80
#include <sstream> // std::stringstream
86
using namespace liblas;
89
#define compare_no_case(a,b,n) _strnicmp( (a), (b), (n) )
91
#define compare_no_case(a,b,n) strncasecmp( (a), (b), (n) )
94
#include <boost/lambda/lambda.hpp>
96
bool IsReprojectionTransform(liblas::TransformPtr const& p)
98
if (dynamic_cast<liblas::ReprojectionTransform*>(p.get()))
122
LE_Filter_Bounds = 0,
123
LE_Filter_Classification = 1,
125
LE_Filter_Return = 3,
127
LE_Filter_Intensity = 5,
128
LE_Filter_ScanAngleRank = 6,
134
LE_Transform_Reprojection = 0
137
static std::stack<liblas::Error > errors;
138
static std::vector<liblas::TransformPtr> transforms;
139
static std::vector<liblas::FilterPtr> filters;
142
static std::map<liblas::Reader*, std::istream*> readers;
143
static std::map<liblas::Writer*, std::ostream*> writers;
146
# pragma warning(disable: 4127) // warning C4127: conditional expression is constant
147
# pragma warning(disable: 4702) // unreachable code
150
#define VALIDATE_LAS_POINTER0(ptr, func) \
151
do { if( NULL == ptr ) { \
152
LASErrorEnum const ret = LE_Failure; \
153
std::ostringstream msg; \
154
msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \
155
std::string message(msg.str()); \
156
LASError_PushError( ret, message.c_str(), (func)); \
160
#define VALIDATE_LAS_POINTER1(ptr, func, rc) \
161
do { if( NULL == ptr ) { \
162
LASErrorEnum const ret = LE_Failure; \
163
std::ostringstream msg; \
164
msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \
165
std::string message(msg.str()); \
166
LASError_PushError( ret, message.c_str(), (func)); \
170
LAS_DLL int LAS_IsGDALEnabled(void) {
171
return IsGDALEnabled();
174
LAS_DLL int LAS_IsLibGeoTIFFEnabled(void) {
175
return IsLibGeoTIFFEnabled();
178
LAS_DLL void LASError_Reset(void) {
179
if (errors.empty()) return;
180
for (std::stack<liblas::Error >::size_type i=0;i<errors.size();i++) errors.pop();
183
LAS_DLL void LASError_Pop(void) {
184
if (errors.empty()) return;
188
LAS_DLL int LASError_GetLastErrorNum(void){
192
liblas::Error err = errors.top();
193
return err.GetCode();
197
LAS_DLL char* LASError_GetLastErrorMsg(void){
201
liblas::Error err = errors.top();
202
return LASCopyString(err.GetMessage().c_str());
206
LAS_DLL char* LASError_GetLastErrorMethod(void){
210
liblas::Error err = errors.top();
211
return LASCopyString(err.GetMethod().c_str());
215
LAS_DLL void LASError_PushError(int code, const char *message, const char *method) {
216
liblas::Error err = liblas::Error(code, std::string(message), std::string(method));
220
LAS_DLL int LASError_GetErrorCount(void) {
221
return static_cast<int>(errors.size());
226
LAS_DLL LASReaderH LASReader_Create(const char* filename)
229
VALIDATE_LAS_POINTER1(filename, "LASReader_Create", NULL);
231
std::istream* istrm = NULL;
233
istrm = liblas::Open(filename, std::ios::in | std::ios::binary);
234
} catch (std::exception const& e)
238
LASError_PushError(LE_Failure, e.what(), "LASReader_Create");
243
liblas::ReaderFactory f;
244
liblas::Reader* reader = new liblas::Reader(f.CreateWithStream(*istrm));
245
readers.insert(std::pair<liblas::Reader*, std::istream*>(reader, istrm));
246
return (LASReaderH) reader;
247
} catch (std::exception const& e)
249
LASError_PushError(LE_Failure, e.what(), "LASReader_Create");
257
LAS_DLL LASReaderH LASReader_CreateWithHeader( const char* filename,
261
VALIDATE_LAS_POINTER1(filename, "LASReader_CreateWithHeader", NULL);
262
VALIDATE_LAS_POINTER1(hHeader->get(), "LASReader_CreateWithHeader", NULL);
264
std::istream* istrm = NULL;
265
liblas::ReaderFactory f;
267
istrm = liblas::Open(filename, std::ios::in | std::ios::binary);
268
} catch (std::exception const& e)
270
if (istrm) delete istrm;
271
LASError_PushError(LE_Failure, e.what(), "LASReader_Create");
277
liblas::Reader* reader = new liblas::Reader(f.CreateWithStream(*istrm));
279
liblas::Header const& current_header = reader->GetHeader();
281
// If the original data were compressed, we need to override whatever value
282
// our incoming header has for that value
283
liblas::HeaderPtr* header = ((liblas::HeaderPtr*) hHeader);
284
if (current_header.Compressed())
286
header->get()->SetCompressed(true);
288
reader->SetHeader(*header->get());
289
readers.insert(std::pair<liblas::Reader*, std::istream*>(reader, istrm));
290
return (LASReaderH) reader;
293
} catch (std::exception const& e)
295
LASError_PushError(LE_Failure, e.what(), "LASReader_Create");
302
LAS_DLL void LASReader_SetHeader( LASReaderH hReader, const LASHeaderH hHeader)
305
VALIDATE_LAS_POINTER0(hReader, "LASReader_SetHeader");
306
VALIDATE_LAS_POINTER0(hHeader, "LASReader_SetHeader");
308
liblas::Reader* reader = (liblas::Reader*)hReader;
309
liblas::HeaderPtr* header = (liblas::HeaderPtr*)hHeader;
311
reader->SetHeader(*header->get());
314
LAS_DLL void LASReader_Destroy(LASReaderH hReader)
316
VALIDATE_LAS_POINTER0(hReader, "LASReader_Destroy");
319
liblas::Reader* reader = (liblas::Reader*)hReader;
321
std::map<liblas::Reader*, std::istream*>::iterator it = readers.find(reader);
322
if (it == readers.end())
324
LASError_PushError(LE_Failure, "Unable to find reader stream", "LASReader_Destroy");
327
std::istream* istrm = it->second;
334
LASError_PushError(LE_Failure, "Got 99 problems, but the stream ain't one", "LASReader_Destroy");
338
liblas::Cleanup(istrm);
340
readers.erase(reader);
343
} catch (std::runtime_error const& e/* e */)
345
LASError_PushError(LE_Failure, e.what(), "LASReader_Destroy");
355
LAS_DLL const LASPointH LASReader_GetNextPoint(const LASReaderH hReader)
357
VALIDATE_LAS_POINTER1(hReader, "LASReader_GetNextPoint", NULL);
360
liblas::Reader *reader = ((liblas::Reader*) hReader);
361
if (reader->ReadNextPoint())
362
// return (LASPointH) new LASPoint(reader->GetPoint());
363
return (LASPointH) &(reader->GetPoint());
366
} catch (invalid_point_data const& e /*e */) {
367
LASError_PushError(LE_Failure, e.what(), "LASReader_GetNextPoint Invalid Point");
368
} catch (std::exception const& e)
370
LASError_PushError(LE_Failure, e.what(), "LASReader_GetNextPoint");
376
LAS_DLL const LASPointH LASReader_GetPointAt(const LASReaderH hReader, boost::uint32_t position)
378
VALIDATE_LAS_POINTER1(hReader, "LASReader_GetPointAt", NULL);
381
liblas::Reader *reader = ((liblas::Reader*) hReader);
382
if (reader->ReadPointAt((std::size_t) position))
383
// return (LASPointH) new LASPoint(reader->GetPoint());
384
return (LASPointH) &(reader->GetPoint());
387
} catch (invalid_point_data const& e /*e */) {
388
LASError_PushError(LE_Failure, e.what(), "LASReader_GetPointAt Invalid Point");
389
} catch (std::exception const& e)
391
LASError_PushError(LE_Failure, e.what(), "LASReader_GetPointAt");
398
LAS_DLL LASErrorEnum LASReader_Seek(LASReaderH hReader, boost::uint32_t position)
400
VALIDATE_LAS_POINTER1(hReader, "LASReader_Seek", LE_None);
403
liblas::Reader *reader = ((liblas::Reader*) hReader);
404
if (reader->Seek((std::size_t) position))
408
} catch (invalid_point_data const& e /*e */) {
409
LASError_PushError(LE_Failure, e.what(), "LASReader_Seek Invalid location");
410
} catch (std::exception const& e)
412
LASError_PushError(LE_Failure, e.what(), "LASReader_Seek");
419
LAS_DLL char* LASReader_GetSummaryXML(const LASReaderH hReader)
422
VALIDATE_LAS_POINTER1(hReader, "LASReader_GetSummaryXML", NULL);
423
liblas::Reader* r = (liblas::Reader*)hReader;
427
bool read = r->ReadNextPoint();
430
LASError_PushError(LE_Failure, "Unable to read point", "LASReader_GetSummaryXML");
436
liblas::Point const& p = r->GetPoint();
438
read = r->ReadNextPoint();
443
std::ostringstream oss;
445
liblas::property_tree::write_xml(oss, s.GetPTree());
446
return LASCopyString(oss.str().c_str());
450
LAS_DLL LASErrorEnum LASReader_SetInputSRS(LASReaderH hReader, const LASSRSH hSRS) {
452
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetInputSRS", LE_Failure);
453
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetInputSRS", LE_Failure);
456
liblas::Reader* reader = ((liblas::Reader*) hReader);
457
liblas::Header h = reader->GetHeader();
458
liblas::SpatialReference* ref = ((liblas::SpatialReference*) hSRS);
460
reader->SetHeader(h);
462
catch (std::exception const& e) {
463
LASError_PushError(LE_Failure, e.what(), "LASReader_SetInputSRS");
471
LAS_DLL LASHeaderH LASReader_GetHeader(const LASReaderH hReader)
473
VALIDATE_LAS_POINTER1(hReader, "LASReader_GetHeader", new liblas::HeaderPtr());
475
liblas::Header header = ((liblas::Reader*) hReader)->GetHeader();
476
return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header(header));
483
LAS_DLL LASErrorEnum LASReader_SetOutputSRS(LASReaderH hReader, const LASSRSH hSRS) {
485
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetOutputSRS", LE_Failure);
486
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetOutputSRS", LE_Failure);
489
liblas::Reader* reader = ((liblas::Reader*) hReader);
490
liblas::Header const& h = reader->GetHeader();
491
liblas::SpatialReference in_ref = h.GetSRS();
492
liblas::SpatialReference* out_ref = ((liblas::SpatialReference*) hSRS);
493
std::vector<liblas::TransformPtr> transforms = reader->GetTransforms();
495
transforms.erase( std::remove_if( transforms.begin(),
497
boost::bind( &IsReprojectionTransform, _1 ) ),
500
liblas::TransformPtr srs_transform = liblas::TransformPtr(new liblas::ReprojectionTransform(in_ref, *out_ref, &h));
501
if (transforms.size())
502
transforms.insert(transforms.begin(), srs_transform);
504
transforms.push_back(srs_transform);
505
reader->SetTransforms(transforms);
507
// ((liblas::Reader*) hReader)->SetOutputSRS(*((liblas::SpatialReference*)hSRS));
509
catch (std::exception const& e) {
510
LASError_PushError(LE_Failure, e.what(), "LASReader_SetOutputSRS");
517
LAS_DLL LASErrorEnum LASReader_SetSRS(LASReaderH hReader, const LASSRSH hSRS) {
519
VALIDATE_LAS_POINTER1(hReader, "LASReader_SetSRS", LE_Failure);
520
VALIDATE_LAS_POINTER1(hSRS, "LASReader_SetSRS", LE_Failure);
522
return LASReader_SetOutputSRS(hReader, hSRS);
525
LAS_DLL LASHeaderH LASHeader_Create(void) {
526
return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header());
529
LAS_DLL LASPointH LASPoint_Create(void) {
530
return (LASPointH) new liblas::Point();
533
LAS_DLL LASPointH LASPoint_Copy(const LASPointH hPoint) {
534
return (LASPointH) new liblas::Point(*((liblas::Point*) hPoint));
537
LAS_DLL LASHeaderH LASPoint_GetHeader(const LASPointH hPoint)
539
VALIDATE_LAS_POINTER1(hPoint , "LASPoint_GetHeader", new liblas::HeaderPtr());
541
liblas::Point const& p= *((liblas::Point*) hPoint);
542
liblas::Header const* h = p.GetHeader();
543
return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header(*h));
547
LAS_DLL void LASPoint_SetHeader( LASPointH hPoint, const LASHeaderH hHeader)
550
VALIDATE_LAS_POINTER0(hPoint, "LASPoint_SetHeader");
551
VALIDATE_LAS_POINTER0(hHeader, "LASPoint_SetHeader");
553
liblas::Point* point = (liblas::Point*)hPoint;
554
liblas::HeaderPtr h = (liblas::HeaderPtr)*hHeader;
555
liblas::Header const& header = *h;
556
point->SetHeader(&header);
559
LAS_DLL LASErrorEnum LASPoint_SetData(LASPointH hPoint, unsigned char* data) {
561
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetData", LE_Failure);
562
VALIDATE_LAS_POINTER1(data, "LASPoint_SetData", LE_Failure);
565
liblas::Point* p = ((liblas::Point*) hPoint);
566
boost::uint16_t size = 0;
568
liblas::Header const* h = p->GetHeader();
569
size = h->GetDataRecordLength();
571
std::vector<boost::uint8_t> & d = p->GetData();
572
if (d.size() != size)
575
d.assign(static_cast<boost::uint32_t>(0), d.size());
578
for (boost::uint16_t i=0; i < size; i++) {
582
catch (std::exception const& e) {
583
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetData");
591
LAS_DLL LASErrorEnum LASPoint_GetData( const LASPointH hPoint, boost::uint8_t* data) {
593
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetData", LE_Failure);
594
VALIDATE_LAS_POINTER1(data, "LASPoint_GetData", LE_Failure);
597
liblas::Point* p = ((liblas::Point*) hPoint);
598
boost::uint16_t size = 0;
599
std::vector<boost::uint8_t> const& d = p->GetData();
601
liblas::Header const* h = p->GetHeader();
602
size = h->GetDataRecordLength();
604
for (boost::uint16_t i=0; i < size; i++) {
608
catch (std::exception const& e) {
609
LASError_PushError(LE_Failure, e.what(), "LASPoint_GetData");
618
LAS_DLL void LASPoint_Destroy(LASPointH hPoint) {
619
VALIDATE_LAS_POINTER0(hPoint, "LASPoint_Destroy");
620
delete (liblas::Point*) hPoint;
624
LAS_DLL double LASPoint_GetX(const LASPointH hPoint) {
626
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetX", 0.0);
628
double value = ((liblas::Point*) hPoint)->GetX();
632
LAS_DLL LASErrorEnum LASPoint_SetX(LASPointH hPoint, double value) {
634
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetX", LE_Failure);
637
((liblas::Point*) hPoint)->SetX(value);
638
} catch (std::exception const& e)
640
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetX");
648
LAS_DLL boost::int32_t LASPoint_GetRawX(const LASPointH hPoint) {
650
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawX", 0);
652
long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawX());
656
LAS_DLL LASErrorEnum LASPoint_SetRawX(LASPointH hPoint, boost::int32_t value) {
658
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetRawX", LE_Failure);
661
((liblas::Point*) hPoint)->SetRawX(value);
662
} catch (std::exception const& e)
664
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetRawX");
672
LAS_DLL double LASPoint_GetY(const LASPointH hPoint) {
674
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetY", 0.0);
676
double value = ((liblas::Point*) hPoint)->GetY();
680
LAS_DLL LASErrorEnum LASPoint_SetY(LASPointH hPoint, double value) {
682
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetY", LE_Failure);
685
((liblas::Point*) hPoint)->SetY(value);
686
} catch (std::exception const& e)
688
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetY");
696
LAS_DLL boost::int32_t LASPoint_GetRawY(const LASPointH hPoint) {
698
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawY", 0);
700
long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawY());
704
LAS_DLL LASErrorEnum LASPoint_SetRawY(LASPointH hPoint, boost::int32_t value) {
706
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetRawY", LE_Failure);
709
((liblas::Point*) hPoint)->SetRawY(value);
710
} catch (std::exception const& e)
712
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetRawY");
719
LAS_DLL double LASPoint_GetZ(const LASPointH hPoint) {
721
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetZ", 0.0);
723
double value = ((liblas::Point*) hPoint)->GetZ();
727
LAS_DLL LASErrorEnum LASPoint_SetZ(LASPointH hPoint, double value) {
729
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetZ", LE_Failure);
732
((liblas::Point*) hPoint)->SetZ(value);
733
} catch (std::exception const& e)
735
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetZ");
743
LAS_DLL boost::int32_t LASPoint_GetRawZ(const LASPointH hPoint) {
745
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetRawZ", 0);
747
long value = static_cast<long>(((liblas::Point*) hPoint)->GetRawZ());
751
LAS_DLL LASErrorEnum LASPoint_SetRawZ(LASPointH hPoint, boost::int32_t value) {
753
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetRawZ", LE_Failure);
756
((liblas::Point*) hPoint)->SetRawZ(value);
757
} catch (std::exception const& e)
759
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetRawZ");
767
LAS_DLL boost::uint16_t LASPoint_GetIntensity(const LASPointH hPoint) {
769
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetIntensity", 0);
771
boost::uint16_t value = ((liblas::Point*) hPoint)->GetIntensity();
775
LAS_DLL LASErrorEnum LASPoint_SetIntensity(LASPointH hPoint, boost::uint16_t value) {
777
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetIntensity", LE_Failure);
780
((liblas::Point*) hPoint)->SetIntensity(value);
781
} catch (std::exception const& e)
783
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetIntensity");
791
LAS_DLL boost::uint16_t LASPoint_GetReturnNumber(const LASPointH hPoint) {
793
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetReturnNumber", 0);
795
boost::uint16_t value = ((liblas::Point*) hPoint)->GetReturnNumber();
799
LAS_DLL LASErrorEnum LASPoint_SetReturnNumber(LASPointH hPoint, boost::uint16_t value) {
801
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetReturnNumber", LE_Failure);
804
((liblas::Point*) hPoint)->SetReturnNumber(value);
805
} catch (std::exception const& e)
807
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetReturnNumber");
815
LAS_DLL boost::uint16_t LASPoint_GetNumberOfReturns(const LASPointH hPoint) {
817
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetNumberOfReturns", 0);
819
boost::uint16_t value = ((liblas::Point*) hPoint)->GetNumberOfReturns();
823
LAS_DLL LASErrorEnum LASPoint_SetNumberOfReturns(LASPointH hPoint, boost::uint16_t value) {
825
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetNumberOfReturns", LE_Failure);
828
((liblas::Point*) hPoint)->SetNumberOfReturns(value);
829
} catch (std::exception const& e)
831
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetNumberOfReturns");
839
LAS_DLL boost::uint16_t LASPoint_GetScanDirection(const LASPointH hPoint) {
841
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetScanDirection", 0);
843
boost::uint16_t value = ((liblas::Point*) hPoint)->GetScanDirection();
847
LAS_DLL LASErrorEnum LASPoint_SetScanDirection(LASPointH hPoint, boost::uint16_t value) {
849
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetScanDirection", LE_Failure);
852
((liblas::Point*) hPoint)->SetScanDirection(value);
853
} catch (std::exception const& e)
855
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetScanDirection");
863
LAS_DLL boost::uint16_t LASPoint_GetFlightLineEdge(const LASPointH hPoint) {
865
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetFlightLineEdge", 0);
867
boost::uint16_t value = ((liblas::Point*) hPoint)->GetFlightLineEdge();
871
LAS_DLL LASErrorEnum LASPoint_SetFlightLineEdge(LASPointH hPoint, boost::uint16_t value) {
873
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetFlightLineEdge", LE_Failure);
876
((liblas::Point*) hPoint)->SetFlightLineEdge(value);
877
} catch (std::exception const& e)
879
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetFlightLineEdge");
887
LAS_DLL boost::uint8_t LASPoint_GetScanFlags(const LASPointH hPoint) {
889
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetScanFlags", 0);
891
boost::uint8_t value = ((liblas::Point*) hPoint)->GetScanFlags();
895
LAS_DLL LASErrorEnum LASPoint_SetScanFlags(LASPointH hPoint, boost::uint8_t value) {
897
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetScanFlags", LE_Failure);
900
((liblas::Point*) hPoint)->SetScanFlags(value);
901
} catch (std::exception const& e)
903
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetScanFlags");
911
LAS_DLL boost::uint8_t LASPoint_GetClassification(const LASPointH hPoint) {
913
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetClassification", 0);
915
liblas::Classification::bitset_type clsflags(((liblas::Point*) hPoint)->GetClassification());
916
boost::uint8_t value = static_cast<boost::uint8_t>(clsflags.to_ulong());
920
LAS_DLL LASErrorEnum LASPoint_SetClassification(LASPointH hPoint, boost::uint8_t value) {
922
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetClassification", LE_Failure);
925
((liblas::Point*) hPoint)->SetClassification(value);
926
} catch (std::exception const& e)
928
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetClassification");
936
LAS_DLL LASErrorEnum LASPoint_SetTime(LASPointH hPoint, double value) {
938
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetTime", LE_Failure);
941
((liblas::Point*) hPoint)->SetTime(value);
944
catch (std::runtime_error const&)
946
// drop the value on the floor. If the point has a schema that
947
// doesn't have time, the user needs to change the point's header.
949
catch (std::exception const& e)
951
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetTime");
959
LAS_DLL double LASPoint_GetTime(const LASPointH hPoint) {
961
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetTime", 0.0);
965
value = ((liblas::Point*) hPoint)->GetTime();
967
} catch (std::runtime_error const&)
974
LAS_DLL char LASPoint_GetScanAngleRank(const LASPointH hPoint) {
976
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetScanAngleRank", 0);
978
boost::int8_t value = ((liblas::Point*) hPoint)->GetScanAngleRank();
979
return static_cast<char>(value);
982
LAS_DLL LASErrorEnum LASPoint_SetScanAngleRank(LASPointH hPoint, char value) {
984
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetScanAngleRank", LE_Failure);
987
((liblas::Point*) hPoint)->SetScanAngleRank(static_cast<boost::int8_t>(value));
988
} catch (std::exception const& e)
990
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetScanAngleRank");
998
LAS_DLL boost::uint16_t LASPoint_GetPointSourceId(const LASPointH hPoint) {
1000
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetPointSourceId", 0);
1002
boost::uint16_t value = ((liblas::Point*) hPoint)->GetPointSourceID();
1006
LAS_DLL LASErrorEnum LASPoint_SetPointSourceId(LASPointH hPoint, boost::uint16_t value) {
1008
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetPointSourceId", LE_Failure);
1011
((liblas::Point*) hPoint)->SetPointSourceID(value);
1012
} catch (std::exception const& e)
1014
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetPointSourceId");
1023
LAS_DLL boost::uint8_t LASPoint_GetUserData(const LASPointH hPoint) {
1025
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetUserData", 0);
1027
boost::uint8_t value = ((liblas::Point*) hPoint)->GetUserData();
1031
LAS_DLL char* LASPoint_GetXML(const LASPointH hPoint)
1033
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetXML", NULL);
1034
liblas::Point* p = (liblas::Point*)hPoint;
1036
std::ostringstream oss;
1038
liblas::property_tree::ptree tree= p->GetPTree();
1039
liblas::property_tree::write_xml(oss, tree);
1040
return LASCopyString(oss.str().c_str());
1044
LAS_DLL LASErrorEnum LASPoint_SetUserData(LASPointH hPoint, boost::uint8_t value) {
1046
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetUserData", LE_Failure);
1049
((liblas::Point*) hPoint)->SetUserData(value);
1050
} catch (std::exception const& e)
1052
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetUserData");
1060
LAS_DLL int LASPoint_Equal(const LASPointH hPoint1, const LASPointH hPoint2) {
1061
VALIDATE_LAS_POINTER1(hPoint1, "LASPoint_Equal", 0);
1062
VALIDATE_LAS_POINTER1(hPoint2, "LASPoint_Equal", 0);
1064
liblas::Point* point1 = ((liblas::Point*) hPoint1);
1065
liblas::Point* point2 = ((liblas::Point*) hPoint2);
1067
return (point1 == point2);
1071
LAS_DLL int LASPoint_Validate(LASPointH hPoint) {
1073
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_Validate", LE_Failure);
1076
((liblas::Point*) hPoint)->Validate();
1077
} catch (invalid_point_data const& e /*e */) {
1079
} catch (std::exception const& e)
1081
LASError_PushError(LE_Failure, e.what(), "LASPoint_Validate");
1088
LAS_DLL int LASPoint_IsValid(LASPointH hPoint) {
1090
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_IsValid", LE_Failure);
1091
return ((liblas::Point*) hPoint)->IsValid();
1094
LAS_DLL char* LASHeader_GetFileSignature(const LASHeaderH hHeader) {
1096
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetFileSignature", NULL);
1098
std::string signature = ((liblas::HeaderPtr*) hHeader)->get()->GetFileSignature();
1099
return LASCopyString(signature.c_str());
1102
LAS_DLL boost::uint16_t LASHeader_GetFileSourceId(const LASHeaderH hHeader) {
1103
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetFileSourceId", 0);
1105
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetFileSourceId();
1109
LAS_DLL LASErrorEnum LASHeader_SetFileSourceId(LASHeaderH hHeader, boost::uint16_t value) {
1110
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetFileSourceId", LE_Failure);
1111
((liblas::HeaderPtr*) hHeader)->get()->SetFileSourceId(value);
1116
LAS_DLL boost::uint16_t LASHeader_GetReserved(const LASHeaderH hHeader) {
1117
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetReserved", 0);
1119
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetReserved();
1123
LAS_DLL LASErrorEnum LASHeader_SetReserved(LASHeaderH hHeader, boost::uint16_t value) {
1124
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetReserved", LE_Failure);
1125
((liblas::HeaderPtr*) hHeader)->get()->SetReserved(value);
1129
LAS_DLL char* LASHeader_GetProjectId(const LASHeaderH hHeader) {
1130
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetProjectId", 0);
1132
liblas::guid id = ((liblas::HeaderPtr*) hHeader)->get()->GetProjectId();
1133
return LASCopyString(id.to_string().c_str());
1136
LAS_DLL LASErrorEnum LASHeader_SetProjectId(LASHeaderH hHeader, const char* value) {
1137
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetProjectId", LE_Failure);
1141
id = liblas::guid(value);
1142
((liblas::HeaderPtr*) hHeader)->get()->SetProjectId(id);
1143
} catch (std::exception const& e)
1145
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetGUID");
1152
LAS_DLL boost::uint8_t LASHeader_GetVersionMajor(const LASHeaderH hHeader) {
1153
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetVersionMajor", 0);
1155
long value = ((liblas::HeaderPtr*) hHeader)->get()->GetVersionMajor();
1156
return boost::uint8_t(value);
1159
LAS_DLL LASErrorEnum LASHeader_SetVersionMajor(LASHeaderH hHeader, boost::uint8_t value) {
1160
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetVersionMajor", LE_Failure);
1163
((liblas::HeaderPtr*) hHeader)->get()->SetVersionMajor(value);
1164
} catch (std::exception const& e)
1166
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetVersionMajor");
1173
LAS_DLL boost::uint8_t LASHeader_GetVersionMinor(const LASHeaderH hHeader) {
1174
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetVersionMinor", 0);
1176
long value = ((liblas::HeaderPtr*) hHeader)->get()->GetVersionMinor();
1177
return boost::uint8_t(value);
1180
LAS_DLL LASErrorEnum LASHeader_SetVersionMinor(LASHeaderH hHeader, boost::uint8_t value) {
1181
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetVersionMinor", LE_Failure);
1183
// TODO: Maybe this should be a fatal error -- hobu
1185
((liblas::HeaderPtr*) hHeader)->get()->SetVersionMinor(value);
1186
} catch (std::exception const& e)
1188
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetVersionMinor");
1195
LAS_DLL char* LASHeader_GetSystemId(const LASHeaderH hHeader) {
1196
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSystemId", NULL);
1199
std::string sysid = ((liblas::HeaderPtr*) hHeader)->get()->GetSystemId();
1200
return LASCopyString(sysid.c_str());
1203
LAS_DLL LASErrorEnum LASHeader_SetSystemId(LASHeaderH hHeader, const char* value) {
1204
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetSystemId", LE_Failure);
1207
((liblas::HeaderPtr*) hHeader)->get()->SetSystemId(value);
1208
} catch (std::exception const& e)
1210
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSystemId");
1217
LAS_DLL char* LASHeader_GetSoftwareId(const LASHeaderH hHeader) {
1218
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSoftwareId", NULL);
1221
std::string softid = ((liblas::HeaderPtr*) hHeader)->get()->GetSoftwareId();
1222
return LASCopyString(softid.c_str());
1225
LAS_DLL LASErrorEnum LASHeader_SetSoftwareId(LASHeaderH hHeader, const char* value) {
1226
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetSoftwareId", LE_Failure);
1229
((liblas::HeaderPtr*) hHeader)->get()->SetSoftwareId(value);
1230
} catch (std::exception const& e)
1232
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSoftwareId");
1239
LAS_DLL boost::uint16_t LASHeader_GetCreationDOY(const LASHeaderH hHeader) {
1240
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetCreationDOY", 0);
1242
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetCreationDOY();
1246
LAS_DLL LASErrorEnum LASHeader_SetCreationDOY(LASHeaderH hHeader, boost::uint16_t value) {
1247
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetCreationDOY", LE_Failure);
1248
((liblas::HeaderPtr*) hHeader)->get()->SetCreationDOY(value);
1252
LAS_DLL boost::uint16_t LASHeader_GetCreationYear(const LASHeaderH hHeader) {
1253
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetCreationYear", 0);
1255
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetCreationYear();
1259
LAS_DLL LASErrorEnum LASHeader_SetCreationYear(LASHeaderH hHeader, boost::uint16_t value) {
1260
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetCreationYear", LE_Failure);
1261
((liblas::HeaderPtr*) hHeader)->get()->SetCreationYear(value);
1265
LAS_DLL boost::uint16_t LASHeader_GetHeaderSize(const LASHeaderH hHeader) {
1266
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetHeaderSize", 0);
1268
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetHeaderSize();
1272
LAS_DLL boost::uint32_t LASHeader_GetDataOffset(const LASHeaderH hHeader) {
1273
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetDataOffset", 0);
1275
unsigned long value = ((liblas::HeaderPtr*) hHeader)->get()->GetDataOffset();
1279
LAS_DLL LASErrorEnum LASHeader_SetDataOffset(const LASHeaderH hHeader, boost::uint32_t value) {
1280
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetDataOffset", LE_Failure);
1283
((liblas::HeaderPtr*) hHeader)->get()->SetDataOffset(value);
1284
} catch (std::exception const& e)
1286
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetDataOffset");
1293
LAS_DLL boost::uint32_t LASHeader_GetHeaderPadding(const LASHeaderH hHeader) {
1294
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetHeaderPadding", 0);
1296
unsigned long value = ((liblas::HeaderPtr*) hHeader)->get()->GetHeaderPadding();
1300
LAS_DLL LASErrorEnum LASHeader_SetHeaderPadding(const LASHeaderH hHeader, boost::uint32_t value) {
1301
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetHeaderPadding", LE_Failure);
1304
((liblas::HeaderPtr*) hHeader)->get()->SetHeaderPadding(value);
1305
} catch (std::exception const& e)
1307
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetHeaderPadding");
1314
LAS_DLL boost::uint32_t LASHeader_GetRecordsCount(const LASHeaderH hHeader) {
1315
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetRecordsCount", 0);
1317
unsigned long value = ((liblas::HeaderPtr*) hHeader)->get()->GetRecordsCount();
1321
LAS_DLL boost::uint8_t LASHeader_GetDataFormatId(const LASHeaderH hHeader) {
1322
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetDataFormatId", 0);
1324
liblas::PointFormatName id = ((liblas::HeaderPtr*) hHeader)->get()->GetDataFormatId();
1325
return static_cast<boost::uint8_t>(id);
1328
LAS_DLL LASErrorEnum LASHeader_SetDataFormatId(LASHeaderH hHeader, boost::uint8_t value) {
1329
VALIDATE_LAS_POINTER1(hHeader, "LASHeader_SetDataFormatId", LE_Failure);
1332
((liblas::HeaderPtr*) hHeader)->get()->SetDataFormatId((liblas::PointFormatName)value);
1333
} catch (std::exception const& e)
1335
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetDataFormatId");
1342
LAS_DLL boost::uint16_t LASHeader_GetDataRecordLength(const LASHeaderH hHeader) {
1343
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetDataRecordLength", 0);
1345
unsigned short value = ((liblas::HeaderPtr*) hHeader)->get()->GetDataRecordLength();
1351
LAS_DLL boost::uint32_t LASHeader_GetPointRecordsByReturnCount(const LASHeaderH hHeader, int index) {
1352
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetPointRecordsByReturnCount", 0);
1354
std::vector<boost::uint32_t> counts = ((liblas::HeaderPtr*) hHeader)->get()->GetPointRecordsByReturnCount();
1355
if ( (index < 5) && (index >= 0)) {
1356
return counts[index];
1363
LAS_DLL LASErrorEnum LASHeader_SetPointRecordsByReturnCount(const LASHeaderH hHeader, int index, boost::uint32_t value) {
1364
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetPointRecordsByReturnCount", LE_Failure);
1367
((liblas::HeaderPtr*) hHeader)->get()->SetPointRecordsByReturnCount(index, value);
1368
} catch (std::exception const& e)
1370
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetPointRecordsByReturnCount");
1378
LAS_DLL boost::uint32_t LASHeader_GetPointRecordsCount(const LASHeaderH hHeader) {
1379
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetPointRecordsCount", 0);
1381
unsigned long value = ((liblas::HeaderPtr*) hHeader)->get()->GetPointRecordsCount();
1385
LAS_DLL LASErrorEnum LASHeader_SetPointRecordsCount(const LASHeaderH hHeader, boost::uint32_t value) {
1386
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetPointRecordsCount", LE_Failure);
1389
((liblas::HeaderPtr*) hHeader)->get()->SetPointRecordsCount(value);
1390
} catch (std::exception const& e)
1392
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetPointRecordsCount");
1399
LAS_DLL double LASHeader_GetScaleX(const LASHeaderH hHeader) {
1400
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetScaleX", 0.0);
1402
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetScaleX();
1406
LAS_DLL double LASHeader_GetScaleY(const LASHeaderH hHeader) {
1407
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetScaleY", 0.0);
1409
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetScaleY();
1413
LAS_DLL double LASHeader_GetScaleZ(const LASHeaderH hHeader) {
1414
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetScaleZ", 0.0);
1416
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetScaleZ();
1420
LAS_DLL LASErrorEnum LASHeader_SetScale(LASHeaderH hHeader, double x, double y, double z) {
1421
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetScale", LE_Failure);
1424
((liblas::HeaderPtr*) hHeader)->get()->SetScale(x,y,z);
1425
} catch (std::exception const& e)
1427
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetScale");
1434
LAS_DLL double LASHeader_GetOffsetX(const LASHeaderH hHeader) {
1435
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetOffsetX", 0.0);
1437
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetOffsetX();
1441
LAS_DLL double LASHeader_GetOffsetY(const LASHeaderH hHeader) {
1442
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetOffsetY", 0.0);
1444
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetOffsetY();
1448
LAS_DLL double LASHeader_GetOffsetZ(const LASHeaderH hHeader) {
1449
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetOffsetZ", 0.0);
1451
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetOffsetZ();
1455
LAS_DLL LASErrorEnum LASHeader_SetOffset(LASHeaderH hHeader, double x, double y, double z) {
1456
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetOffset", LE_Failure);
1459
((liblas::HeaderPtr*) hHeader)->get()->SetOffset(x,y,z);
1460
} catch (std::exception const& e)
1462
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetOffset");
1469
LAS_DLL double LASHeader_GetMinX(const LASHeaderH hHeader) {
1470
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMinX", 0.0);
1472
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMinX();
1476
LAS_DLL double LASHeader_GetMinY(const LASHeaderH hHeader) {
1477
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMinY", 0.0);
1479
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMinY();
1483
LAS_DLL double LASHeader_GetMinZ(const LASHeaderH hHeader) {
1484
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMinZ", 0.0);
1486
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMinZ();
1490
LAS_DLL LASErrorEnum LASHeader_SetMin(LASHeaderH hHeader, double x, double y, double z) {
1491
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetMin", LE_Failure);
1494
((liblas::HeaderPtr*) hHeader)->get()->SetMin(x,y,z);
1495
} catch (std::exception const& e)
1497
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetMin");
1504
LAS_DLL double LASHeader_GetMaxX(const LASHeaderH hHeader) {
1505
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMaxX", 0.0);
1507
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMaxX();
1511
LAS_DLL double LASHeader_GetMaxY(const LASHeaderH hHeader) {
1512
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMaxY", 0.0);
1514
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMaxY();
1518
LAS_DLL double LASHeader_GetMaxZ(const LASHeaderH hHeader) {
1519
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetMaxZ", 0.0);
1521
double value = ((liblas::HeaderPtr*) hHeader)->get()->GetMaxZ();
1525
LAS_DLL LASErrorEnum LASHeader_SetMax(LASHeaderH hHeader, double x, double y, double z) {
1526
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetMax", LE_Failure);
1529
((liblas::HeaderPtr*) hHeader)->get()->SetMax(x,y,z);
1530
} catch (std::exception const& e)
1532
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetMax");
1539
LAS_DLL char* LASHeader_GetXML(const LASHeaderH hHeader)
1541
VALIDATE_LAS_POINTER1(hHeader, "LASHeader_GetXML", NULL);
1542
liblas::Header* h = (liblas::Header*)hHeader->get();
1544
std::ostringstream oss;
1546
liblas::property_tree::ptree tree= h->GetPTree();
1547
liblas::property_tree::write_xml(oss, tree);
1548
return LASCopyString(oss.str().c_str());
1553
LAS_DLL void LASHeader_Destroy(LASHeaderH hHeader)
1555
VALIDATE_LAS_POINTER0(hHeader, "LASHeader_Destroy");
1556
// delete ((liblas::Header*) hHeader);
1560
LAS_DLL LASHeaderH LASHeader_Copy(const LASHeaderH hHeader) {
1561
liblas::HeaderPtr* header = ((liblas::HeaderPtr*) hHeader);
1562
return (LASHeaderH) new liblas::HeaderPtr(new liblas::Header(*header->get()));
1565
LAS_DLL int LASHeader_Equal(const LASHeaderH hHeader1, const LASHeaderH hHeader2) {
1566
VALIDATE_LAS_POINTER1(hHeader1->get(), "LASHeader_Equal", 0);
1567
VALIDATE_LAS_POINTER1(hHeader2->get(), "LASHeader_Equal", 0);
1569
liblas::HeaderPtr* header1 = ((liblas::HeaderPtr*) hHeader1);
1570
liblas::HeaderPtr* header2 = ((liblas::HeaderPtr*) hHeader2);
1572
return (*header1->get() == *header2->get());
1575
LAS_DLL LASGuidH LASHeader_GetGUID(const LASHeaderH hHeader) {
1576
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetGUID", 0);
1578
liblas::guid id = ((liblas::HeaderPtr*) hHeader)->get()->GetProjectId();
1579
return (LASGuidH) new liblas::guid(id);
1583
LAS_DLL LASErrorEnum LASHeader_SetGUID(LASHeaderH hHeader, LASGuidH hId) {
1584
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetGUID", LE_Failure);
1587
liblas::guid* id = (liblas::guid*) hId;
1589
((liblas::HeaderPtr*) hHeader)->get()->SetProjectId(*id);
1590
} catch (std::exception const& e)
1592
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetGUID");
1599
LAS_DLL LASVLRH LASHeader_GetVLR(const LASHeaderH hHeader, boost::uint32_t i) {
1600
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetVLR", 0);
1602
liblas::VariableRecord vlr = ((liblas::HeaderPtr*) hHeader)->get()->GetVLR(i);
1603
return (LASVLRH) new liblas::VariableRecord(vlr);
1606
LAS_DLL LASErrorEnum LASHeader_DeleteVLR(LASHeaderH hHeader, boost::uint32_t index) {
1608
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_DeleteVLR", LE_Failure);
1611
((liblas::HeaderPtr*) hHeader)->get()->DeleteVLR(index);
1613
catch (std::exception const& e) {
1614
LASError_PushError(LE_Failure, e.what(), "LASHeader_DeleteVLR");
1622
LAS_DLL LASErrorEnum LASHeader_AddVLR(LASHeaderH hHeader, const LASVLRH hVLR) {
1624
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_AddVLR", LE_Failure);
1625
VALIDATE_LAS_POINTER1(hVLR, "LASHeader_AddVLR", LE_Failure);
1628
((liblas::HeaderPtr*) hHeader)->get()->AddVLR(*((liblas::VariableRecord*)hVLR));
1630
catch (std::exception const& e) {
1631
LASError_PushError(LE_Failure, e.what(), "LASHeader_AddVLR");
1642
LAS_DLL LASWriterH LASWriter_Create(const char* filename, const LASHeaderH hHeader, int mode) {
1643
VALIDATE_LAS_POINTER1(hHeader->get(), "LASWriter_Create", NULL);
1645
if (filename == NULL) {
1646
LASError_PushError(LE_Failure, "Input filename was null", "LASWriter_Create");
1649
std::ostream* ostrm = NULL;
1652
std::ios::openmode m;
1653
if ( (mode > 2) || (mode < 1)) {
1654
throw std::runtime_error("File mode must be eWrite or eAppend");
1661
m = std::ios::out | std::ios::in | std::ios::binary | std::ios::ate;
1665
m = std::ios::out | std::ios::binary | std::ios::ate;
1668
ostrm = liblas::Create(filename, m);
1672
} catch (std::exception const& e)
1676
LASError_PushError(LE_Failure, e.what(), "LASWriter_Create");
1683
liblas::HeaderPtr* header = ((liblas::HeaderPtr*) hHeader);
1684
liblas::Writer* writer = new liblas::Writer(*ostrm, *header->get());
1686
writers.insert(std::pair<liblas::Writer*, std::ostream*>(writer, ostrm));
1687
return (LASWriterH) writer;
1690
} catch (std::exception const& e)
1692
LASError_PushError(LE_Failure, e.what(), "LASWriter_Create");
1699
LAS_DLL LASErrorEnum LASWriter_WritePoint(const LASWriterH hWriter, const LASPointH hPoint) {
1701
VALIDATE_LAS_POINTER1(hPoint, "LASWriter_WritePoint", LE_Failure);
1705
ret = ((liblas::Writer*) hWriter)->WritePoint(*((liblas::Point*) hPoint));
1707
LASError_PushError( LE_Warning,
1708
"Failed to write point because it was invalid",
1709
"LASWriter_WritePoint");
1712
} catch (std::exception const& e)
1714
LASError_PushError(LE_Failure, e.what(), "LASWriter_WritePoint");
1721
LAS_DLL LASErrorEnum LASWriter_WriteHeader(const LASWriterH hWriter, const LASHeaderH hHeader) {
1723
VALIDATE_LAS_POINTER1(hHeader->get(), "LASWriter_WriteHeader", LE_Failure);
1724
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_WriteHeader", LE_Failure);
1727
((liblas::Writer*) hWriter)->SetHeader(*((liblas::HeaderPtr*) hHeader)->get());
1728
((liblas::Writer*) hWriter)->WriteHeader();
1729
} catch (std::exception const& e)
1731
LASError_PushError(LE_Failure, e.what(), "LASWriter_WriteHeader");
1738
LAS_DLL LASErrorEnum LASWriter_WriteOwnedHeader(const LASWriterH hWriter)
1740
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_WriteOwnedHeader", LE_Failure);
1743
((liblas::Writer*) hWriter)->WriteHeader();
1744
} catch (std::exception const& e)
1746
LASError_PushError(LE_Failure, e.what(), "LASWriter_WriteOwnedHeader");
1754
LAS_DLL void LASWriter_SetHeader( LASWriterH hWriter, const LASHeaderH hHeader)
1757
VALIDATE_LAS_POINTER0(hWriter, "LASWriter_SetHeader");
1758
VALIDATE_LAS_POINTER0(hHeader, "LASWriter_SetHeader");
1760
liblas::Writer* writer = (liblas::Writer*)hWriter;
1761
liblas::HeaderPtr* header = (liblas::HeaderPtr*)hHeader;
1763
writer->SetHeader(*header->get());
1766
LAS_DLL void LASWriter_Destroy(LASWriterH hWriter)
1768
VALIDATE_LAS_POINTER0(hWriter, "LASWriter_Destroy");
1771
liblas::Writer* writer = (liblas::Writer*)hWriter;
1773
std::map<liblas::Writer*, std::ostream*>::iterator it = writers.find(writer);
1774
if (it == writers.end())
1776
LASError_PushError(LE_Failure, "Unable to find writer stream", "LASWriter_Destroy");
1779
std::ostream* ostrm = it->second;
1784
if ( ostrm == NULL )
1786
LASError_PushError(LE_Failure, "Got 99 problems, but the stream ain't one", "LASWriter_Destroy");
1790
liblas::Cleanup(ostrm);
1792
writers.erase(writer);
1796
} catch (std::runtime_error const& e/* e */)
1798
LASError_PushError(LE_Failure, e.what(), "LASWriter_Destroy");
1804
LAS_DLL LASErrorEnum LASWriter_SetInputSRS(LASWriterH hWriter, const LASSRSH hSRS) {
1806
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_SetInputSRS", LE_Failure);
1807
VALIDATE_LAS_POINTER1(hSRS, "LASWriter_SetInputSRS", LE_Failure);
1810
liblas::Writer* writer = ((liblas::Writer*) hWriter);
1811
liblas::Header h = writer->GetHeader();
1812
liblas::SpatialReference* srs = ((liblas::SpatialReference*) hSRS);
1814
writer->SetHeader(h);
1816
catch (std::exception const& e) {
1817
LASError_PushError(LE_Failure, e.what(), "LASWriter_SetInputSRS");
1824
LAS_DLL LASErrorEnum LASWriter_SetOutputSRS(LASWriterH hWriter, const LASSRSH hSRS) {
1826
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_SetOutputSRS", LE_Failure);
1827
VALIDATE_LAS_POINTER1(hSRS, "LASWriter_SetOutputSRS", LE_Failure);
1830
liblas::Writer* writer = ((liblas::Writer*) hWriter);
1831
liblas::Header const& h = writer->GetHeader();
1832
liblas::SpatialReference in_ref = h.GetSRS();
1833
liblas::SpatialReference* out_ref = ((liblas::SpatialReference*) hSRS);
1834
std::vector<liblas::TransformPtr> transforms = writer->GetTransforms();
1836
transforms.erase( std::remove_if( transforms.begin(),
1838
boost::bind( &IsReprojectionTransform, _1 ) ),
1841
liblas::TransformPtr srs_transform = liblas::TransformPtr(new liblas::ReprojectionTransform(in_ref, *out_ref, &h));
1842
if (transforms.size())
1843
transforms.insert(transforms.begin(), srs_transform);
1845
transforms.push_back(srs_transform);
1846
writer->SetTransforms(transforms);
1848
catch (std::exception const& e) {
1849
LASError_PushError(LE_Failure, e.what(), "LASWriter_SetOutputSRS");
1856
LAS_DLL LASErrorEnum LASWriter_SetSRS(LASWriterH hWriter, const LASSRSH hSRS) {
1858
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_SetSRS", LE_Failure);
1859
VALIDATE_LAS_POINTER1(hSRS, "LASWriter_SetSRS", LE_Failure);
1861
return LASWriter_SetOutputSRS(hWriter, hSRS);
1864
LAS_DLL LASHeaderH LASWriter_GetHeader(const LASWriterH hWriter)
1866
VALIDATE_LAS_POINTER1(hWriter, "LASWriter_GetHeader", new liblas::HeaderPtr());
1868
liblas::Header header = ((liblas::Writer*) hWriter)->GetHeader();
1869
return (LASHeaderH) new liblas::HeaderPtr( new liblas::Header(header) );
1872
LAS_DLL void LASError_Print(const char* message) {
1875
char* errmethod = NULL;
1876
errmsg = LASError_GetLastErrorMsg();
1877
errmethod = LASError_GetLastErrorMethod();
1878
if (LASError_GetErrorCount()) {
1880
"%s: %s (%d) from method %s\n",
1883
LASError_GetLastErrorNum(),
1886
if (errmsg) free(errmsg);
1887
if (errmethod) free(errmethod);
1890
"You have encountered an error. '%s'\n",
1897
LAS_DLL char* LAS_GetVersion() {
1898
return LASCopyString(liblas::GetVersion().c_str());
1901
LAS_DLL char* LAS_GetFullVersion(void) {
1902
return LASCopyString(liblas::GetFullVersion().c_str());
1906
LAS_DLL LASVLRH LASVLR_Create(void) {
1907
return (LASVLRH) new liblas::VariableRecord();
1910
LAS_DLL void LASVLR_Destroy(LASVLRH hVLR){
1911
VALIDATE_LAS_POINTER0(hVLR, "LASVLR_Destroy");
1912
delete (liblas::VariableRecord*)hVLR;
1917
LAS_DLL char* LASVLR_GetUserId(const LASVLRH hVLR) {
1918
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetUserId", 0);
1919
liblas::VariableRecord* vlr = (liblas::VariableRecord*)hVLR;
1920
return LASCopyString(vlr->GetUserId(true).c_str());
1923
LAS_DLL LASErrorEnum LASVLR_SetUserId(LASVLRH hVLR, const char* value) {
1924
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetUserId", LE_Failure);
1927
((liblas::VariableRecord*) hVLR)->SetUserId(value);
1928
} catch (std::exception const& e)
1930
LASError_PushError(LE_Failure, e.what(), "LASVLR_SetUserId");
1937
LAS_DLL char* LASVLR_GetDescription(const LASVLRH hVLR) {
1938
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetDescription", 0);
1939
liblas::VariableRecord* vlr = (liblas::VariableRecord*)hVLR;
1940
return LASCopyString(vlr->GetDescription(true).c_str());
1943
LAS_DLL LASErrorEnum LASVLR_SetDescription(LASVLRH hVLR, const char* value) {
1944
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetDescription", LE_Failure);
1947
((liblas::VariableRecord*) hVLR)->SetDescription(value);
1948
} catch (std::exception const& e)
1950
LASError_PushError(LE_Failure, e.what(), "LASVLR_SetDescription");
1957
LAS_DLL boost::uint16_t LASVLR_GetRecordLength(const LASVLRH hVLR) {
1959
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetRecordLength", 0);
1961
boost::uint16_t value = ((liblas::VariableRecord*) hVLR)->GetRecordLength();
1964
LAS_DLL LASErrorEnum LASVLR_SetRecordLength(LASVLRH hVLR, boost::uint16_t value) {
1965
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetRecordLength", LE_Failure);
1966
((liblas::VariableRecord*) hVLR)->SetRecordLength(value);
1970
LAS_DLL boost::uint16_t LASVLR_GetRecordId(const LASVLRH hVLR) {
1972
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetRecordId", 0);
1974
boost::uint16_t value = ((liblas::VariableRecord*) hVLR)->GetRecordId();
1977
LAS_DLL LASErrorEnum LASVLR_SetRecordId(LASVLRH hVLR, boost::uint16_t value) {
1978
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetRecordId", LE_Failure);
1979
((liblas::VariableRecord*) hVLR)->SetRecordId(value);
1984
LAS_DLL LASErrorEnum LASVLR_SetReserved(LASVLRH hVLR, boost::uint16_t value) {
1985
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetReserved", LE_Failure);
1986
((liblas::VariableRecord*) hVLR)->SetReserved(value);
1990
LAS_DLL boost::uint16_t LASVLR_GetReserved(const LASVLRH hVLR) {
1992
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetReserved", 0);
1994
boost::uint16_t value = ((liblas::VariableRecord*) hVLR)->GetReserved();
1998
LAS_DLL LASErrorEnum LASVLR_GetData(const LASVLRH hVLR, boost::uint8_t* data) {
2000
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_GetData", LE_Failure);
2003
liblas::VariableRecord* vlr = ((liblas::VariableRecord*) hVLR);
2004
std::vector<boost::uint8_t> const& d = vlr->GetData();
2005
boost::uint16_t length = vlr->GetRecordLength();
2006
for (boost::uint16_t i=0; i < length; i++) {
2010
catch (std::exception const& e) {
2011
LASError_PushError(LE_Failure, e.what(), "LASVLR_GetData");
2019
LAS_DLL LASErrorEnum LASVLR_SetData(const LASVLRH hVLR, boost::uint8_t* data, boost::uint16_t length) {
2021
VALIDATE_LAS_POINTER1(hVLR, "LASVLR_SetData", LE_Failure);
2024
liblas::VariableRecord* vlr = ((liblas::VariableRecord*) hVLR);
2025
std::vector<boost::uint8_t> d;
2027
for (boost::uint16_t i=0; i < length; i++) {
2032
catch (std::exception const& e) {
2033
LASError_PushError(LE_Failure, e.what(), "LASVLR_GetData");
2041
LAS_DLL LASGuidH LASGuid_Create() {
2042
liblas::guid random;
2044
random = liblas::guid::create();
2045
return (LASGuidH) new liblas::guid(random);
2047
catch (std::exception const& e) {
2048
LASError_PushError(LE_Failure, e.what(), "LASGuid_Create");
2053
LAS_DLL LASGuidH LASGuid_CreateFromString(const char* string) {
2054
VALIDATE_LAS_POINTER1(string, "LASGuid_CreateFromString", NULL);
2057
id = liblas::guid(string);
2058
return (LASGuidH) new liblas::guid(id);
2060
catch (std::exception const& e) {
2061
LASError_PushError(LE_Failure, e.what(), "LASGuid_CreateFromString");
2066
LAS_DLL void LASGuid_Destroy(LASGuidH hId) {
2067
VALIDATE_LAS_POINTER0(hId, "LASGuid_Destroy");
2068
delete (liblas::guid*) hId;
2072
LAS_DLL int LASGuid_Equals(LASGuidH hId1, LASGuidH hId2) {
2073
VALIDATE_LAS_POINTER1(hId1, "LASGuid_Equals", LE_Failure);
2074
VALIDATE_LAS_POINTER1(hId2, "LASGuid_Equals", LE_Failure);
2076
liblas::guid* id1 = (liblas::guid*)hId1;
2077
liblas::guid* id2 = (liblas::guid*)hId2;
2080
return( *id1 == *id2);
2082
catch (std::exception const& e) {
2083
LASError_PushError(LE_Failure, e.what(), "LASGuid_Equals");
2088
LAS_DLL char* LASGuid_AsString(LASGuidH hId) {
2089
VALIDATE_LAS_POINTER1(hId, "LASGuid_AsString", 0);
2090
liblas::guid* id= (liblas::guid*)hId;
2091
return LASCopyString(id->to_string().c_str());
2096
LAS_DLL LASColorH LASColor_Create(void) {
2097
return (LASColorH) new liblas::Color();
2100
LAS_DLL void LASColor_Destroy(LASColorH hColor){
2101
VALIDATE_LAS_POINTER0(hColor, "LASColor_Destroy");
2102
delete (liblas::Color*)hColor;
2106
LAS_DLL LASErrorEnum LASColor_SetRed(LASColorH hColor, boost::uint16_t value) {
2108
VALIDATE_LAS_POINTER1(hColor, "LASColor_SetRed", LE_Failure);
2111
liblas::Color* color = ((liblas::Color*) hColor);
2112
color->SetRed(value);
2114
catch (std::exception const& e) {
2115
LASError_PushError(LE_Failure, e.what(), "LASColor_SetRed");
2122
LAS_DLL boost::uint16_t LASColor_GetRed(LASColorH hColor) {
2124
VALIDATE_LAS_POINTER1(hColor, "LASColor_GetRed", 0);
2126
boost::uint16_t value = ((liblas::Color*) hColor)->GetRed();
2130
LAS_DLL LASErrorEnum LASColor_SetBlue(LASColorH hColor, boost::uint16_t value) {
2132
VALIDATE_LAS_POINTER1(hColor, "LASColor_SetBlue", LE_Failure);
2135
liblas::Color* color = ((liblas::Color*) hColor);
2136
color->SetBlue(value);
2138
catch (std::exception const& e) {
2139
LASError_PushError(LE_Failure, e.what(), "LASColor_SetBlue");
2146
LAS_DLL boost::uint16_t LASColor_GetBlue(LASColorH hColor) {
2148
VALIDATE_LAS_POINTER1(hColor, "LASColor_GetBlue", 0);
2150
boost::uint16_t value = ((liblas::Color*) hColor)->GetBlue();
2154
LAS_DLL LASErrorEnum LASColor_SetGreen(LASColorH hColor, boost::uint16_t value) {
2156
VALIDATE_LAS_POINTER1(hColor, "LASColor_SetGreen", LE_Failure);
2159
liblas::Color* color = ((liblas::Color*) hColor);
2160
color->SetGreen(value);
2162
catch (std::exception const& e) {
2163
LASError_PushError(LE_Failure, e.what(), "LASColor_SetGreen");
2170
LAS_DLL boost::uint16_t LASColor_GetGreen(LASColorH hColor) {
2172
VALIDATE_LAS_POINTER1(hColor, "LASColor_GetGreen", 0);
2174
boost::uint16_t value = ((liblas::Color*) hColor)->GetGreen();
2178
LAS_DLL LASColorH LASPoint_GetColor(const LASPointH hPoint) {
2179
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_GetColor", 0);
2181
liblas::Color color;
2183
color = ((liblas::Point*) hPoint)->GetColor();
2185
} catch (std::runtime_error const&)
2189
return (LASColorH) new liblas::Color(color);
2192
LAS_DLL LASErrorEnum LASPoint_SetColor(LASPointH hPoint, const LASColorH hColor) {
2194
VALIDATE_LAS_POINTER1(hPoint, "LASPoint_SetColor", LE_Failure);
2195
VALIDATE_LAS_POINTER1(hColor, "LASPoint_SetColor", LE_Failure);
2198
((liblas::Point*) hPoint)->SetColor(*((liblas::Color*)hColor));
2200
catch (std::runtime_error const&)
2202
// drop the value on the floor. If the point has a schema that
2203
// doesn't have color, the user needs to change the point's header.
2206
catch (std::exception const& e) {
2207
LASError_PushError(LE_Failure, e.what(), "LASPoint_SetColor");
2214
LAS_DLL LASSRSH LASSRS_Create(void) {
2215
return (LASSRSH) new liblas::SpatialReference();
2218
LAS_DLL void LASSRS_Destroy(LASSRSH hSRS){
2219
VALIDATE_LAS_POINTER0(hSRS, "LASSRS_Destroy");
2220
delete (liblas::SpatialReference*)hSRS;
2224
LAS_DLL const void* LASSRS_GetGTIF(LASSRSH hSRS) {
2225
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetGTIF", 0);
2228
return (const void *) ((liblas::SpatialReference*) hSRS)->GetGTIF();
2230
catch (std::exception const& e) {
2231
LASError_PushError(LE_Failure, e.what(), "LASSRS_GetGTIF");
2236
LAS_DLL LASErrorEnum LASSRS_SetGTIF(LASSRSH hSRS, const void* pgtiff, const void* ptiff)
2238
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_SetGTIF", LE_Failure);
2239
VALIDATE_LAS_POINTER1(pgtiff, "LASSRS_SetGTIF", LE_Failure);
2240
VALIDATE_LAS_POINTER1(ptiff, "LASSRS_SetGTIF", LE_Failure);
2242
const GTIF* cgtiff = static_cast<const GTIF*>(pgtiff);
2243
const ST_TIFF* ctiff = static_cast<const ST_TIFF*>(ptiff);
2244
GTIF* gtiff = const_cast<GTIF*>(cgtiff);
2245
ST_TIFF* tiff = const_cast<ST_TIFF*>(ctiff);
2247
((liblas::SpatialReference*) hSRS)->SetGTIF(gtiff, tiff);
2249
catch (std::exception const& e) {
2250
LASError_PushError(LE_Failure, e.what(), "LASSRS_SetGTIF");
2256
LAS_DLL char* LASSRS_GetProj4(LASSRSH hSRS)
2258
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetProj4", NULL);
2259
liblas::SpatialReference* srs = (liblas::SpatialReference*)hSRS;
2261
return LASCopyString((srs)->GetProj4().c_str());
2265
LAS_DLL LASErrorEnum LASSRS_SetProj4(LASSRSH hSRS, const char* value)
2267
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_SetProj4", LE_Failure);
2268
VALIDATE_LAS_POINTER1(value, "LASSRS_SetProj4", LE_Failure);
2271
((liblas::SpatialReference*) hSRS)->SetProj4(value);
2273
catch (std::exception const& e) {
2274
LASError_PushError(LE_Failure, e.what(), "LASSRS_SetProj4");
2281
LAS_DLL char* LASSRS_GetWKT(LASSRSH hSRS)
2283
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetWKT", NULL);
2284
liblas::SpatialReference* srs = (liblas::SpatialReference*)hSRS;
2286
return LASCopyString((srs)->GetWKT(liblas::SpatialReference::eHorizontalOnly).c_str());
2290
LAS_DLL char* LASSRS_GetWKT_CompoundOK(LASSRSH hSRS)
2292
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetWKT_CompoundOK", NULL);
2293
liblas::SpatialReference* srs = (liblas::SpatialReference*)hSRS;
2295
return LASCopyString((srs)->GetWKT(liblas::SpatialReference::eCompoundOK).c_str());
2299
LAS_DLL LASErrorEnum LASSRS_SetWKT(LASSRSH hSRS, const char* value)
2301
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_SetWKT", LE_Failure);
2302
VALIDATE_LAS_POINTER1(value, "LASSRS_SetWKT", LE_Failure);
2305
((liblas::SpatialReference*) hSRS)->SetWKT(value);
2307
catch (std::exception const& e) {
2308
LASError_PushError(LE_Failure, e.what(), "LASSRS_SetWKT");
2315
LAS_DLL LASErrorEnum LASSRS_SetVerticalCS(LASSRSH hSRS,
2317
const char *citation,
2319
int verticalUnits ) {
2321
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_SetVerticalCS", LE_Failure);
2324
((liblas::SpatialReference*) hSRS)->SetVerticalCS( verticalCSType, citation,
2328
catch (std::exception const& e) {
2329
LASError_PushError(LE_Failure, e.what(), "LASSRS_SetVerticalCS");
2336
LAS_DLL LASErrorEnum LASSRS_SetFromUserInput(LASSRSH hSRS, const char* value)
2338
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_SetFromUserInput", LE_Failure);
2339
VALIDATE_LAS_POINTER1(value, "LASSRS_SetFromUserInput", LE_Failure);
2342
((liblas::SpatialReference*) hSRS)->SetFromUserInput(value);
2344
catch (std::exception const& e) {
2345
LASError_PushError(LE_Failure, e.what(), "LASSRS_SetFromUserInput");
2352
LAS_DLL LASErrorEnum LASSRS_AddVLR(LASSRSH hSRS, const LASVLRH hVLR) {
2354
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_AddVLR", LE_Failure);
2355
VALIDATE_LAS_POINTER1(hVLR, "LASSRS_AddVLR", LE_Failure);
2358
((liblas::SpatialReference*) hSRS)->AddVLR(*((liblas::VariableRecord*)hVLR));
2360
catch (std::exception const& e) {
2361
LASError_PushError(LE_Failure, e.what(), "LASSRS_AddVLR");
2368
LAS_DLL LASVLRH LASSRS_GetVLR(const LASSRSH hSRS, boost::uint32_t i) {
2369
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetVLR", 0);
2371
liblas::VariableRecord vlr = ((liblas::SpatialReference*) hSRS)->GetVLRs()[i];
2372
return (LASVLRH) new liblas::VariableRecord(vlr);
2375
LAS_DLL boost::uint32_t LASSRS_GetVLRCount(const LASSRSH hSRS) {
2376
VALIDATE_LAS_POINTER1(hSRS, "LASSRS_GetVLR", 0);
2378
using boost::uint32_t;
2379
uint32_t size = static_cast<uint32_t>(((liblas::SpatialReference*) hSRS)->GetVLRs().size());
2383
LAS_DLL LASErrorEnum LASHeader_SetSRS(LASHeaderH hHeader, const LASSRSH hSRS) {
2385
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetSRS", LE_Failure);
2386
VALIDATE_LAS_POINTER1(hSRS, "LASHeader_SetSRS", LE_Failure);
2389
((liblas::HeaderPtr*) hHeader)->get()->SetSRS(*((liblas::SpatialReference*)hSRS));
2391
catch (std::exception const& e) {
2392
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSRS");
2400
LAS_DLL LASSRSH LASHeader_GetSRS(const LASHeaderH hHeader) {
2401
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSRS", 0);
2403
liblas::SpatialReference srs = ((liblas::HeaderPtr*) hHeader)->get()->GetSRS();
2404
return (LASSRSH) new liblas::SpatialReference(srs);
2408
LAS_DLL void LASString_Free(char* string) {
2414
LAS_DLL LASSchemaH LASSchema_Create( liblas::PointFormatName point_format) {
2415
liblas::Schema* schema = new liblas::Schema(point_format);
2416
return (LASSchemaH) schema;
2420
LAS_DLL unsigned int LASSchema_GetByteSize( LASSchemaH hFormat)
2422
VALIDATE_LAS_POINTER1(hFormat, "LASSchema_GetByteSize", 0);
2424
liblas::Schema* format = ((liblas::Schema*) hFormat);
2425
return static_cast<unsigned int>(format->GetByteSize());
2429
LAS_DLL unsigned int LASSchema_GetBaseByteSize( LASSchemaH hFormat)
2431
VALIDATE_LAS_POINTER1(hFormat, "LASSchema_GetBaseByteSize", 0);
2433
liblas::Schema* format = ((liblas::Schema*) hFormat);
2434
return static_cast<unsigned int>(format->GetBaseByteSize());
2438
LAS_DLL void LASSchema_Destroy(LASSchemaH hFormat) {
2439
VALIDATE_LAS_POINTER0(hFormat, "LASSchema_Destroy");
2440
delete (liblas::Schema*) hFormat;
2444
LAS_DLL LASSchemaH LASHeader_GetSchema( LASHeaderH hHeader )
2446
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_GetSchema", 0);
2448
liblas::Schema format = ((liblas::HeaderPtr*) hHeader)->get()->GetSchema();
2449
return (LASSchemaH) new liblas::Schema(format);
2453
LAS_DLL LASErrorEnum LASHeader_SetSchema( LASHeaderH hHeader, const LASSchemaH hFormat)
2455
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetSchema", LE_Failure);
2456
VALIDATE_LAS_POINTER1(hFormat, "LASHeader_SetSchema", LE_Failure);
2459
((liblas::HeaderPtr*) hHeader)->get()->SetSchema(*((liblas::Schema*)hFormat));
2461
catch (std::exception const& e) {
2462
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSchema");
2469
LAS_DLL int LASHeader_Compressed(const LASHeaderH hHeader )
2471
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_Compressed", 0);
2472
return ((liblas::HeaderPtr*) hHeader)->get()->Compressed();
2475
LAS_DLL LASErrorEnum LASHeader_SetCompressed( LASHeaderH hHeader, int value)
2477
VALIDATE_LAS_POINTER1(hHeader->get(), "LASHeader_SetCompressed", LE_Failure);
2481
if (value == 0) v = false;
2483
((liblas::HeaderPtr*) hHeader)->get()->SetCompressed(v);
2485
catch (std::exception const& e) {
2486
LASError_PushError(LE_Failure, e.what(), "LASHeader_SetCompressed");
2497
# pragma warning(default: 4127) // enable warning C4127: conditional expression is constant
2498
# pragma warning(default: 4702) // unreachable code