Skip to content

Commit

Permalink
able to build without zstd and lazperf
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik authored and nyalldawson committed Oct 26, 2020
1 parent 8536c56 commit bb5b625
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Expand Up @@ -351,7 +351,13 @@ IF(WITH_CORE)
MESSAGE(STATUS "Found zlib: ${ZLIB_LIBRARIES}")

FIND_PACKAGE(ZSTD REQUIRED) # for decompression of point clouds
IF (ZSTD_FOUND)
SET(HAVE_ZSTD TRUE) # used in qgsconfig.h
ENDIF (ZSTD_FOUND)
FIND_PACKAGE(LazPerf REQUIRED) # for decompression of point clouds
IF (LazPerf_FOUND)
SET(HAVE_LAZPERF TRUE) # used in qgsconfig.h
ENDIF (LazPerf_FOUND)

# optional
IF (WITH_POSTGRESQL)
Expand Down Expand Up @@ -380,6 +386,7 @@ IF(WITH_CORE)
ELSE (WITH_QTWEBKIT)
MESSAGE(STATUS "Qt WebKit support DISABLED.")
ENDIF(WITH_QTWEBKIT)

#############################################################
# search for Qt5
SET(QT_MIN_VERSION 5.9.0)
Expand Down
4 changes: 4 additions & 0 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -76,5 +76,9 @@

#cmakedefine HAVE_STATIC_PROVIDERS

#cmakedefine HAVE_ZSTD

#cmakedefine HAVE_LAZPERF

#endif

30 changes: 28 additions & 2 deletions src/core/providers/ept/qgseptdecoder.cpp
Expand Up @@ -18,13 +18,19 @@
#include "qgseptdecoder.h"
#include "qgseptpointcloudindex.h"
#include "qgsvector3d.h"
#include "qgsconfig.h"

#include <zstd.h>
#include <QFile>
#include <iostream>

#if defined ( HAVE_ZSTD )
#include <zstd.h>
#endif

#if defined ( HAVE_LAZPERF )
#include "laz-perf/io.hpp"
#include "laz-perf/common/common.hpp"
#endif

///@cond PRIVATE

Expand Down Expand Up @@ -60,7 +66,7 @@ QVector<char> QgsEptDecoder::decompressBinaryClasses( const QString &filename, i
Q_ASSERT( r );

int count = f.size() / pointRecordSize;
QVector<char> classes(count);
QVector<char> classes( count );
for ( int i = 0; i < count; ++i )
{
QByteArray bytes = f.read( pointRecordSize );
Expand All @@ -78,6 +84,8 @@ QVector<char> QgsEptDecoder::decompressBinaryClasses( const QString &filename, i

/* *************************************************************************************** */

#if defined(HAVE_ZSTD)

QByteArray decompressZtdStream( const QByteArray &dataCompressed )
{
// NOTE: this is very primitive implementation because we expect the uncompressed
Expand Down Expand Up @@ -135,8 +143,18 @@ QVector<qint32> QgsEptDecoder::decompressZStandard( const QString &filename, int
return data;
}

#else // defined(HAVE_ZSTD)
QVector<qint32> QgsEptDecoder::decompressZStandard( const QString &filename, int pointRecordSize )
{
//TODO graceful error
Q_ASSERT( false );
}

#endif // defined(HAVE_ZSTD)

/* *************************************************************************************** */

#if defined ( HAVE_LAZPERF )
QVector<qint32> QgsEptDecoder::decompressLaz( const QString &filename )
{
std::ifstream file( filename.toLatin1().constData(), std::ios::binary );
Expand Down Expand Up @@ -165,4 +183,12 @@ QVector<qint32> QgsEptDecoder::decompressLaz( const QString &filename )
return data;
}

#else // defined ( HAVE_LAZPERF )
QVector<qint32> QgsEptDecoder::decompressLaz( const QString &filename )
{
//TODO graceful return and error message
Q_ASSERT( false );
}
#endif

///@endcond

0 comments on commit bb5b625

Please sign in to comment.