Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch from silently building broken Entwine point cloud support
when dependancies are missing (libzstd, lazperf) to an explicit
WITH_EPT optional cmake switch which requires those dependancies

This makes it easier people to determine whether they have the
complete set of necessary dependancies to build Entwine point
cloud support, as cmake will show an error if they enable WITH_EPT
but don't have them...
  • Loading branch information
nyalldawson committed Nov 6, 2020
1 parent 610703c commit f5a4880
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 78 deletions.
23 changes: 11 additions & 12 deletions CMakeLists.txt
Expand Up @@ -242,6 +242,11 @@ IF(WITH_CORE)
SET(HAVE_PDAL TRUE)
ENDIF(WITH_PDAL)

SET (WITH_EPT FALSE CACHE BOOL "Determines whether Entwine Point Cloud (EPT) support should be built")
IF(WITH_EPT)
SET(HAVE_EPT TRUE)
ENDIF(WITH_EPT)

#BUILD WITH QtMobility by default on android only. Other platform can force it
IF (ANDROID)
SET (DEFAULT_WITH_QTMOBILITY TRUE)
Expand Down Expand Up @@ -355,18 +360,6 @@ IF(WITH_CORE)
FIND_PACKAGE(ZLIB REQUIRED) # for decompression of vector tiles in MBTiles file
MESSAGE(STATUS "Found zlib: ${ZLIB_LIBRARIES}")

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

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

# optional
IF (WITH_POSTGRESQL)
FIND_PACKAGE(Postgres) # PostgreSQL provider
Expand Down Expand Up @@ -395,6 +388,12 @@ IF(WITH_CORE)
MESSAGE(STATUS "Qt WebKit support DISABLED.")
ENDIF(WITH_QTWEBKIT)

IF (WITH_EPT) # EPT provider
FIND_PACKAGE(ZSTD) # for decompression of point clouds
FIND_PACKAGE(LazPerf) # for decompression of point clouds
SET(HAVE_EPT TRUE) # used in qgsconfig.h
ENDIF (WITH_EPT)

