Skip to content

Commit

Permalink
Remove dependency on QtScript
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 10, 2017
1 parent ba4346b commit a45908f
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 170 deletions.
1 change: 0 additions & 1 deletion .docker/Dockerfile
Expand Up @@ -69,7 +69,6 @@ RUN apt-get update \
qt5keychain-dev \
qtbase5-dev \
qtpositioning5-dev \
qtscript5-dev \
qttools5-dev \
qttools5-dev-tools \
spawn-fcgi \
Expand Down
4 changes: 0 additions & 4 deletions CMakeLists.txt
Expand Up @@ -285,10 +285,6 @@ IF(WITH_CORE)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
FIND_PACKAGE(Qt5Script)
IF(Qt5Script_FOUND)
ADD_DEFINITIONS(-DWITH_QTSCRIPT)
ENDIF()
IF (WITH_QTWEBKIT)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
Expand Down
14 changes: 7 additions & 7 deletions INSTALL

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions debian/control
Expand Up @@ -20,7 +20,7 @@ Build-Depends:
libspatialite-dev,
libsqlite3-dev,
libspatialindex-dev,
qtbase5-dev, qttools5-dev-tools, qttools5-dev, qtscript5-dev, qtpositioning5-dev,
qtbase5-dev, qttools5-dev-tools, qttools5-dev, qtpositioning5-dev,
libqt5svg5-dev, libqt5xmlpatterns5-dev, libqt5webkit5-dev, libqt5opengl5-dev, libqt5sql5-sqlite, libqt5scintilla2-dev,
libqwt-qt5-dev, libqca-qt5-2-dev, libqca-qt5-2-plugins,
python3-dev, python3-all-dev, python3-sip, python3-sip-dev,
Expand Down Expand Up @@ -203,7 +203,6 @@ Depends:
libqt5webkit5-dev,
libqca-qt5-2-dev,
libqwt-qt5-dev,
qtscript5-dev,
qtpositioning5-dev,
pyqt5-dev-tools,
python3-pyqt5,
Expand Down
3 changes: 1 addition & 2 deletions debian/control.in
Expand Up @@ -21,7 +21,7 @@ Build-Depends:
libsqlite3-dev,
libspatialindex-dev,
libzip-dev,
qtbase5-dev, qttools5-dev-tools, qttools5-dev, qtscript5-dev, qtpositioning5-dev, qt5keychain-dev,
qtbase5-dev, qttools5-dev-tools, qttools5-dev, qtpositioning5-dev, qt5keychain-dev,
libqt5svg5-dev, libqt5xmlpatterns5-dev, libqt5webkit5-dev, libqt5opengl5-dev, libqt5sql5-sqlite, libqt5scintilla2-dev,
libqwt-qt5-dev, libqca-qt5-2-dev, libqca-qt5-2-plugins,
python3-dev, python3-all-dev, python3-sip, python3-sip-dev,
Expand Down Expand Up @@ -232,7 +232,6 @@ Depends:
libqt5webkit5-dev,
libqca-qt5-2-dev,
libqwt-qt5-dev,
qtscript5-dev,
qtpositioning5-dev,
pyqt5-dev-tools,
python3-pyqt5,
Expand Down
14 changes: 7 additions & 7 deletions doc/INSTALL.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions doc/linux.t2t

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mac/cmake/1qt.cmake.in
Expand Up @@ -16,8 +16,8 @@ SET (QT_FWVER @QT_VERSION_MAJOR@)
# build list of Qt frameworks to bundle

# core list, includes dependencies and used by extra plugins
SET (QTLISTQG QtCore QtGui phonon QtXml QtNetwork QtScript QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)
SET (PYQTLIST Qt QtCore QtGui phonon QtXml QtNetwork QtScript QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)
SET (QTLISTQG QtCore QtGui phonon QtXml QtNetwork QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)
SET (PYQTLIST Qt QtCore QtGui phonon QtXml QtNetwork QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)

