Skip to content
Permalink
Browse files

Merge pull request #5817 from m-kuhn/noQtScript

Remove dependency on deprecated QtScript library
  • Loading branch information
elpaso committed Dec 11, 2017
2 parents b1db8da + 02b6976 commit e0aa5e1f1162cf7087cdc9a21a53abb806eb2ac1
@@ -69,7 +69,6 @@ RUN apt-get update \
qt5keychain-dev \
qtbase5-dev \
qtpositioning5-dev \
qtscript5-dev \
qttools5-dev \
qttools5-dev-tools \
spawn-fcgi \
@@ -291,7 +291,6 @@ IF(WITH_CORE)
ENDIF(WITH_QTWEBKIT)
FIND_PACKAGE(Qt5Test REQUIRED)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
IF (WITH_3D)
FIND_PACKAGE(Qt53DCore REQUIRED)
14 INSTALL

Large diffs are not rendered by default.

@@ -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,
@@ -203,7 +203,6 @@ Depends:
libqt5webkit5-dev,
libqca-qt5-2-dev,
libqwt-qt5-dev,
qtscript5-dev,
qtpositioning5-dev,
pyqt5-dev-tools,
python3-pyqt5,
@@ -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,
@@ -232,7 +232,6 @@ Depends:
libqt5webkit5-dev,
libqca-qt5-2-dev,
libqwt-qt5-dev,
qtscript5-dev,
qtpositioning5-dev,
pyqt5-dev-tools,
python3-pyqt5,

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -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@)
@@ -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
@@ -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}
)
@@ -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}
)


@@ -64,9 +64,6 @@
#include <QEventLoop>
#include <QTextCodec>
#include <QThread>
#include <QScriptEngine>
#include <QScriptValue>
#include <QScriptValueIterator>
#include <QNetworkDiskCache>
#include <QTimer>

@@ -2972,39 +2969,33 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
else if ( jsonPart != -1 )
{
QString json = QString::fromUtf8( mIdentifyResultBodies.value( jsonPart ) );
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 );

QgsFeatureStoreList featureStoreList;
QgsCoordinateTransform coordinateTransform;

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

if ( !result.isObject() )
throw QStringLiteral( "object expected" );
QJsonDocument doc = QJsonDocument::fromJson( json.toUtf8() );
if ( doc.isNull() )
throw QStringLiteral( "Doc expected" );
if ( !doc.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() );
QJsonObject result = doc.object();
if ( result.value( QLatin1String( "type" ) ).toString() != QLatin1String( "FeatureCollection" ) )
throw QStringLiteral( "Type FeatureCollection expected: %1" ).arg( result.value( QLatin1String( "type" ) ).toString() );

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

QgsCoordinateReferenceSystem featuresCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsText );
@@ -3018,69 +3009,71 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
}
}

QScriptValue fc = result.property( QStringLiteral( "features" ) );
const QJsonValue fc = result.value( QLatin1String( "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 ) );
const QJsonArray features = fc.toArray();

QScriptValue props = f.property( QStringLiteral( "properties" ) );
int i = -1;
for ( const QJsonValue &fv : features )
{
++i;
const QJsonObject f = fv.toObject();
const QJsonValue props = f.value( QLatin1String( "properties" ) );
if ( !props.isObject() )
{
QgsDebugMsg( "no properties found" );
continue;
}

QgsFields fields;
QScriptValueIterator it( props );
while ( it.hasNext() )

const QJsonObject properties = props.toObject();
auto fieldIterator = properties.constBegin();

for ( ; fieldIterator != properties.constEnd(); ++fieldIterator )
{
it.next();
fields.append( QgsField( it.name(), QVariant::String ) );
fields.append( QgsField( fieldIterator.key(), QVariant::String ) );
}

QgsFeature feature( fields );

if ( f.property( QStringLiteral( "geometry" ) ).isValid() )
if ( f.value( QLatin1String( "geometry" ) ).isObject() )
{
QScriptValue geom = json_stringify.call( QScriptValue(), QScriptValueList() << f.property( QStringLiteral( "geometry" ) ) );
if ( geom.isString() )
QJsonDocument serializer( f.value( QLatin1String( "geometry" ) ).toObject() );
QString geom = serializer.toJson( QJsonDocument::JsonFormat::Compact );

gdal::ogr_geometry_unique_ptr ogrGeom( OGR_G_CreateGeometryFromJson( geom.toUtf8() ) );
if ( ogrGeom )
{
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() )
{
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 );
}
QgsGeometry transformed = feature.geometry();
transformed.transform( coordinateTransform );
feature.setGeometry( transformed );
}
}
}

int j = 0;
it.toFront();
while ( it.hasNext() )
fieldIterator = properties.constBegin();
for ( ; fieldIterator != properties.constEnd(); ++fieldIterator )
{
it.next();
feature.setAttribute( j++, it.value().toString() );
feature.setAttribute( j++, fieldIterator.value().toString() );
}