IF (WITH_PDAL)
FIND_PACKAGE(PDAL) # PDAL provider
ENDIF (WITH_PDAL)
Expand Down
3 changes: 1 addition & 2 deletions cmake/FindLazPerf.cmake
Expand Up @@ -26,6 +26,5 @@ MARK_AS_ADVANCED(LazPerf_INCLUDE_DIR)
IF (LazPerf_FOUND)
MESSAGE(STATUS "Found laz-perf: ${LazPerf_INCLUDE_DIR}")
ELSE (LazPerf_FOUND)
# optional dependency only
MESSAGE(STATUS "Could not find laz-perf")
MESSAGE(FATAL_ERROR "Could not find laz-perf")
ENDIF (LazPerf_FOUND)
2 changes: 1 addition & 1 deletion cmake/FindZSTD.cmake
Expand Up @@ -30,5 +30,5 @@ MARK_AS_ADVANCED(ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
IF (ZSTD_FOUND)
MESSAGE(STATUS "Found ZSTD: ${ZSTD_LIBRARY}")
ELSE (ZSTD_FOUND)
MESSAGE(STATUS "Could not find ZSTD")
MESSAGE(FATAL_ERROR "Could not find ZSTD")
ENDIF (ZSTD_FOUND)
4 changes: 1 addition & 3 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -76,9 +76,7 @@

#cmakedefine HAVE_STATIC_PROVIDERS

#cmakedefine HAVE_ZSTD

#cmakedefine HAVE_LAZPERF
#cmakedefine HAVE_EPT

#cmakedefine HAVE_PDAL
#define PDAL_VERSION "${PDAL_VERSION}"
Expand Down
47 changes: 23 additions & 24 deletions src/core/CMakeLists.txt
Expand Up @@ -204,11 +204,6 @@ SET(QGIS_CORE_SRCS
providers/ogr/qgsogrdbconnection.cpp
providers/ogr/qgsogrtransaction.cpp

providers/ept/qgseptdataitems.cpp
providers/ept/qgseptprovider.cpp
providers/ept/qgseptdecoder.cpp
providers/ept/qgseptpointcloudindex.cpp

scalebar/qgsdoubleboxscalebarrenderer.cpp
scalebar/qgshollowscalebarrenderer.cpp
scalebar/qgsnumericscalebarrenderer.cpp
Expand Down Expand Up @@ -1384,10 +1379,6 @@ SET(QGIS_CORE_HDRS
providers/ogr/qgsogrdbconnection.h
providers/ogr/qgsogrprovider.h
providers/ogr/qgsogrtransaction.h
providers/ept/qgseptdataitems.h
providers/ept/qgseptprovider.h
providers/ept/qgseptdecoder.h
providers/ept/qgseptpointcloudindex.h

raster/qgsbilinearrasterresampler.h
raster/qgsbrightnesscontrastfilter.h
Expand Down Expand Up @@ -1612,7 +1603,6 @@ INCLUDE_DIRECTORIES(
providers/gdal
providers/ogr
providers/meshmemory
providers/ept
raster
renderer
scalebar
Expand Down Expand Up @@ -1645,18 +1635,6 @@ INCLUDE_DIRECTORIES(SYSTEM
${ZLIB_INCLUDE_DIRS}
)

IF (HAVE_ZSTD)
INCLUDE_DIRECTORIES(SYSTEM
${ZSTD_INCLUDE_DIR}
)
ENDIF (HAVE_ZSTD)

IF (HAVE_LAZPERF)
INCLUDE_DIRECTORIES(SYSTEM
${LazPerf_INCLUDE_DIR}
)
ENDIF (HAVE_LAZPERF)

IF (HAVE_PDAL)
INCLUDE_DIRECTORIES(SYSTEM
${PDAL_INCLUDE_DIR}
Expand All @@ -1673,6 +1651,27 @@ IF (HAVE_OPENCL)
INCLUDE_DIRECTORIES(SYSTEM ${OpenCL_INCLUDE_DIRS})
ENDIF (HAVE_OPENCL)

IF (WITH_EPT)
INCLUDE_DIRECTORIES(providers/ept)

INCLUDE_DIRECTORIES(SYSTEM
${ZSTD_INCLUDE_DIR}
${LazPerf_INCLUDE_DIR}
)

SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
providers/ept/qgseptdataitems.cpp
providers/ept/qgseptprovider.cpp
providers/ept/qgseptdecoder.cpp
providers/ept/qgseptpointcloudindex.cpp
)
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
providers/ept/qgseptdataitems.h
providers/ept/qgseptprovider.h
providers/ept/qgseptdecoder.h
providers/ept/qgseptpointcloudindex.h
)
ENDIF (WITH_EPT)

IF (APPLE)
# Libtasn1 is for DER-encoded PKI ASN.1 parsing/extracting workarounds
Expand Down Expand Up @@ -1800,11 +1799,11 @@ TARGET_LINK_LIBRARIES(qgis_core
${ZLIB_LIBRARIES}
)

IF (HAVE_ZSTD)
IF (WITH_EPT)
TARGET_LINK_LIBRARIES(qgis_core
${ZSTD_LIBRARY}
)
ENDIF (HAVE_ZSTD)
ENDIF (WITH_EPT)

IF (HAVE_PDAL)
TARGET_LINK_LIBRARIES(qgis_core
Expand Down
31 changes: 2 additions & 29 deletions src/core/providers/ept/qgseptdecoder.cpp
Expand Up @@ -20,20 +20,17 @@
#include "qgspointcloudattribute.h"
#include "qgsvector3d.h"
#include "qgsconfig.h"
#include "qgslogger.h"

#include <QFile>
#include <iostream>
#include <memory>
#include <cstring>

#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 @@ -201,8 +198,6 @@ QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QString &filename, co

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

#if defined(HAVE_ZSTD)

QByteArray decompressZtdStream( const QByteArray &dataCompressed )
{
// NOTE: this is very primitive implementation because we expect the uncompressed
Expand Down Expand Up @@ -246,20 +241,8 @@ QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QString &filename,
return _decompressBinary( dataUncompressed, attributes, requestedAttributes );
}

#else // defined(HAVE_ZSTD)
QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
{
Q_UNUSED( filename )
Q_UNUSED( attributes )
Q_UNUSED( requestedAttributes )
return nullptr;
}

#endif // defined(HAVE_ZSTD)

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

#if defined ( HAVE_LAZPERF )
QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
const QgsPointCloudAttributeCollection &attributes,
const QgsPointCloudAttributeCollection &requestedAttributes )
Expand Down Expand Up @@ -311,22 +294,12 @@ QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
}
}
float t = common::since( start );
std::cout << "LAZ-PERF Read through the points in " << t << " seconds." << std::endl;
QgsDebugMsgLevel( QStringLiteral( "LAZ-PERF Read through the points in %1 seconds." ).arg( t ), 2 );
return new QgsPointCloudBlock(
count,
requestedAttributes,
data
);
}