# add Qsci.so, if available
IF (@QSCI_FOUND@)
Expand Down
1 change: 0 additions & 1 deletion rpm/qgis.spec.template
Expand Up @@ -84,7 +84,6 @@ BuildRequires: qscintilla-qt5-devel

# Qt5 stuff
BuildRequires: qt5-qtlocation-devel
BuildRequires: qt5-qtscript-devel
BuildRequires: qt5-qtsvg-devel
BuildRequires: qt5-qttools-static
BuildRequires: qt5-qtwebkit-devel
Expand Down
3 changes: 0 additions & 3 deletions src/providers/wms/CMakeLists.txt
Expand Up @@ -50,7 +50,6 @@ INCLUDE_DIRECTORIES(
INCLUDE_DIRECTORIES(SYSTEM
${GDAL_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
${QT_QTSCRIPT_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)
Expand All @@ -60,14 +59,12 @@ ADD_LIBRARY(wmsprovider MODULE ${WMS_SRCS} ${WMS_MOC_SRCS})

TARGET_LINK_LIBRARIES(wmsprovider
qgis_core
${QT_QTSCRIPT_LIBRARY}
${GDAL_LIBRARY} # for OGR_G_CreateGeometryFromJson()
)


TARGET_LINK_LIBRARIES(wmsprovider_a
qgis_core
${QT_QTSCRIPT_LIBRARY}
)


Expand Down
130 changes: 0 additions & 130 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -64,11 +64,6 @@
#include <QEventLoop>
#include <QTextCodec>
#include <QThread>
#ifdef WITH_QTSCRIPT
#include <QScriptEngine>
#include <QScriptValue>
#include <QScriptValueIterator>
#endif
#include <QNetworkDiskCache>
#include <QTimer>

Expand Down Expand Up @@ -2978,130 +2973,6 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
QgsFeatureStoreList featureStoreList;
QgsCoordinateTransform coordinateTransform;

#ifdef WITH_QTSCRIPT
json.prepend( '(' ).append( ')' );

QScriptEngine engine;
engine.evaluate( QStringLiteral( "function json_stringify(obj) { return JSON.stringify(obj); }" ) );
QScriptValue json_stringify = engine.globalObject().property( QStringLiteral( "json_stringify" ) );
Q_ASSERT( json_stringify.isFunction() );

QScriptValue result = engine.evaluate( json );

try
{
QgsDebugMsg( QString( "result:%1" ).arg( result.toString() ) );

if ( !result.isObject() )
throw QStringLiteral( "object expected" );

if ( result.property( QStringLiteral( "type" ) ).toString() != QLatin1String( "FeatureCollection" ) )
throw QStringLiteral( "type FeatureCollection expected: %1" ).arg( result.property( QStringLiteral( "type" ) ).toString() );

if ( result.property( QStringLiteral( "crs" ) ).isValid() )
{
QString crsType = result.property( QStringLiteral( "crs" ) ).property( QStringLiteral( "type" ) ).toString();
QString crsText;
if ( crsType == QLatin1String( "name" ) )
crsText = result.property( QStringLiteral( "crs" ) ).property( QStringLiteral( "properties" ) ).property( QStringLiteral( "name" ) ).toString();
else if ( crsType == QLatin1String( "EPSG" ) )
crsText = QStringLiteral( "%1:%2" ).arg( crsType, result.property( QStringLiteral( "crs" ) ).property( QStringLiteral( "properties" ) ).property( QStringLiteral( "code" ) ).toString() );
else
{
QgsDebugMsg( QString( "crs not supported:%1" ).arg( result.property( "crs" ).toString() ) );
}

QgsCoordinateReferenceSystem featuresCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsText );

if ( !featuresCrs.isValid() )
throw QStringLiteral( "CRS %1 invalid" ).arg( crsText );

if ( featuresCrs.isValid() && featuresCrs != crs() )
{
coordinateTransform = QgsCoordinateTransform( featuresCrs, crs() );
}
}

QScriptValue fc = result.property( QStringLiteral( "features" ) );
if ( !fc.isArray() )
throw QStringLiteral( "FeatureCollection array expected" );

QScriptValue f;
for ( int i = 0; f = fc.property( i ), f.isValid(); i++ )
{
QgsDebugMsg( QString( "feature %1" ).arg( i ) );

QScriptValue props = f.property( QStringLiteral( "properties" ) );
if ( !props.isObject() )
{
QgsDebugMsg( "no properties found" );
continue;
}

QgsFields fields;
QScriptValueIterator it( props );
while ( it.hasNext() )
{
it.next();
fields.append( QgsField( it.name(), QVariant::String ) );
}

QgsFeature feature( fields );

if ( f.property( QStringLiteral( "geometry" ) ).isValid() )
{
QScriptValue geom = json_stringify.call( QScriptValue(), QScriptValueList() << f.property( QStringLiteral( "geometry" ) ) );
if ( geom.isString() )
{
gdal::ogr_geometry_unique_ptr ogrGeom( OGR_G_CreateGeometryFromJson( geom.toString().toUtf8() ) );
if ( ogrGeom )
{
int wkbSize = OGR_G_WkbSize( ogrGeom.get() );
unsigned char *wkb = new unsigned char[ wkbSize ];
OGR_G_ExportToWkb( ogrGeom.get(), ( OGRwkbByteOrder ) QgsApplication::endian(), wkb );

QgsGeometry g;
g.fromWkb( wkb, wkbSize );
feature.setGeometry( g );

if ( coordinateTransform.isValid() && feature.hasGeometry() )
{
QgsGeometry transformed = feature.geometry();
transformed.transform( coordinateTransform );
feature.setGeometry( transformed );
}
}
}
}

int j = 0;
it.toFront();
while ( it.hasNext() )
{
it.next();
feature.setAttribute( j++, it.value().toString() );
}

QgsFeatureStore featureStore( fields, crs() );

QMap<QString, QVariant> params;
params.insert( QStringLiteral( "sublayer" ), layerList[count] );
params.insert( QStringLiteral( "featureType" ), QStringLiteral( "%1_%2" ).arg( count ).arg( i ) );
params.insert( QStringLiteral( "getFeatureInfoUrl" ), requestUrl.toString() );
featureStore.setParams( params );

feature.setValid( true );
featureStore.addFeature( feature );

featureStoreList.append( featureStore );
}
}
catch ( const QString &err )
{
QgsDebugMsg( QString( "JSON error: %1\nResult: %2" ).arg( err, QString::fromUtf8( mIdentifyResultBodies.value( jsonPart ) ) ) );
results.insert( results.size(), err ); // string returned for format type "feature" means error
}
#else
try
{
QJsonDocument doc = QJsonDocument::fromJson( json.toUtf8() );
Expand Down Expand Up @@ -3219,7 +3090,6 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
QgsDebugMsg( QString( "JSON error: %1\nResult: %2" ).arg( err, QString::fromUtf8( mIdentifyResultBodies.value( jsonPart ) ) ) );
results.insert( results.size(), err ); // string returned for format type "feature" means error
}
#endif

results.insert( results.size(), qVariantFromValue( featureStoreList ) );
}
Expand Down
4 changes: 0 additions & 4 deletions tests/src/providers/CMakeLists.txt
Expand Up @@ -104,17 +104,13 @@ IF(UNIX AND NOT ANDROID AND CMAKE_BUILD_TYPE MATCHES Debug)
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core/raster
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/providers/wcs
)
INCLUDE_DIRECTORIES(SYSTEM
${QT_QTSCRIPT_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(qgis_wcstest
${QT_QTCORE_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTSVG_LIBRARY}
${QT_QTXML_LIBRARY}
${OPTIONAL_QTWEBKIT}
${QT_QTSCRIPT_LIBRARY}
qgis_core
)

Expand Down

0 comments on commit a45908f

Please sign in to comment.