QgsFeatureStore featureStore( fields, crs() );

QMap<QString, QVariant> params;
QVariantMap params;
params.insert( QStringLiteral( "sublayer" ), layerList[count] );
params.insert( QStringLiteral( "featureType" ), QStringLiteral( "%1_%2" ).arg( count ).arg( i ) );
params.insert( QStringLiteral( "getFeatureInfoUrl" ), requestUrl.toString() );
@@ -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
)

@@ -21,9 +21,6 @@
#include <QString>
#include <QStringList>
#include <QTextStream>
#include <QScriptEngine>
#include <QScriptValue>
#include <QScriptValueIterator>

#include "qgsapplication.h"
#include "qgsdatasourceuri.h"
@@ -121,56 +118,52 @@ void TestQgsWcsPublicServers::init()
QString data = file.readAll();
//QgsDebugMsg("servers: \n" + str );
file.close();
QScriptEngine engine;
QScriptValue result = engine.evaluate( data );
QJsonDocument doc = QJsonDocument::fromJson( data.toUtf8() );
const QJsonObject result = doc.object();

QScriptValueIterator serverIt( result );
while ( serverIt.hasNext() )
QJsonObject::ConstIterator serverIt = result.constBegin();
for ( ; serverIt != result.constEnd(); serverIt++ )
{
serverIt.next();
QScriptValue serverValue = serverIt.value();
const QJsonObject serverObject = serverIt.value().toObject();
const QString serverUrl = serverObject.value( QLatin1String( "url" ) ).toString();

QString serverUrl = serverValue.property( QStringLiteral( "url" ) ).toString();
QgsDebugMsg( "serverUrl: " + serverUrl );

Server server( serverUrl );
server.description = serverValue.property( QStringLiteral( "description" ) ).toString();
server.description = serverObject.value( QLatin1String( "description" ) ).toString();

QScriptValueIterator paramsIt( serverValue.property( QStringLiteral( "params" ) ) );
while ( paramsIt.hasNext() )
const QJsonObject serverParams = serverObject.value( QLatin1String( "params" ) ).toObject();
QJsonObject::ConstIterator paramsIt = serverParams.constBegin();
for ( ; paramsIt != serverParams.constEnd(); paramsIt++ )
{
paramsIt.next();
QgsDebugMsg( QString( "params value: %1" ).arg( paramsIt.value().toString() ) );
server.params.insert( paramsIt.name(), paramsIt.value().toString() );
server.params.insert( paramsIt.key(), paramsIt.value().toString() );
}

QScriptValue issuesValue = serverValue.property( QStringLiteral( "issues" ) );
QJsonObject issuesObject = serverObject.value( QLatin1String( "issues" ) ).toObject();

QScriptValueIterator issuesIt( issuesValue );
while ( issuesIt.hasNext() )
QJsonObject::ConstIterator issuesIt = issuesObject.constBegin();
for ( ; issuesIt != issuesObject.constEnd(); ++issuesIt )
{
issuesIt.next();
QScriptValue issueValue = issuesIt.value();
QJsonObject issueObject = issuesIt.value().toObject();

QString description = issueValue.property( QStringLiteral( "description" ) ).toString();
QString description = issueObject.value( QLatin1String( "description" ) ).toString();
QgsDebugMsg( "description: " + description );
Issue issue( description );

issue.offender = issueValue.property( QStringLiteral( "offender" ) ).toString();
issue.offender = issueObject.value( QLatin1String( "offender" ) ).toString();

QScriptValue coveragesValue = issueValue.property( QStringLiteral( "coverages" ) );
QScriptValueIterator coveragesIt( coveragesValue );
while ( coveragesIt.hasNext() )
QJsonObject coveragesObject = issueObject.value( QLatin1String( "coverages" ) ).toObject();
QJsonObject::ConstIterator coverageIt = coveragesObject.constBegin();
for ( ; coverageIt != coveragesObject.constEnd(); ++coverageIt )
{
coveragesIt.next();
issue.coverages << coveragesIt.value().toString();
issue.coverages << coverageIt.value().toString();
}

QScriptValue versionsValue = issueValue.property( QStringLiteral( "versions" ) );
QScriptValueIterator versionsIt( versionsValue );
while ( versionsIt.hasNext() )
QJsonObject versionsObject = issueObject.value( QLatin1String( "versions" ) ).toObject();
QJsonObject::ConstIterator versionsIt = versionsObject.constBegin();
for ( ; versionsIt != versionsObject.constEnd(); ++versionsIt )
{
versionsIt.next();
issue.versions << versionsIt.value().toString();
}

0 comments on commit e0aa5e1

Please sign in to comment.
You can’t perform that action at this time.