#else // defined ( HAVE_LAZPERF )
QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
{
Q_UNUSED( filename )
Q_UNUSED( attributes )
Q_UNUSED( requestedAttributes )
return nullptr;
}
#endif

///@endcond
6 changes: 6 additions & 0 deletions src/core/qgsproviderregistry.cpp
Expand Up @@ -36,7 +36,11 @@
#include "providers/gdal/qgsgdalprovider.h"
#include "providers/ogr/qgsogrprovider.h"
#include "providers/meshmemory/qgsmeshmemorydataprovider.h"

#ifdef HAVE_EPT
#include "providers/ept/qgseptprovider.h"
#endif

#include "qgsruntimeprofiler.h"
#include "qgsfileutils.h"

Expand Down Expand Up @@ -139,11 +143,13 @@ void QgsProviderRegistry::init()
QgsProviderMetadata *vt = new QgsVectorTileProviderMetadata();
mProviders[ vt->key() ] = vt;
}
#ifdef HAVE_EPT
{
QgsScopedRuntimeProfile profile( QObject::tr( "Create EPT point cloud provider" ) );
QgsProviderMetadata *pc = new QgsEptProviderMetadata();
mProviders[ pc->key() ] = pc;
}
#endif
#ifdef HAVE_STATIC_PROVIDERS
mProviders[ QgsWmsProvider::providerKey() ] = new QgsWmsProviderMetadata();
mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
Expand Down
14 changes: 11 additions & 3 deletions src/gui/CMakeLists.txt
Expand Up @@ -349,7 +349,6 @@ SET(QGIS_GUI_SRCS

providers/ept/qgspointcloudsourceselect.cpp
providers/ept/qgseptproviderguimetadata.cpp
providers/ept/qgseptdataitemguiprovider.cpp

tableeditor/qgstableeditordialog.cpp
tableeditor/qgstableeditorformattingwidget.cpp
Expand Down Expand Up @@ -1110,7 +1109,6 @@ SET(QGIS_GUI_HDRS

providers/ept/qgspointcloudsourceselect.h
providers/ept/qgseptproviderguimetadata.h
providers/ept/qgseptdataitemguiprovider.h

raster/qgscolorrampshaderwidget.h
raster/qgshillshaderendererwidget.h
Expand Down Expand Up @@ -1308,9 +1306,9 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui/ogr
${CMAKE_SOURCE_DIR}/src/gui/processing
${CMAKE_SOURCE_DIR}/src/gui/processing/models
${CMAKE_SOURCE_DIR}/src/gui/providers/ept
${CMAKE_SOURCE_DIR}/src/gui/providers/gdal
${CMAKE_SOURCE_DIR}/src/gui/providers/ogr
${CMAKE_SOURCE_DIR}/src/gui/providers/ept
${CMAKE_SOURCE_DIR}/src/gui/pointcloud
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/gui/vector
Expand Down Expand Up @@ -1371,6 +1369,16 @@ INCLUDE_DIRECTORIES(SYSTEM
${Protobuf_INCLUDE_DIRS}
)

IF (WITH_EPT)
SET(QGIS_GUI_SRCS ${QGIS_GUI_SRCS}
providers/ept/qgseptdataitemguiprovider.cpp
)
SET(QGIS_GUI_HDRS ${QGIS_GUI_HDRS}
providers/ept/qgseptdataitemguiprovider.h
)
ENDIF (WITH_EPT)


# disable deprecation warnings for classes re-exporting deprecated methods
IF(MSVC)
SET_SOURCE_FILES_PROPERTIES(
Expand Down
6 changes: 6 additions & 0 deletions src/gui/providers/ept/qgseptproviderguimetadata.cpp
Expand Up @@ -18,8 +18,12 @@
#include "qgsapplication.h"
#include "qgssourceselectprovider.h"
#include "qgspointcloudsourceselect.h"

#include "qgseptproviderguimetadata.h"

#ifdef HAVE_EPT
#include "qgseptdataitemguiprovider.h"
#endif

///@cond PRIVATE

Expand All @@ -42,11 +46,13 @@ QgsEptProviderGuiMetadata::QgsEptProviderGuiMetadata()
{
}

#ifdef HAVE_EPT
QList<QgsDataItemGuiProvider *> QgsEptProviderGuiMetadata::dataItemGuiProviders()
{
return QList<QgsDataItemGuiProvider *>()
<< new QgsEptDataItemGuiProvider;
}
#endif

QList<QgsSourceSelectProvider *> QgsEptProviderGuiMetadata::sourceSelectProviders()
{
Expand Down
5 changes: 5 additions & 0 deletions src/gui/providers/ept/qgseptproviderguimetadata.h
Expand Up @@ -31,7 +31,12 @@ class QgsEptProviderGuiMetadata: public QgsProviderGuiMetadata
public:
QgsEptProviderGuiMetadata();

#ifdef HAVE_EPT
QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override;
#endif

// for now we always include the "ept" provider source select provider, as it actually
// forms the generic point cloud source select widget
QList<QgsSourceSelectProvider *> sourceSelectProviders() override;
};

Expand Down
13 changes: 10 additions & 3 deletions tests/src/providers/CMakeLists.txt
Expand Up @@ -14,7 +14,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/pal
${CMAKE_SOURCE_DIR}/src/core/pointcloud
${CMAKE_SOURCE_DIR}/src/core/providers/ept
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/symbology
${CMAKE_SOURCE_DIR}/src/core/effects
Expand All @@ -24,7 +23,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/providers/arcgisrest
${CMAKE_SOURCE_DIR}/src/providers/mdal
${CMAKE_SOURCE_DIR}/src/providers/ogr
${CMAKE_SOURCE_DIR}/src/providers/ept
${CMAKE_SOURCE_DIR}/src/test
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/external/nlohmann
Expand Down Expand Up @@ -106,11 +104,20 @@ ADD_QGIS_TEST(postgresconntest testqgspostgresconn.cpp)
TARGET_LINK_LIBRARIES(qgis_postgresconntest postgresprovider_a qgis_core)

IF (NOT FORCE_STATIC_PROVIDERS)
ADD_QGIS_TEST(eptprovidertest testqgseptprovider.cpp)
ADD_QGIS_TEST(mdalprovidertest testqgsmdalprovider.cpp)
ENDIF (NOT FORCE_STATIC_PROVIDERS)

IF (WITH_EPT)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core/providers/ept
)
ADD_QGIS_TEST(eptprovidertest testqgseptprovider.cpp)
ENDIF(WITH_EPT)

IF (WITH_PDAL)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/providers/pdal
)
ADD_QGIS_TEST(pdalprovidertest testqgspdalprovider.cpp)
TARGET_LINK_LIBRARIES(qgis_pdalprovidertest pdalprovider_a qgis_core)
ENDIF(WITH_PDAL)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/providers/testqgspdalprovider.cpp
Expand Up @@ -27,7 +27,7 @@
#include "qgis.h"
#include "qgsapplication.h"
#include "qgsproviderregistry.h"
#include "qgseptprovider.h"
#include "qgspdalprovider.h"
#include "qgsmaplayer.h"

/**
Expand Down

0 comments on commit f5a4880

Please sign in to comment.