-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to make tessellation of polygons without Z work again
+ initial work on unit testing of tessellator
- Loading branch information
Showing
6 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Standard includes and utils to compile into all tests. | ||
SET (util_SRCS) | ||
|
||
|
||
##################################################### | ||
# Don't forget to include output directory, otherwise | ||
# the UI file won't be wrapped! | ||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_SOURCE_DIR}/tests/core #for render checker class | ||
${CMAKE_SOURCE_DIR}/src/3d | ||
${CMAKE_SOURCE_DIR}/src/core | ||
${CMAKE_SOURCE_DIR}/src/core/expression | ||
${CMAKE_SOURCE_DIR}/src/core/auth | ||
${CMAKE_SOURCE_DIR}/src/core/composer | ||
${CMAKE_SOURCE_DIR}/src/core/geometry | ||
${CMAKE_SOURCE_DIR}/src/core/layout | ||
${CMAKE_SOURCE_DIR}/src/core/metadata | ||
${CMAKE_SOURCE_DIR}/src/core/raster | ||
${CMAKE_SOURCE_DIR}/src/core/symbology | ||
${CMAKE_SOURCE_DIR}/src/core/fieldformatter | ||
${CMAKE_SOURCE_DIR}/src/test | ||
${CMAKE_SOURCE_DIR}/src/native | ||
|
||
|
||
${CMAKE_BINARY_DIR}/src/core | ||
${CMAKE_BINARY_DIR}/src/3d | ||
${CMAKE_BINARY_DIR}/src/ui | ||
${CMAKE_BINARY_DIR}/src/native | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
INCLUDE_DIRECTORIES(SYSTEM | ||
${QT_INCLUDE_DIR} | ||
${GDAL_INCLUDE_DIR} | ||
${PROJ_INCLUDE_DIR} | ||
${GEOS_INCLUDE_DIR} | ||
) | ||
|
||
#note for tests we should not include the moc of our | ||
#qtests in the executable file list as the moc is | ||
#directly included in the sources | ||
#and should not be compiled twice. Trying to include | ||
#them in will cause an error at build time | ||
############################################################# | ||
# Tests: | ||
|
||
MACRO (ADD_QGIS_TEST testname testsrc) | ||
SET(qgis_${testname}_SRCS ${testsrc} ${util_SRCS}) | ||
SET(qgis_${testname}_MOC_CPPS ${testsrc}) | ||
ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS}) | ||
SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES AUTOMOC TRUE) | ||
SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES AUTORCC TRUE) | ||
TARGET_LINK_LIBRARIES(qgis_${testname} | ||
${QT_QTXML_LIBRARY} | ||
${QT_QTCORE_LIBRARY} | ||
${QT_QTSVG_LIBRARY} | ||
${QT_QTTEST_LIBRARY} | ||
${QT_QTNETWORK_LIBRARY} | ||
${PROJ_LIBRARY} | ||
${GEOS_LIBRARY} | ||
${GDAL_LIBRARY} | ||
qgis_core | ||
qgis_3d) | ||
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000) | ||
TARGET_LINK_LIBRARIES(qgis_${testname} qgis_native) | ||
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname}) | ||
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES | ||
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR} | ||
# INSTALL_RPATH_USE_LINK_PATH true ) | ||
ENDMACRO (ADD_QGIS_TEST) | ||
|
||
ADD_QGIS_TEST(tessellatortest testqgstessellator.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*************************************************************************** | ||
testqgstessellator.cpp | ||
---------------------- | ||
Date : October 2017 | ||
Copyright : (C) 2017 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgstest.h" | ||
|
||
#include "qgspoint.h" | ||
#include "qgspolygon.h" | ||
#include "qgstessellator.h" | ||
|
||
|
||
/** | ||
* \ingroup UnitTests | ||
* This is a unit test for the node tool | ||
*/ | ||
class TestQgsTessellator : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
TestQgsTessellator(); | ||
|
||
private slots: | ||
void initTestCase();// will be called before the first testfunction is executed. | ||
void cleanupTestCase();// will be called after the last testfunction was executed. | ||
|
||
void testBasic(); | ||
|
||
private: | ||
}; | ||
|
||
TestQgsTessellator::TestQgsTessellator() = default; | ||
|
||
|
||
//runs before all tests | ||
void TestQgsTessellator::initTestCase() | ||
{ | ||
} | ||
|
||
//runs after all tests | ||
void TestQgsTessellator::cleanupTestCase() | ||
{ | ||
} | ||
|
||
void TestQgsTessellator::testBasic() | ||
{ | ||
QgsPolygonV2 polygon; | ||
polygon.fromWkt( "POLYGON((1 1, 2 1, 3 2, 1 2, 1 1))" ); | ||
|
||
QgsTessellator t( 0, 0, false ); | ||
t.addPolygon( polygon, 0 ); | ||
|
||
QVector<float> polygonData = t.data(); | ||
QCOMPARE( polygonData.count(), 2 * 3 * 3 ); // two triangles (3 points with x/y/z coords) | ||
} | ||
|
||
|
||
QGSTEST_MAIN( TestQgsTessellator ) | ||
#include "testqgstessellator.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters